aestivalserver-mods/illuna_aestival/src/signs.lua

125 lines
4.1 KiB
Lua
Executable File

-- cherry-picks from https://gitlab.com/VanessaE/street_signs (LGPL 3.0)
-- it is strongly recommended to grab the original mod.
--
minetest.register_alias("signs:text", "signs_lib:text")
--
street_signs = {}
street_signs.path = minetest.get_modpath(minetest.get_current_modname())
screwdriver = screwdriver or {}
street_signs.lbm_restore_nodes = {}
street_signs.big_sign_sizes = {
-- "size", lines, chars, hscale, vscale, xoffs, yoffs, box
{ "small", 3, 50, 1.3, 1.05, 7, 5, { -0.5, -0.5, -0.5, -0.4, 0.5, 1.5 } },
{ "medium", 6, 50, 1.3, 1.05, 7, 5, { -0.5, -0.5, -0.5, -0.4, 1.5, 1.5 } },
{ "large", 6, 80, 1, 1.05, 7, 5, { -0.5, -0.5, -0.5, -0.4, 1.5, 2.5 } }
}
street_signs.big_sign_colors = {
{ "green", "f", "dye:green", "dye:white" },
{ "blue", "f", "dye:blue", "dye:white" },
{ "yellow", "0", "dye:yellow", "dye:black" },
{ "orange", "0", "dye:orange", "dye:black" }
}
-- restore signs' text after /clearobjects and the like, the next time
-- a block is reloaded by the server.
minetest.register_lbm({
nodenames = street_signs.lbm_restore_nodes,
name = ":street_signs:restore_sign_text",
label = "Restore sign text",
run_at_every_load = true,
action = function(pos, node)
street_signs.update_sign(pos)
end
})
local cbox = signs_lib.make_selection_boxes(36, 36)
for _, s in ipairs(street_signs.big_sign_sizes) do
local size = s[1]
local nlines = s[2]
local nchars = s[3]
local hscale = s[4]
local vscale = s[5]
local xoffs = s[6]
local yoffs = s[7]
local cbox = {
type = "wallmounted",
wall_side = s[8],
wall_top = { -s[8][3], -s[8][1], s[8][2], -s[8][6], -s[8][4], s[8][5] },
wall_bottom = { s[8][3], s[8][1], s[8][2], s[8][6], s[8][4], s[8][5] }
}
for _, c in ipairs(street_signs.big_sign_colors) do
local color = c[1]
local defc = c[2]
signs_lib.register_sign("street_signs:sign_highway_"..size.."_"..color, {
description = "Generic highway sign ("..nlines.."-line, "..size..", "..color..")",
inventory_image = "street_signs_generic_highway_"..size.."_"..color.."_inv.png",
selection_box = cbox,
mesh = "street_signs_generic_highway_"..size.."_wall.obj",
tiles = {
"street_signs_generic_highway_"..size.."_"..color..".png",
"street_signs_generic_highway_edges.png"
},
default_color = defc,
groups = signs_lib.standard_steel_groups,
sounds = signs_lib.standard_steel_sign_sounds,
number_of_lines = nlines,
chars_per_line = nchars,
horiz_scaling = hscale,
vert_scaling = vscale,
line_spacing = 2,
font_size = 31,
x_offset = xoffs,
y_offset = yoffs,
entity_info = {
mesh = "street_signs_generic_highway_"..size.."_entity_wall.obj",
yaw = signs_lib.wallmounted_yaw
},
allow_widefont = true,
allow_onpole = true
})
minetest.register_alias("street_signs:sign_highway_widefont_"..size.."_"..color,
"street_signs:sign_highway_"..size.."_"..color.."_widefont")
end
end
cbox = signs_lib.make_selection_boxes(60, 24)
signs_lib.register_sign("street_signs:sign_roundabout_directional", {
description = "R6-4b: Roundabout direction (4 chevrons)",
selection_box = cbox,
mesh = "street_signs_generic_sign_60x24_wall.obj",
tiles = {
"street_signs_roundabout_directional.png",
"street_signs_sign_edge.png",
},
inventory_image = "street_signs_roundabout_directional_inv.png",
groups = signs_lib.standard_steel_groups,
sounds = signs_lib.standard_steel_sign_sounds,
allow_onpole = true,
allow_onpole_horizontal = true,
})
signs_lib.register_sign("street_signs:sign_roundabout_directional_left", {
description = "R6-4b: Roundabout direction (4 chevrons, pointing left)",
selection_box = cbox,
mesh = "street_signs_generic_sign_60x24_wall.obj",
tiles = {
"street_signs_roundabout_directional_left.png",
"street_signs_sign_edge.png",
},
inventory_image = "street_signs_roundabout_directional_left_inv.png",
groups = signs_lib.standard_steel_groups,
sounds = signs_lib.standard_steel_sign_sounds,
allow_onpole = true,
allow_onpole_horizontal = true,
})