From e0cb875a9f356207ad327558ce335adab54c2531 Mon Sep 17 00:00:00 2001 From: gpcf Date: Sat, 13 May 2023 23:50:23 +0200 Subject: initial commit --- init.lua | 63 ++++++++++++++++++++++++++++++++++++++++++++++ mod.conf | 5 ++++ textures/line_bg.png | Bin 0 -> 629 bytes textures/station_sign.png | Bin 0 -> 740 bytes 4 files changed, 68 insertions(+) create mode 100644 init.lua create mode 100644 mod.conf create mode 100644 textures/line_bg.png create mode 100644 textures/station_sign.png diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..bc8ae85 --- /dev/null +++ b/init.lua @@ -0,0 +1,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, +}) diff --git a/mod.conf b/mod.conf new file mode 100644 index 0000000..93fbb8f --- /dev/null +++ b/mod.conf @@ -0,0 +1,5 @@ +name = departureboards +title = Departure Boards +description = A mod providing departure boards for advtrains +depends = default,display_api,font_api,signs_api +optional_depends = intllib \ No newline at end of file diff --git a/textures/line_bg.png b/textures/line_bg.png new file mode 100644 index 0000000..9adc772 Binary files /dev/null and b/textures/line_bg.png differ diff --git a/textures/station_sign.png b/textures/station_sign.png new file mode 100644 index 0000000..fede238 Binary files /dev/null and b/textures/station_sign.png differ -- cgit v1.2.3