summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcheapie <no-email-for-you@example.com>2019-05-17 17:02:59 -0500
committercheapie <no-email-for-you@example.com>2019-05-17 17:03:41 -0500
commit847588d8726c0e6ba4da1091fbaa9864bda0147b (patch)
tree32f91938dea8501a7e50c01971891141574e76b8
parentfb3e3c0b34919481a2a2b010394c91c6069ed7cf (diff)
downloadelevatorparts-847588d8726c0e6ba4da1091fbaa9864bda0147b.tar
elevatorparts-847588d8726c0e6ba4da1091fbaa9864bda0147b.tar.gz
elevatorparts-847588d8726c0e6ba4da1091fbaa9864bda0147b.tar.bz2
elevatorparts-847588d8726c0e6ba4da1091fbaa9864bda0147b.tar.xz
elevatorparts-847588d8726c0e6ba4da1091fbaa9864bda0147b.zip
Add flashing fire/independent service messages to PIs
-rw-r--r--init.lua125
1 files changed, 108 insertions, 17 deletions
diff --git a/init.lua b/init.lua
index a95f860..6519b76 100644
--- a/init.lua
+++ b/init.lua
@@ -573,7 +573,6 @@ local chars = {
["y"] = "elevatorparts_pi_y.png",
["z"] = "elevatorparts_pi_2.png",
["-"] = "elevatorparts_pi_dash.png",
- [" "] = "elevatorparts_transparent.png",
}
minetest.register_entity("elevatorparts:pi_entity",{
@@ -595,11 +594,11 @@ local function removeEntity(pos)
end
local function generateTexture(text,uparrow,downarrow)
- local out = string.format("[combine:64x64:0,0=elevatorparts_transparent.png")
+ local out = "[combine:64x64:0,0=elevatorparts_transparent.png"
local pos = 0
for i=1,string.len(text),1 do
local char = string.sub(text,i,i)
- out = out..string.format(":%d,7=%s",pos*12+22,chars[char] or chars["-"])
+ if char ~= " " then out = out..string.format(":%d,%d=%s",pos*12+22,7,chars[char] or chars["-"]) end
pos = pos+1
end
if uparrow then out = out..":6,7=elevatorparts_pi_arrow_up.png"
@@ -616,7 +615,19 @@ local function updateDisplay(pos)
local fdir = minetest.facedir_to_dir(minetest.get_node(pos).param2)
local uparrow = meta:get_int("uparrow") > 0
local downarrow = meta:get_int("downarrow") > 0
+ local flash_fs = meta:get_int("flash_fs") > 0
+ local flash_is = meta:get_int("flash_is") > 0
+ local flashtimer = meta:get_int("flashtimer") > 0
local etex = generateTexture(text,uparrow,downarrow)
+ if flash_fs then
+ if flashtimer then etex = generateTexture(" fs",uparrow,downarrow) end
+ entity:set_properties({_flash_fs = true,_flash_is = false,})
+ elseif flash_is then
+ if flashtimer then etex = generateTexture(" n",uparrow,downarrow) end
+ entity:set_properties({_flash_fs = false,_flash_is = true,})
+ else
+ entity:set_properties({_flash_fs = false,_flash_is = false,})
+ end
entity:set_properties({textures={etex}})
entity:set_yaw((fdir.x ~= 0) and math.pi/2 or 0)
entity:setpos(vector.add(pos,vector.multiply(fdir,0.45)))
@@ -632,13 +643,16 @@ local pi_ignore = {
arrow_up = true,
arrow_down = true,
arrow_off = true,
+ flash_is = true,
+ flash_fs = true,
+ flash_off = true,
}
minetest.register_node("elevatorparts:pilantern_up_off",{
description = "PI + Up Lantern Combo",
groups = {
dig_immediate = 2,
- elevatorparts_pi_lbm = 1,
+ elevatorparts_pi_abm = 1,
},
tiles = {
"elevatorparts_generic_bg.png",
@@ -694,6 +708,15 @@ minetest.register_node("elevatorparts:pilantern_up_off",{
elseif msg == "arrow_off" then
meta:set_int("uparrow",0)
meta:set_int("downarrow",0)
+ elseif msg == "flash_is" then
+ meta:set_int("flash_is",1)
+ meta:set_int("flash_fs",0)
+ elseif msg == "flash_fs" then
+ meta:set_int("flash_is",0)
+ meta:set_int("flash_fs",1)
+ elseif msg == "flash_off" then
+ meta:set_int("flash_is",0)
+ meta:set_int("flash_fs",0)
elseif not pi_ignore[msg] then
meta:set_string("text",string.sub(" "..msg,-3,-1))
end
@@ -708,7 +731,7 @@ minetest.register_node("elevatorparts:pilantern_up_on",{
groups = {
dig_immediate = 2,
not_in_creative_inventory = 1,
- elevatorparts_pi_lbm = 1,
+ elevatorparts_pi_abm = 1,
},
tiles = {
"elevatorparts_generic_bg.png",
@@ -765,6 +788,15 @@ minetest.register_node("elevatorparts:pilantern_up_on",{
elseif msg == "arrow_off" then
meta:set_int("uparrow",0)
meta:set_int("downarrow",0)
+ elseif msg == "flash_is" then
+ meta:set_int("flash_is",1)
+ meta:set_int("flash_fs",0)
+ elseif msg == "flash_fs" then
+ meta:set_int("flash_is",0)
+ meta:set_int("flash_fs",1)
+ elseif msg == "flash_off" then
+ meta:set_int("flash_is",0)
+ meta:set_int("flash_fs",0)
elseif not pi_ignore[msg] then
meta:set_string("text",string.sub(" "..msg,-3,-1))
end
@@ -778,7 +810,7 @@ minetest.register_node("elevatorparts:pilantern_down_off",{
description = "PI + Down Lantern Combo",
groups = {
dig_immediate = 2,
- elevatorparts_pi_lbm = 1,
+ elevatorparts_pi_abm = 1,
},
tiles = {
"elevatorparts_generic_bg.png",
@@ -834,6 +866,15 @@ minetest.register_node("elevatorparts:pilantern_down_off",{
elseif msg == "arrow_off" then
meta:set_int("uparrow",0)
meta:set_int("downarrow",0)
+ elseif msg == "flash_is" then
+ meta:set_int("flash_is",1)
+ meta:set_int("flash_fs",0)
+ elseif msg == "flash_fs" then
+ meta:set_int("flash_is",0)
+ meta:set_int("flash_fs",1)
+ elseif msg == "flash_off" then
+ meta:set_int("flash_is",0)
+ meta:set_int("flash_fs",0)
elseif not pi_ignore[msg] then
meta:set_string("text",string.sub(" "..msg,-3,-1))
end
@@ -848,7 +889,7 @@ minetest.register_node("elevatorparts:pilantern_down_on",{
groups = {
dig_immediate = 2,
not_in_creative_inventory = 1,
- elevatorparts_pi_lbm = 1,
+ elevatorparts_pi_abm = 1,
},
tiles = {
"elevatorparts_generic_bg.png",
@@ -905,6 +946,15 @@ minetest.register_node("elevatorparts:pilantern_down_on",{
elseif msg == "arrow_off" then
meta:set_int("uparrow",0)
meta:set_int("downarrow",0)
+ elseif msg == "flash_is" then
+ meta:set_int("flash_is",1)
+ meta:set_int("flash_fs",0)
+ elseif msg == "flash_fs" then
+ meta:set_int("flash_is",0)
+ meta:set_int("flash_fs",1)
+ elseif msg == "flash_off" then
+ meta:set_int("flash_is",0)
+ meta:set_int("flash_fs",0)
elseif not pi_ignore[msg] then
meta:set_string("text",string.sub(" "..msg,-3,-1))
end
@@ -918,7 +968,7 @@ minetest.register_node("elevatorparts:pilantern_updown_off",{
description = "PI + Up and Down Lantern Combo",
groups = {
dig_immediate = 2,
- elevatorparts_pi_lbm = 1,
+ elevatorparts_pi_abm = 1,
},
tiles = {
"elevatorparts_generic_bg.png",
@@ -977,6 +1027,15 @@ minetest.register_node("elevatorparts:pilantern_updown_off",{
elseif msg == "arrow_off" then
meta:set_int("uparrow",0)
meta:set_int("downarrow",0)
+ elseif msg == "flash_is" then
+ meta:set_int("flash_is",1)
+ meta:set_int("flash_fs",0)
+ elseif msg == "flash_fs" then
+ meta:set_int("flash_is",0)
+ meta:set_int("flash_fs",1)
+ elseif msg == "flash_off" then
+ meta:set_int("flash_is",0)
+ meta:set_int("flash_fs",0)
elseif not pi_ignore[msg] then
meta:set_string("text",string.sub(" "..msg,-3,-1))
end
@@ -991,7 +1050,7 @@ minetest.register_node("elevatorparts:pilantern_updown_upon",{
groups = {
dig_immediate = 2,
not_in_creative_inventory = 1,
- elevatorparts_pi_lbm = 1,
+ elevatorparts_pi_abm = 1,
},
tiles = {
"elevatorparts_generic_bg.png",
@@ -1051,6 +1110,15 @@ minetest.register_node("elevatorparts:pilantern_updown_upon",{
elseif msg == "arrow_off" then
meta:set_int("uparrow",0)
meta:set_int("downarrow",0)
+ elseif msg == "flash_is" then
+ meta:set_int("flash_is",1)
+ meta:set_int("flash_fs",0)
+ elseif msg == "flash_fs" then
+ meta:set_int("flash_is",0)
+ meta:set_int("flash_fs",1)
+ elseif msg == "flash_off" then
+ meta:set_int("flash_is",0)
+ meta:set_int("flash_fs",0)
elseif not pi_ignore[msg] then
meta:set_string("text",string.sub(" "..msg,-3,-1))
end
@@ -1065,7 +1133,7 @@ minetest.register_node("elevatorparts:pilantern_updown_downon",{
groups = {
dig_immediate = 2,
not_in_creative_inventory = 1,
- elevatorparts_pi_lbm = 1,
+ elevatorparts_pi_abm = 1,
},
tiles = {
"elevatorparts_generic_bg.png",
@@ -1125,6 +1193,15 @@ minetest.register_node("elevatorparts:pilantern_updown_downon",{
elseif msg == "arrow_off" then
meta:set_int("uparrow",0)
meta:set_int("downarrow",0)
+ elseif msg == "flash_is" then
+ meta:set_int("flash_is",1)
+ meta:set_int("flash_fs",0)
+ elseif msg == "flash_fs" then
+ meta:set_int("flash_is",0)
+ meta:set_int("flash_fs",1)
+ elseif msg == "flash_off" then
+ meta:set_int("flash_is",0)
+ meta:set_int("flash_fs",0)
elseif not pi_ignore[msg] then
meta:set_string("text",string.sub(" "..msg,-3,-1))
end
@@ -1139,7 +1216,7 @@ minetest.register_node("elevatorparts:pilantern_updown_bothon",{
groups = {
dig_immediate = 2,
not_in_creative_inventory = 1,
- elevatorparts_pi_lbm = 1,
+ elevatorparts_pi_abm = 1,
},
tiles = {
"elevatorparts_generic_bg.png",
@@ -1199,6 +1276,15 @@ minetest.register_node("elevatorparts:pilantern_updown_bothon",{
elseif msg == "arrow_off" then
meta:set_int("uparrow",0)
meta:set_int("downarrow",0)
+ elseif msg == "flash_is" then
+ meta:set_int("flash_is",1)
+ meta:set_int("flash_fs",0)
+ elseif msg == "flash_fs" then
+ meta:set_int("flash_is",0)
+ meta:set_int("flash_fs",1)
+ elseif msg == "flash_off" then
+ meta:set_int("flash_is",0)
+ meta:set_int("flash_fs",0)
elseif not pi_ignore[msg] then
meta:set_string("text",string.sub(" "..msg,-3,-1))
end
@@ -1208,12 +1294,17 @@ minetest.register_node("elevatorparts:pilantern_updown_bothon",{
},
})
-minetest.register_lbm({
- name = "elevatorparts:pi_respawn",
- label = "Respawn PI display entities",
- nodenames = {"group:elevatorparts_pi_lbm"},
- run_at_every_load = true,
- action = updateDisplay,
+minetest.register_abm({
+ label = "Respawn / Flash PI displays",
+ nodenames = {"group:elevatorparts_pi_abm"},
+ interval = 1,
+ chance = 1,
+ action = function(pos)
+ local meta = minetest.get_meta(pos)
+ local flashtimer = meta:get_int("flashtimer") > 0
+ meta:set_int("flashtimer",flashtimer and 0 or 1)
+ updateDisplay(pos)
+ end,
})
minetest.register_craft({