aboutsummaryrefslogtreecommitdiff
path: root/init.lua
blob: bc8ae85112a36e208591316b6c495768dd5176fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
local function escape_texture(str)
	return str:gsub("[%[%()^:]", "\\%1")
end

function render_depboard(pos, objref)
	local font = font_api.get_font("metro")
	local line = font:render("10", font:get_height(1)*15, font:get_height(1), {halign="left", color="#ffffff"})
	local dest = font:render("Origin Marcuse", font:get_height(1)*15, font:get_height(1), {halign="left", color="#ffffff"})
	local remark = font:render("5 minutes Delay", font:get_height(1)*15, font:get_height(1), {halign="left", color="#ff0000"})
	local m = font:render("10", font:get_height(1)*15, font:get_height(1), {halign="left", color="#ffffff"})
	local s = font:render("40", font:get_height(1)*15, font:get_height(1), {halign="left", color="#ffffff"})
	local line_color = "#00ffff"
	objref:set_properties({ textures= {"[combine:256x256:0,0=station_sign.png\\^(line_bg.png\\^\\[colorize\\:"..line_color.."\\:150)\\^\\[resize\\:256x256:200,100="..escape_texture(line)..":10,100="..escape_texture(dest)..":200,127="..escape_texture(m)..":228,127="..escape_texture(s)..":10,127="..escape_texture(remark)},
	                        visual_size = {x=3, y=3} })


end


display_api.register_display_entity("departureboards:display")

minetest.register_node("departureboards:departureboard", {
		sunlight_propagates = true,
		paramtype = "light",
		paramtype2 = "facedir",
		drawtype = "nodebox",
		node_box = {
			type = "fixed",
			fixed = {-3/2, -1/2, 0.5,
					 3/2, 1/2, 0.5 - 0.1},
		},
		tiles = { "signs_road_sides.png", "signs_road_sides.png", 
			          "signs_road_sides.png", "signs_road_sides.png", 
			          "signs_road_sides.png", "signs_road_sides.png" },
		groups = {choppy=2, dig_immediate=2, not_blocking_trains=1, display_api=1},
		sounds = default.node_sound_defaults(),
		display_entities = {
			["departureboards:display"] = {
					on_display_update = render_depboard,
					depth = 0.5 - display_api.entity_spacing - 0.1,
					size = { x = 3, y = 1 },
					aspect_ratio = 1/2,
					maxlines = 1,
			},
		},
		light_source = 3,
		on_place = display_api.on_place,
		on_construct = 	function(pos)
				local ndef = minetest.registered_nodes[minetest.get_node(pos).name]
				local meta = minetest.get_meta(pos)
				meta:set_string("font", ndef.display_entities.font_name or
				                        font_api.get_default_font_name())
				signs_api.set_formspec(pos)
				display_api.on_construct(pos)
			end,
		on_destruct = display_api.on_destruct,
		on_rotate = signs_api.on_rotate,
		on_receive_fields =  signs_api.on_receive_fields,
		on_punch = function(pos, node, player, pointed_thing)
				signs_api.set_formspec(pos)
				display_api.update_entities(pos)
		end,
})