diff options
Diffstat (limited to 'digilines.lua')
| -rw-r--r-- | digilines.lua | 70 |
1 files changed, 36 insertions, 34 deletions
diff --git a/digilines.lua b/digilines.lua index 8f5c220..60fa469 100644 --- a/digilines.lua +++ b/digilines.lua @@ -1,15 +1,17 @@ +local S = core.get_translator("celevator") + local function handledigilines(pos,node,channel,msg) local multi = node.name == "celevator:digilines_multi_io" if msg == "GET" then msg = {command = "GET"} end if type(msg) ~= "table" or type(msg.command) ~= "string" then return end - local meta = minetest.get_meta(pos) + local meta = core.get_meta(pos) local setchannel = meta:get_string("channel") if setchannel ~= channel then return end if multi and type(msg.carid) ~= "number" then return end local carid = multi and msg.carid or meta:get_int("carid") if carid == 0 then return end local dmode = meta:get_int("dispatcher") == 1 - local carinfo = minetest.deserialize(celevator.storage:get_string(string.format("car%d",carid))) or {} + local carinfo = core.deserialize(celevator.storage:get_string(string.format("car%d",carid))) or {} if multi then dmode = carinfo.dispatcherpos end @@ -18,7 +20,7 @@ local function handledigilines(pos,node,channel,msg) if not carinfo.dispatcherpos then return end if not celevator.dispatcher.isdispatcher(carinfo.dispatcherpos) then return end if msg.command == "get" then - local mem = minetest.deserialize(minetest.get_meta(carinfo.dispatcherpos):get_string("mem")) + local mem = core.deserialize(core.get_meta(carinfo.dispatcherpos):get_string("mem")) if not mem then return end local ret = { upcalls = {}, @@ -67,7 +69,7 @@ local function handledigilines(pos,node,channel,msg) if not carinfo.controllerpos then return end if not celevator.controller.iscontroller(carinfo.controllerpos) then return end if msg.command == "get" then - local mem = minetest.deserialize(minetest.get_meta(carinfo.controllerpos):get_string("mem")) + local mem = core.deserialize(core.get_meta(carinfo.controllerpos):get_string("mem")) if not mem then return end local ret = { carstate = mem.carstate, @@ -174,8 +176,8 @@ local function handledigilines(pos,node,channel,msg) end end -minetest.register_node("celevator:digilines_io",{ - description = "Elevator Digilines Input/Output", +core.register_node("celevator:digilines_io",{ + description = S("Elevator Digilines Input/Output"), tiles = { "celevator_digilinesio_top.png", "celevator_cabinet_sides.png", @@ -199,27 +201,27 @@ minetest.register_node("celevator:digilines_io",{ }, }, after_place_node = function(pos) - local meta = minetest.get_meta(pos) + local meta = core.get_meta(pos) local fs = "formspec_version[7]size[8,4.5]" - fs = fs.."field[0.5,0.5;3,1;channel;Channel;${channel}]" - fs = fs.."field[4.5,0.5;3,1;carid;Car ID;${carid}]" - fs = fs.."button_exit[2.5,2;3,1;save;Save]" + fs = fs.."field[0.5,0.5;3,1;channel;"..S("Channel")..";${channel}]" + fs = fs.."field[4.5,0.5;3,1;carid;"..S("Car ID")..";${carid}]" + fs = fs.."button_exit[2.5,2;3,1;save;"..S("Save").."]" meta:set_string("formspec",fs) end, on_receive_fields = function(pos,_,fields,player) - local meta = minetest.get_meta(pos) + local meta = core.get_meta(pos) if not fields.save 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 + if core.is_protected(pos,name) and not core.check_player_privs(name,{protection_bypass=true}) then if player:is_player() then - minetest.record_protection_violation(pos,name) + core.record_protection_violation(pos,name) end return end if not tonumber(fields.carid) then return end meta:set_int("carid",fields.carid) local carid = tonumber(fields.carid) - local carinfo = minetest.deserialize(celevator.storage:get_string(string.format("car%d",carid))) or {} + local carinfo = core.deserialize(celevator.storage:get_string(string.format("car%d",carid))) or {} if not (carinfo.controllerpos or carinfo.dispatcherpos) then return end local dmode = false if carinfo.dispatcherpos then @@ -229,31 +231,31 @@ minetest.register_node("celevator:digilines_io",{ if not celevator.controller.iscontroller(carinfo.controllerpos) then return end end if dmode then - if minetest.is_protected(carinfo.dispatcherpos,name) and not minetest.check_player_privs(name,{protection_bypass=true}) then + if core.is_protected(carinfo.dispatcherpos,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 dispatcher you don't have access to.") - minetest.record_protection_violation(carinfo.dispatcherpos,name) + core.chat_send_player(name,S("Can't connect to a dispatcher you don't have access to.")) + core.record_protection_violation(carinfo.dispatcherpos,name) end return end else - if minetest.is_protected(carinfo.controllerpos,name) and not minetest.check_player_privs(name,{protection_bypass=true}) then + if core.is_protected(carinfo.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 you don't have access to.") - minetest.record_protection_violation(carinfo.controllerpos,name) + core.chat_send_player(name,S("Can't connect to a controller you don't have access to.")) + core.record_protection_violation(carinfo.controllerpos,name) end return end end meta:set_int("dispatcher",dmode and 1 or 0) meta:set_string("channel",fields.channel) - local infotext = "Car: "..carid + local infotext = S("ID: @1",carid) meta:set_string("infotext",infotext) end, }) -minetest.register_node("celevator:digilines_multi_io",{ - description = "Elevator Digilines Multi-Car Input/Output", +core.register_node("celevator:digilines_multi_io",{ + description = S("Elevator Digilines Multi-Car Input/Output"), tiles = { "celevator_digilinesio_multi_top.png", "celevator_cabinet_sides.png", @@ -279,28 +281,28 @@ minetest.register_node("celevator:digilines_multi_io",{ }, after_place_node = function(pos,player) local name = player:get_player_name() - if not (minetest.check_player_privs(name,{protection_bypass=true}) or minetest.check_player_privs(name,{server=true})) then + if not (core.check_player_privs(name,{protection_bypass=true}) or core.check_player_privs(name,{server=true})) then if player:is_player() then - minetest.chat_send_player(name,"You need either the 'protection_bypass' or 'server' privilege to use this.") - minetest.record_protection_violation(pos,name) + core.chat_send_player(name,S("You need either the 'protection_bypass' or 'server' privilege to use this.")) + core.record_protection_violation(pos,name) end - minetest.remove_node(pos) + core.remove_node(pos) return end - local meta = minetest.get_meta(pos) + local meta = core.get_meta(pos) local fs = "formspec_version[7]size[8,4.5]" - fs = fs.."field[0.5,0.5;7,1;channel;Channel;${channel}]" - fs = fs.."button_exit[2.5,2;3,1;save;Save]" + fs = fs.."field[0.5,0.5;7,1;channel;"..S("Channel")..";${channel}]" + fs = fs.."button_exit[2.5,2;3,1;save;"..S("Save").."]" meta:set_string("formspec",fs) end, on_receive_fields = function(pos,_,fields,player) - local meta = minetest.get_meta(pos) + local meta = core.get_meta(pos) if not fields.save then return end local name = player:get_player_name() - if not (minetest.check_player_privs(name,{protection_bypass=true}) or minetest.check_player_privs(name,{server=true})) then + if not (core.check_player_privs(name,{protection_bypass=true}) or core.check_player_privs(name,{server=true})) then if player:is_player() then - minetest.chat_send_player(name,"You need either the 'protection_bypass' or 'server' privilege to use this.") - minetest.record_protection_violation(pos,name) + core.chat_send_player(name,S("You need either the 'protection_bypass' or 'server' privilege to use this.")) + core.record_protection_violation(pos,name) end return end |
