diff options
Diffstat (limited to 'fs1switch.lua')
| -rw-r--r-- | fs1switch.lua | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/fs1switch.lua b/fs1switch.lua index 5949250..a5cb2f4 100644 --- a/fs1switch.lua +++ b/fs1switch.lua @@ -12,42 +12,42 @@ local nodebox = { } local function resetspring(pos) - local node = minetest.get_node(pos) + local node = core.get_node(pos) local offstates = { ["celevator:fs1switch_reset"] = "celevator:fs1switch_off", ["celevator:fs1switch_reset_lit"] = "celevator:fs1switch_off_lit", } if offstates[node.name] then node.name = offstates[node.name] - minetest.swap_node(pos,node) + core.swap_node(pos,node) end end local function rightclick(pos,node,player) if not (player and player:is_player()) then return end - local meta = minetest.get_meta(pos) + local meta = core.get_meta(pos) if meta:get_string("formspec") ~= "" then return end local name = player:get_player_name() - if minetest.is_protected(pos,name) and not minetest.check_player_privs(name,{protection_bypass=true}) then - minetest.chat_send_player(name,"You don't have a key for this switch.") - minetest.record_protection_violation(pos,name) + if core.is_protected(pos,name) and not core.check_player_privs(name,{protection_bypass=true}) then + core.chat_send_player(name,"You don't have a key for this switch.") + core.record_protection_violation(pos,name) return end if node.name == "celevator:fs1switch_off" then node.name = "celevator:fs1switch_on" - minetest.swap_node(pos,node) + core.swap_node(pos,node) elseif node.name == "celevator:fs1switch_on" then node.name = "celevator:fs1switch_reset" - minetest.swap_node(pos,node) - minetest.after(0.5,resetspring,pos) + core.swap_node(pos,node) + core.after(0.5,resetspring,pos) elseif node.name == "celevator:fs1switch_off_lit" or node.name == "celevator:fs1switch_on_lit" then node.name = "celevator:fs1switch_reset_lit" - minetest.swap_node(pos,node) - minetest.after(0.5,resetspring,pos) + core.swap_node(pos,node) + core.after(0.5,resetspring,pos) end local carid = meta:get_int("carid") if carid == 0 then return end - local carinfo = minetest.deserialize(celevator.storage:get_string(string.format("car%d",carid))) + local carinfo = core.deserialize(celevator.storage:get_string(string.format("car%d",carid))) if not carinfo then return end local controllerpos = carinfo.controllerpos local dispatcher = false @@ -56,7 +56,7 @@ local function rightclick(pos,node,player) dispatcher = true end if not controllerpos then return end - local controllermeta = minetest.get_meta(controllerpos) + local controllermeta = core.get_meta(controllerpos) if controllermeta:get_int("carid") ~= carid then return end if node.name == "celevator:fs1switch_reset" or node.name == "celevator:fs1switch_reset_lit" then if dispatcher then @@ -87,23 +87,23 @@ function celevator.fs1switch.setled(pos,on) local node = celevator.get_node(pos) if on and onstates[node.name] then node.name = onstates[node.name] - minetest.swap_node(pos,node) + core.swap_node(pos,node) elseif (not on) and offstates[node.name] then node.name = offstates[node.name] - minetest.swap_node(pos,node) + core.swap_node(pos,node) end end local function unpair(pos) - local meta = minetest.get_meta(pos) + local meta = core.get_meta(pos) local carid = meta:get_int("carid") if carid == 0 then return end - local carinfo = minetest.deserialize(celevator.storage:get_string(string.format("car%d",carid))) + local carinfo = core.deserialize(celevator.storage:get_string(string.format("car%d",carid))) if not (carinfo and carinfo.fs1switches) then return end for i,fs1switch in pairs(carinfo.fs1switches) do if vector.equals(pos,fs1switch.pos) then table.remove(carinfo.fs1switches,i) - celevator.storage:set_string(string.format("car%d",carid),minetest.serialize(carinfo)) + celevator.storage:set_string(string.format("car%d",carid),core.serialize(carinfo)) end end end @@ -111,7 +111,7 @@ end local switchstates = {"off","on","reset"} for _,switchpos in ipairs(switchstates) do - minetest.register_node("celevator:fs1switch_"..switchpos,{ + core.register_node("celevator:fs1switch_"..switchpos,{ description = "Elevator Fire Service Phase 1 Keyswitch"..(switchpos == "off" and "" or string.format(" (%s state - you hacker you!)",switchpos)), groups = { dig_immediate = 2, @@ -136,35 +136,35 @@ for _,switchpos in ipairs(switchstates) do fixed = nodebox, }, after_place_node = function(pos) - local meta = minetest.get_meta(pos) + local meta = core.get_meta(pos) meta:set_string("formspec","formspec_version[7]size[8,5]field[0.5,0.5;7,1;carid;Car ID;]button[3,3.5;2,1;save;Save]") end, on_receive_fields = function(pos,_,fields,player) local carid = tonumber(fields.carid or 0) if not (carid and carid >= 1 and carid == math.floor(carid)) then return end - local carinfo = minetest.deserialize(celevator.storage:get_string(string.format("car%d",carid))) + local carinfo = core.deserialize(celevator.storage:get_string(string.format("car%d",carid))) if not carinfo then return end local controllerpos = carinfo.controllerpos or carinfo.dispatcherpos if not controllerpos then return end local name = player:get_player_name() - if minetest.is_protected(controllerpos,name) and not minetest.check_player_privs(name,{protection_bypass=true}) then + if core.is_protected(controllerpos,name) and not core.check_player_privs(name,{protection_bypass=true}) then if player:is_player() then - minetest.chat_send_player(name,"Can't connect to a controller/dispatcher you don't have access to.") - minetest.record_protection_violation(controllerpos,name) + core.chat_send_player(name,"Can't connect to a controller/dispatcher you don't have access to.") + core.record_protection_violation(controllerpos,name) end return end if not carinfo.fs1switches then carinfo.fs1switches = {} end table.insert(carinfo.fs1switches,{pos=pos}) - celevator.storage:set_string(string.format("car%d",carid),minetest.serialize(carinfo)) - local meta = minetest.get_meta(pos) + celevator.storage:set_string(string.format("car%d",carid),core.serialize(carinfo)) + local meta = core.get_meta(pos) meta:set_int("carid",carid) meta:set_string("formspec","") end, on_rightclick = rightclick, on_destruct = unpair, }) - minetest.register_node("celevator:fs1switch_"..switchpos.."_lit",{ + core.register_node("celevator:fs1switch_"..switchpos.."_lit",{ description = "Elevator Fire Service Phase 1 Keyswitch"..string.format(" (%s state, lit - you hacker you!)",switchpos), groups = { dig_immediate = 2, |
