aboutsummaryrefslogtreecommitdiff
path: root/advtrains_train_track/models
diff options
context:
space:
mode:
authorBlockhead <jbis1337@hotmail.com>2020-03-03 20:53:25 +1100
committerBlockhead <jbis1337@hotmail.com>2020-03-03 23:00:20 +1100
commit378d8625721ac24401c772531ed348ecae4e4fb3 (patch)
treefa1e2fb5122b3cc1a431e34c4e6036b0612cacd7 /advtrains_train_track/models
parent9d7b21c451ac5ae9475236814f33e5627061ece1 (diff)
downloadadvtrains-378d8625721ac24401c772531ed348ecae4e4fb3.tar.gz
advtrains-378d8625721ac24401c772531ed348ecae4e4fb3.tar.bz2
advtrains-378d8625721ac24401c772531ed348ecae4e4fb3.zip
Draft copy tool
The copy tool copies a train to a global clipboard. It copies the Line number, Routing code, inside text and outside text. It copies the kinds of wagons in the train and whether they are flipped around. Pasting with the copy tool will conditionally flip the train such that 'your front' of the train, rather than the absolute front of the train, is what is output. The new train is oriented to travel forward with the placing player's view. Conditons are: - Multi-unit/push-pull train (= has locomotives on both ends): Never flipped - Locomotive-hauled train (= has one end with a locomotive): Flipped so that the locomotive is always at the front. If the locomotive points long hood forward, it will still point long hood forward. - Rake of wagons (= has no locomotives on ends): Flipped according to which end of the train the player copies from. If the player is towards the back (wagon out of train divded by total wagons > 0.5), then the back becomes the new front. If the player is towards the front, no change.
Diffstat (limited to 'advtrains_train_track/models')
0 files changed, 0 insertions, 0 deletions
'>158 159 160 161 162 163 164 165

local health_bar_definition =
{
	hud_elem_type = "statbar",
	position = { x=0.5, y=1 },
	text = "heart.png",
	number = 20,
	direction = 0,
	size = { x=24, y=24 },
	offset = { x=(-10*24)-25, y=-(48+24+10)},
}

local breath_bar_definition =
{
	hud_elem_type = "statbar",
	position = { x=0.5, y=1 },
	text = "bubble.png",
	number = 20,
	direction = 0,
	size = { x=24, y=24 },
	offset = {x=25,y=-(48+24+10)},
}

local hud_ids = {}

local function initialize_builtin_statbars(player)

	if not player:is_player() then
		return
	end

	local name = player:get_player_name()

	if name == "" then
		return
	end

	if (hud_ids[name] == nil) then
		hud_ids[name] = {}
		-- flags are not transmitted to client on connect, we need to make sure
		-- our current flags are transmitted by sending them actively
		player:hud_set_flags(player:hud_get_flags())
	end

	if player:hud_get_flags().healthbar and
			core.is_yes(core.setting_get("enable_damage")) then
		if hud_ids[name].id_healthbar == nil then
			health_bar_definition.number = player:get_hp()
			hud_ids[name].id_healthbar  = player:hud_add(health_bar_definition)
		end
	else
		if hud_ids[name].id_healthbar ~= nil then
			player:hud_remove(hud_ids[name].id_healthbar)
			hud_ids[name].id_healthbar = nil
		end
	end