1st attempt to handle numbers
parent
56d8bf0ca3
commit
0b6c9ab690
44
ball.lua
44
ball.lua
|
@ -501,9 +501,9 @@ minetest.register_node("basic_machines:ball_spawner", {
|
|||
local meta = minetest.get_meta(pos);
|
||||
local x0=0; local y0=0; local z0=0;
|
||||
--minetest.chat_send_all("form at " .. dump(pos) .. " fields " .. dump(fields))
|
||||
if fields.x0 then x0 = tonumber(fields.x0) or 0 end
|
||||
if fields.y0 then y0 = tonumber(fields.y0) or 0 end
|
||||
if fields.z0 then z0 = tonumber(fields.z0) or 0 end
|
||||
if fields.x0 then x0 = basic_machines.tonumber(fields.x0) or 0 end
|
||||
if fields.y0 then y0 = basic_machines.tonumber(fields.y0) or 0 end
|
||||
if fields.z0 then z0 = basic_machines.tonumber(fields.z0) or 0 end
|
||||
if not privs.privs and (math.abs(x0)>10 or math.abs(y0)>10 or math.abs(z0) > 10) then return end
|
||||
|
||||
meta:set_int("x0",x0);meta:set_int("y0",y0);meta:set_int("z0",z0);
|
||||
|
@ -517,44 +517,44 @@ minetest.register_node("basic_machines:ball_spawner", {
|
|||
|
||||
|
||||
if fields.speed then
|
||||
local speed = tonumber(fields.speed) or 0;
|
||||
local speed = basic_machines.tonumber(fields.speed) or 0;
|
||||
if (speed > 10 or speed < 0) and not privs.privs then return end
|
||||
meta:set_float("speed", speed)
|
||||
end
|
||||
|
||||
if fields.energy then
|
||||
local energy = tonumber(fields.energy) or 1;
|
||||
local energy = basic_machines.tonumber(fields.energy) or 1;
|
||||
meta:set_float("energy", energy)
|
||||
end
|
||||
|
||||
if fields.bounce then
|
||||
local bounce = tonumber(fields.bounce) or 1;
|
||||
local bounce = basic_machines.tonumber(fields.bounce) or 1;
|
||||
meta:set_int("bounce",bounce)
|
||||
end
|
||||
|
||||
if fields.gravity then
|
||||
local gravity = tonumber(fields.gravity) or 1;
|
||||
local gravity = basic_machines.tonumber(fields.gravity) or 1;
|
||||
if (gravity<0 or gravity>30) and not privs.privs then return end
|
||||
meta:set_float("gravity", gravity)
|
||||
end
|
||||
if fields.puncheable then
|
||||
meta:set_int("puncheable", tonumber(fields.puncheable) or 0)
|
||||
meta:set_int("puncheable", basic_machines.tonumber(fields.puncheable) or 0)
|
||||
end
|
||||
|
||||
if fields.solid then
|
||||
meta:set_int("solid", tonumber(fields.solid) or 0)
|
||||
meta:set_int("solid", basic_machines.tonumber(fields.solid) or 0)
|
||||
end
|
||||
|
||||
if fields.lifetime then
|
||||
meta:set_int("lifetime", tonumber(fields.lifetime) or 0)
|
||||
meta:set_int("lifetime", basic_machines.tonumber(fields.lifetime) or 0)
|
||||
end
|
||||
|
||||
if fields.hurt then
|
||||
meta:set_float("hurt", tonumber(fields.hurt) or 0)
|
||||
meta:set_float("hurt", basic_machines.tonumber(fields.hurt) or 0)
|
||||
end
|
||||
|
||||
if fields.hp then
|
||||
meta:set_float("hp", math.abs(tonumber(fields.hp) or 0))
|
||||
meta:set_float("hp", math.abs(basic_machines.tonumber(fields.hp) or 0))
|
||||
end
|
||||
|
||||
if fields.texture then
|
||||
|
@ -562,7 +562,7 @@ minetest.register_node("basic_machines:ball_spawner", {
|
|||
end
|
||||
|
||||
if fields.scale then
|
||||
local scale = math.abs(tonumber(fields.scale) or 100);
|
||||
local scale = math.abs(basic_machines.tonumber(fields.scale) or 100);
|
||||
if scale>1000 and not privs.privs then scale = 1000 end
|
||||
meta:set_int("scale", scale)
|
||||
end
|
||||
|
@ -621,11 +621,11 @@ minetest.register_tool("basic_machines:ball_spell", {
|
|||
|
||||
|
||||
local speed,energy,bounce,gravity,puncheable;
|
||||
speed = tonumber(meta["speed"]) or 0;
|
||||
energy = tonumber(meta["energy"]) or 0; -- if positive activates, negative deactivates, 0 does nothing
|
||||
bounce = tonumber(meta["bounce"]) or 0; -- if nonzero bounces when hit obstacle, 0 gets absorbed
|
||||
gravity = tonumber(meta["gravity"]) or 0; -- gravity
|
||||
puncheable = tonumber(meta["puncheable"]) or 0; -- if 1 can be punched by players in protection, if 2 can be punched by anyone
|
||||
speed = basic_machines.tonumber(meta["speed"]) or 0;
|
||||
energy = basic_machines.tonumber(meta["energy"]) or 0; -- if positive activates, negative deactivates, 0 does nothing
|
||||
bounce = basic_machines.tonumber(meta["bounce"]) or 0; -- if nonzero bounces when hit obstacle, 0 gets absorbed
|
||||
gravity = basic_machines.tonumber(meta["gravity"]) or 0; -- gravity
|
||||
puncheable = basic_machines.tonumber(meta["puncheable"]) or 0; -- if 1 can be punched by players in protection, if 2 can be punched by anyone
|
||||
|
||||
if energy<0 then
|
||||
obj:set_properties({textures={"basic_machines_ball_bullet.png^[colorize:blue:120"}})
|
||||
|
@ -638,9 +638,9 @@ minetest.register_tool("basic_machines:ball_spell", {
|
|||
end
|
||||
luaent.puncheable = puncheable;
|
||||
luaent.owner = meta["owner"];
|
||||
luaent.hurt = math.min(tonumber(meta["hurt"]),basic_machines.ball.maxdamage);
|
||||
luaent.hurt = math.min(basic_machines.tonumber(meta["hurt"]),basic_machines.ball.maxdamage);
|
||||
|
||||
obj:set_hp( tonumber(meta["hp"]) );
|
||||
obj:set_hp( basic_machines.tonumber(meta["hp"]) );
|
||||
|
||||
local x0,y0,z0;
|
||||
if speed>0 then luaent.speed = speed end
|
||||
|
@ -652,8 +652,8 @@ minetest.register_tool("basic_machines:ball_spell", {
|
|||
obj:setvelocity(v);
|
||||
|
||||
|
||||
if tonumber(meta["admin"])==1 then
|
||||
luaent.lifetime = tonumber(meta["lifetime"]);
|
||||
if basic_machines.tonumber(meta["admin"])==1 then
|
||||
luaent.lifetime = basic_machines.tonumber(meta["lifetime"]);
|
||||
end
|
||||
|
||||
|
||||
|
|
|
@ -208,7 +208,7 @@ minetest.register_node("basic_machines:constructor", {
|
|||
|
||||
if fields.craft then
|
||||
if string.sub(fields.craft,1,3)=="CHG" then
|
||||
local sel = tonumber(string.sub(fields.craft,5)) or 1
|
||||
local sel = basic_machines.tonumber(string.sub(fields.craft,5)) or 1
|
||||
meta:set_int("selected",sel);
|
||||
|
||||
local i = 0;
|
||||
|
|
30
init.lua
30
init.lua
|
@ -15,10 +15,37 @@
|
|||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
basic_machines = {};
|
||||
|
||||
basic_machines.tonumber = function(number)
|
||||
local nr = tonumber(number)
|
||||
|
||||
-- nil check
|
||||
if not nr then
|
||||
nr = 0
|
||||
end
|
||||
|
||||
-- NaN check
|
||||
if nr ~= nr then
|
||||
nr = 0
|
||||
end
|
||||
|
||||
-- infinite number check
|
||||
if not (nr > -math.huge and nr < math.huge) then
|
||||
nr = 0
|
||||
end
|
||||
|
||||
-- prevent voxel manip crash for large numbers
|
||||
if nr > 99 then
|
||||
nr = 99
|
||||
end
|
||||
|
||||
if nr < -99 then
|
||||
nr = -99
|
||||
end
|
||||
|
||||
return nr
|
||||
end
|
||||
|
||||
dofile(minetest.get_modpath("basic_machines").."/mark.lua") -- used for markings, borrowed and adapted from worldedit mod
|
||||
dofile(minetest.get_modpath("basic_machines").."/mover.lua") -- mover, detector, keypad, distributor
|
||||
|
@ -55,7 +82,6 @@ minetest.register_craftitem("basic_machines:charcoal", {
|
|||
inventory_image = "charcoal.png",
|
||||
})
|
||||
|
||||
|
||||
minetest.register_craft({
|
||||
type = 'cooking',
|
||||
recipe = "default:tree",
|
||||
|
|
8
mark.lua
8
mark.lua
|
@ -1,15 +1,15 @@
|
|||
-- rnd: code borrowed from machines, mark.lua
|
||||
|
||||
-- need for marking
|
||||
machines = {};
|
||||
|
||||
machines.pos1 = {};machines.pos11 = {}; machines.pos2 = {};
|
||||
machines = {}
|
||||
machines.pos1 = {}
|
||||
machines.pos11 = {}
|
||||
machines.pos2 = {}
|
||||
machines.marker1 = {}
|
||||
machines.marker11 = {}
|
||||
machines.marker2 = {}
|
||||
machines.marker_region = {}
|
||||
|
||||
|
||||
--marks machines region position 1
|
||||
machines.mark_pos1 = function(name)
|
||||
local pos1, pos2 = machines.pos1[name], machines.pos2[name]
|
||||
|
|
138
mover.lua
138
mover.lua
|
@ -3,8 +3,6 @@
|
|||
-- mod with basic simple automatization for minetest. No background processing, just one abm with 5s timer (clock generator), no other lag causing background processing.
|
||||
------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
-- *** SETTINGS *** --
|
||||
basic_machines.timer = 5 -- main timestep
|
||||
basic_machines.machines_minstep = 1 -- minimal allowed activation timestep, if faster machines overheat
|
||||
|
@ -152,44 +150,70 @@ basic_machines.signs = {
|
|||
|
||||
-- *** END OF SETTINGS *** --
|
||||
|
||||
|
||||
local machines_timer = basic_machines.timer
|
||||
local machines_minstep = basic_machines.machines_minstep
|
||||
local max_range = basic_machines.max_range
|
||||
local machines_operations = basic_machines.machines_operations
|
||||
local machines_TTL = basic_machines.machines_TTL
|
||||
|
||||
|
||||
local punchset = {};
|
||||
local punchset = {}
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
local name = player:get_player_name(); if name == nil then return end
|
||||
punchset[name] = {};
|
||||
punchset[name].state = 0;
|
||||
local name = player:get_player_name()
|
||||
|
||||
if name == nil then
|
||||
return
|
||||
end
|
||||
|
||||
punchset[name] = {}
|
||||
punchset[name].state = 0
|
||||
end)
|
||||
|
||||
local get_mover_form = function(pos,player)
|
||||
if not player then
|
||||
return
|
||||
end
|
||||
|
||||
if not player then return end
|
||||
local meta = minetest.get_meta(pos);
|
||||
local x0,y0,z0,x1,y1,z1,x2,y2,z2,prefer,mode,mreverse;
|
||||
local x0, y0, z0, x1, y1, z1, x2, y2, z2, prefer, mode, mreverse
|
||||
|
||||
x0=meta:get_int("x0");y0=meta:get_int("y0");z0=meta:get_int("z0");x1=meta:get_int("x1");y1=meta:get_int("y1");z1=meta:get_int("z1");x2=meta:get_int("x2");y2=meta:get_int("y2");z2=meta:get_int("z2");
|
||||
-- pos1
|
||||
x0 = meta:get_int("x0")
|
||||
y0 = meta:get_int("y0")
|
||||
z0 = meta:get_int("z0")
|
||||
|
||||
machines.pos1[player:get_player_name()] = {x=pos.x+x0,y=pos.y+y0,z=pos.z+z0};machines.mark_pos1(player:get_player_name()) -- mark pos1
|
||||
machines.pos11[player:get_player_name()] = {x=pos.x+x1,y=pos.y+y1,z=pos.z+z1};machines.mark_pos11(player:get_player_name()) -- mark pos11
|
||||
machines.pos2[player:get_player_name()] = {x=pos.x+x2,y=pos.y+y2,z=pos.z+z2};machines.mark_pos2(player:get_player_name()) -- mark pos2
|
||||
-- pos11
|
||||
x1 = meta:get_int("x1")
|
||||
y1 = meta:get_int("y1")
|
||||
z1 = meta:get_int("z1")
|
||||
|
||||
prefer = meta:get_string("prefer");
|
||||
local mreverse = meta:get_int("reverse");
|
||||
local list_name = "nodemeta:"..pos.x..','..pos.y..','..pos.z
|
||||
local mode_list = {["normal"]=1,["dig"]=2, ["drop"]=3, ["object"]=4, ["inventory"]=5, ["transport"]=6};
|
||||
-- pos2
|
||||
x2 = meta:get_int("x2")
|
||||
y2 = meta:get_int("y2")
|
||||
z2 = meta:get_int("z2")
|
||||
|
||||
local mode_string = meta:get_string("mode") or "";
|
||||
machines.pos1[player:get_player_name()] = {x = pos.x + x0, y = pos.y + y0, z = pos.z + z0}
|
||||
machines.mark_pos1(player:get_player_name()) -- mark pos1
|
||||
machines.pos11[player:get_player_name()] = {x = pos.x + x1, y = pos.y + y1, z = pos.z + z1}
|
||||
machines.mark_pos11(player:get_player_name()) -- mark pos11
|
||||
machines.pos2[player:get_player_name()] = {x = pos.x + x2, y = pos.y + y2, z = pos.z + z2}
|
||||
machines.mark_pos2(player:get_player_name()) -- mark pos2
|
||||
|
||||
local meta1 = minetest.get_meta({x=pos.x+x0,y=pos.y+y0,z=pos.z+z0}); -- source meta
|
||||
local meta2 = minetest.get_meta({x=pos.x+x2,y=pos.y+y2,z=pos.z+z2}); -- target meta
|
||||
prefer = meta:get_string("prefer")
|
||||
local mreverse = meta:get_int("reverse")
|
||||
local list_name = "nodemeta:"..pos.x..","..pos.y..","..pos.z
|
||||
local mode_list = {
|
||||
["normal"] = 1,
|
||||
["dig"] = 2,
|
||||
["drop"] = 3,
|
||||
["object"] = 4,
|
||||
["inventory"] = 5,
|
||||
["transport"] = 6
|
||||
}
|
||||
|
||||
local mode_string = meta:get_string("mode") or ""
|
||||
|
||||
local meta1 = minetest.get_meta({x = pos.x + x0, y = pos.y + y0, z = pos.z + z0}) -- source meta
|
||||
local meta2 = minetest.get_meta({x = pos.x + x2, y = pos.y + y2, z = pos.z + z2}) -- target meta
|
||||
|
||||
local inv1=1; local inv2=1;
|
||||
local inv1m = meta:get_string("inv1");local inv2m = meta:get_string("inv2");
|
||||
|
@ -204,10 +228,13 @@ local get_mover_form = function(pos,player)
|
|||
end
|
||||
local list2 = meta2:get_inventory():get_lists(); local inv_list2 = "";
|
||||
j=1;
|
||||
|
||||
if list2 then
|
||||
for i in pairs( list2) do
|
||||
inv_list2 = inv_list2 .. i .. ",";
|
||||
if i == inv2m then inv2=j; end; j=j+1;
|
||||
end
|
||||
end
|
||||
|
||||
local upgrade = meta:get_float("upgrade"); if upgrade>0 then upgrade = upgrade - 1 end
|
||||
local seltab = meta:get_int("seltab");
|
||||
|
@ -567,7 +594,7 @@ minetest.register_node("basic_machines:mover", {
|
|||
return
|
||||
end
|
||||
|
||||
local times = tonumber(prefer) or 0; if times > 20 then times = 20 elseif times<0.2 then times = 0 end
|
||||
local times = basic_machines.tonumber(prefer) or 0; if times > 20 then times = 20 elseif times<0.2 then times = 0 end
|
||||
local velocityv;
|
||||
if times~=0 then
|
||||
velocityv = { x = pos2.x-x0-pos.x, y = pos2.y-y0-pos.y, z = pos2.z-z0-pos.z};
|
||||
|
@ -1087,7 +1114,7 @@ local function use_keypad(pos,ttl, again) -- position, time to live ( how many t
|
|||
elseif string.byte(text) == 37 then -- target keypad's text starts with % ( ascii code 37) -> word extraction
|
||||
|
||||
local ttext = minetest.get_meta({x=pos.x,y=pos.y+1,z=pos.z}):get_string("infotext")
|
||||
local i = tonumber(string.sub(text,2,2)) or 1; --read the number following the %
|
||||
local i = basic_machines.tonumber(string.sub(text,2,2)) or 1; --read the number following the %
|
||||
--extract i-th word from text
|
||||
local j = 0;
|
||||
for word in string.gmatch(ttext, "%S+") do
|
||||
|
@ -1147,8 +1174,8 @@ local function use_keypad(pos,ttl, again) -- position, time to live ( how many t
|
|||
if node.name == "basic_machines:distributor" then
|
||||
local i = string.find(text," ");
|
||||
if i then
|
||||
local ti = tonumber(string.sub(text,1,i-1)) or 1;
|
||||
local tm = tonumber(string.sub(text,i+1)) or 1;
|
||||
local ti = basic_machines.tonumber(string.sub(text,1,i-1)) or 1;
|
||||
local tm = basic_machines.tonumber(string.sub(text,i+1)) or 1;
|
||||
if ti>=1 and ti<=16 and tm>=-2 and tm<=2 then
|
||||
tmeta:set_int("active"..ti,tm)
|
||||
end
|
||||
|
@ -1487,7 +1514,7 @@ minetest.register_node("basic_machines:detector", {
|
|||
if detected_obj == node or node =="" then trigger = true end
|
||||
elseif mode == "light" then
|
||||
detected_obj=minetest.get_node_light({x=x0,y=y0,z=z0}) or 0;
|
||||
if detected_obj>=(tonumber(node) or 0) or node == "" then trigger = true end
|
||||
if detected_obj>=(basic_machines.tonumber(node) or 0) or node == "" then trigger = true end
|
||||
else -- players/objects
|
||||
local objects = minetest.get_objects_inside_radius({x=x0,y=y0,z=z0}, r)
|
||||
local player_near=false;
|
||||
|
@ -1881,7 +1908,7 @@ minetest.register_node("basic_machines:light_on", {
|
|||
|
||||
if fields.deactivate then
|
||||
local meta = minetest.get_meta(pos);
|
||||
local deactivate = tonumber(fields.deactivate) or 0;
|
||||
local deactivate = basic_machines.tonumber(fields.deactivate) or 0;
|
||||
if deactivate <0 or deactivate > 600 then deactivate = 0 end
|
||||
meta:set_int("deactivate",deactivate);
|
||||
local form = "size[2,2] field[0.25,0.5;2,1;deactivate;deactivate after ;"..deactivate.."]".."button_exit[0.,1;1,1;OK;OK]";
|
||||
|
@ -1896,7 +1923,7 @@ minetest.register_node("basic_machines:light_on", {
|
|||
end,
|
||||
action_on = function (pos, node,ttl)
|
||||
local meta = minetest.get_meta(pos);
|
||||
local count = tonumber(meta:get_string("infotext")) or 0;
|
||||
local count = basic_machines.tonumber(meta:get_string("infotext")) or 0;
|
||||
meta:set_string("infotext",count+1); -- increase activate count
|
||||
end
|
||||
}
|
||||
|
@ -2246,7 +2273,7 @@ minetest.register_on_player_receive_fields(function(player,formname,fields)
|
|||
end
|
||||
|
||||
if fields.tabs then
|
||||
meta:set_int("seltab", tonumber(fields.tabs) or 1)
|
||||
meta:set_int("seltab", basic_machines.tonumber(fields.tabs) or 1)
|
||||
local form = get_mover_form(pos,player)
|
||||
minetest.show_formspec(player:get_player_name(), "basic_machines:mover_"..minetest.pos_to_string(pos), form)
|
||||
return
|
||||
|
@ -2257,19 +2284,30 @@ minetest.register_on_player_receive_fields(function(player,formname,fields)
|
|||
local seltab = meta:get_int("seltab");
|
||||
|
||||
if seltab == 2 then -- POSITIONS
|
||||
|
||||
-- positions
|
||||
local x0,y0,z0,x1,y1,z1,x2,y2,z2;
|
||||
x0=tonumber(fields.x0) or 0;y0=tonumber(fields.y0) or -1;z0 = tonumber(fields.z0) or 0
|
||||
x1=tonumber(fields.x1) or 0;y1=tonumber(fields.y1) or -1;z1 = tonumber(fields.z1) or 0
|
||||
x2=tonumber(fields.x2) or 0;y2=tonumber(fields.y2) or 1;z2 = tonumber(fields.z2) or 0;
|
||||
local x0, y0, z0, x1, y1, z1, x2, y2, z2
|
||||
x0 = basic_machines.tonumber(fields.x0) or 0
|
||||
y0 = basic_machines.tonumber(fields.y0) or -1
|
||||
z0 = basic_machines.tonumber(fields.z0) or 0
|
||||
x1 = basic_machines.tonumber(fields.x1) or 0
|
||||
y1 = basic_machines.tonumber(fields.y1) or -1
|
||||
z1 = basic_machines.tonumber(fields.z1) or 0
|
||||
x2 = basic_machines.tonumber(fields.x2) or 0
|
||||
y2 = basic_machines.tonumber(fields.y2) or 1
|
||||
z2 = basic_machines.tonumber(fields.z2) or 0
|
||||
|
||||
-- did the numbers change from last time?
|
||||
if meta:get_int("x0")~=x0 or meta:get_int("y0")~=y0 or meta:get_int("z0")~=z0 or
|
||||
meta:get_int("x1")~=x1 or meta:get_int("y1")~=y1 or meta:get_int("z1")~=z1 or
|
||||
meta:get_int("x2")~=x2 or meta:get_int("y2")~=y2 or meta:get_int("z2")~=z2 then
|
||||
if meta:get_int("x0") ~= x0 or meta:get_int("y0") ~= y0 or
|
||||
meta:get_int("z0") ~= z0 or
|
||||
meta:get_int("x1") ~= x1 or
|
||||
meta:get_int("y1") ~= y1 or
|
||||
meta:get_int("z1") ~= z1 or
|
||||
meta:get_int("x2") ~= x2 or
|
||||
meta:get_int("y2") ~= y2 or
|
||||
meta:get_int("z2") ~= z2 then
|
||||
-- are new numbers inside bounds?
|
||||
if not privs.privs and (math.abs(x1)>max_range or math.abs(y1)>max_range or math.abs(z1)>max_range or math.abs(x2)>max_range or math.abs(y2)>max_range or math.abs(z2)>max_range) then
|
||||
if not privs.privs and
|
||||
(math.abs(x1) > max_range or math.abs(y1) > max_range or math.abs(z1) > max_range or math.abs(x2) > max_range or math.abs(y2) > max_range or math.abs(z2) > max_range) then
|
||||
minetest.chat_send_player(name,"#mover: all coordinates must be between ".. -max_range .. " and " .. max_range .. ". For increased range set up positions by punching"); return
|
||||
end
|
||||
end
|
||||
|
@ -2401,7 +2439,7 @@ minetest.register_on_player_receive_fields(function(player,formname,fields)
|
|||
|
||||
if fields.OK == "OK" then
|
||||
local x0,y0,z0,pass,mode;
|
||||
x0=tonumber(fields.x0) or 0;y0=tonumber(fields.y0) or 1;z0=tonumber(fields.z0) or 0
|
||||
x0=basic_machines.tonumber(fields.x0) or 0;y0=basic_machines.tonumber(fields.y0) or 1;z0=basic_machines.tonumber(fields.z0) or 0
|
||||
pass = fields.pass or ""; mode = fields.mode or 1;
|
||||
|
||||
if minetest.is_protected({x=pos.x+x0,y=pos.y+y0,z=pos.z+z0},name) then
|
||||
|
@ -2426,7 +2464,7 @@ minetest.register_on_player_receive_fields(function(player,formname,fields)
|
|||
if string.find(fields.text, "!") then minetest.log("action", string.format("%s set up keypad for message display at %s", name, minetest.pos_to_string(pos))) end
|
||||
end
|
||||
|
||||
meta:set_int("iter",math.min(tonumber(fields.iter) or 1,500));meta:set_int("mode",tonumber(mode) or 2);
|
||||
meta:set_int("iter",math.min(basic_machines.tonumber(fields.iter) or 1,500));meta:set_int("mode",basic_machines.tonumber(mode) or 2);
|
||||
meta:set_string("infotext", "Punch keypad to use it.");
|
||||
if pass~="" then
|
||||
if fields.text~="@" then
|
||||
|
@ -2507,11 +2545,11 @@ minetest.register_on_player_receive_fields(function(player,formname,fields)
|
|||
|
||||
|
||||
local x0,y0,z0,x1,y1,z1,x2,y2,z2,r,node,NOT;
|
||||
x0=tonumber(fields.x0) or 0;y0=tonumber(fields.y0) or 0;z0=tonumber(fields.z0) or 0
|
||||
x1=tonumber(fields.x1) or 0;y1=tonumber(fields.y1) or 0;z1=tonumber(fields.z1) or 0
|
||||
x2=tonumber(fields.x2) or 0;y2=tonumber(fields.y2) or 0;z2=tonumber(fields.z2) or 0
|
||||
r=tonumber(fields.r) or 1;
|
||||
NOT = tonumber(fields.NOT)
|
||||
x0=basic_machines.tonumber(fields.x0) or 0;y0=basic_machines.tonumber(fields.y0) or 0;z0=basic_machines.tonumber(fields.z0) or 0
|
||||
x1=basic_machines.tonumber(fields.x1) or 0;y1=basic_machines.tonumber(fields.y1) or 0;z1=basic_machines.tonumber(fields.z1) or 0
|
||||
x2=basic_machines.tonumber(fields.x2) or 0;y2=basic_machines.tonumber(fields.y2) or 0;z2=basic_machines.tonumber(fields.z2) or 0
|
||||
r=basic_machines.tonumber(fields.r) or 1;
|
||||
NOT = basic_machines.tonumber(fields.NOT)
|
||||
|
||||
|
||||
if minetest.is_protected({x=pos.x+x0,y=pos.y+y0,z=pos.z+z0},name) then
|
||||
|
@ -2568,8 +2606,8 @@ minetest.register_on_player_receive_fields(function(player,formname,fields)
|
|||
local posf = {}; local active = {};
|
||||
local n = meta:get_int("n");
|
||||
for i = 1,n do
|
||||
posf[i]={x=tonumber(fields["x"..i]) or 0,y=tonumber(fields["y"..i]) or 0,z=tonumber(fields["z"..i]) or 0};
|
||||
active[i]=tonumber(fields["active"..i]) or 0;
|
||||
posf[i]={x=basic_machines.tonumber(fields["x"..i]) or 0,y=basic_machines.tonumber(fields["y"..i]) or 0,z=basic_machines.tonumber(fields["z"..i]) or 0};
|
||||
active[i]=basic_machines.tonumber(fields["active"..i]) or 0;
|
||||
|
||||
if (not (privs.privs) and math.abs(posf[i].x)>max_range or math.abs(posf[i].y)>max_range or math.abs(posf[i].z)>max_range) then
|
||||
minetest.chat_send_player(name,"#distributor: all coordinates must be between ".. -max_range .. " and " .. max_range);
|
||||
|
@ -2583,7 +2621,7 @@ minetest.register_on_player_receive_fields(function(player,formname,fields)
|
|||
meta:set_int("active"..i,active[i]);
|
||||
end
|
||||
if fields.delay then
|
||||
meta:set_float("delay", tonumber(fields.delay) or 0);
|
||||
meta:set_float("delay", basic_machines.tonumber(fields.delay) or 0);
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -2601,7 +2639,7 @@ minetest.register_on_player_receive_fields(function(player,formname,fields)
|
|||
for i = 1,n do if fields["SHOW"..i] then j = i end end
|
||||
--show j-th point
|
||||
if j>0 then
|
||||
local posf={x=tonumber(fields["x"..j]) or 0,y=tonumber(fields["y"..j]) or 0,z=tonumber(fields["z"..j]) or 0};
|
||||
local posf={x=basic_machines.tonumber(fields["x"..j]) or 0,y=basic_machines.tonumber(fields["y"..j]) or 0,z=basic_machines.tonumber(fields["z"..j]) or 0};
|
||||
machines.pos1[player:get_player_name()] = {x=posf.x+pos.x,y=posf.y+pos.y,z=posf.z+pos.z};
|
||||
machines.mark_pos1(player:get_player_name())
|
||||
return;
|
||||
|
|
|
@ -77,7 +77,7 @@ local recycler_process = function(pos)
|
|||
if no_recycle_list[src_item] then meta:set_string("node","") return end -- dont allow recycling of forbidden items
|
||||
|
||||
local recipe = minetest.get_all_craft_recipes( src_item );
|
||||
local recipe_id = tonumber(meta:get_int("recipe")) or 1;
|
||||
local recipe_id = basic_machines.tonumber(meta:get_int("recipe")) or 1;
|
||||
|
||||
if not recipe then
|
||||
return
|
||||
|
@ -89,10 +89,10 @@ local recycler_process = function(pos)
|
|||
local output = recipe[recipe_id].output or "";
|
||||
if string.find(output," ") then
|
||||
local par = string.find(output," ");
|
||||
--if (tonumber(string.sub(output, par)) or 0)>1 then itemlist = {} end
|
||||
--if (basic_machines.tonumber(string.sub(output, par)) or 0)>1 then itemlist = {} end
|
||||
|
||||
if par then
|
||||
reqcount = tonumber(string.sub(output, par)) or 1;
|
||||
reqcount = basic_machines.tonumber(string.sub(output, par)) or 1;
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -239,7 +239,7 @@ minetest.register_node("basic_machines:recycler", {
|
|||
local meta = minetest.get_meta(pos);
|
||||
local recipe=1;
|
||||
if fields.recipe then
|
||||
recipe = tonumber(fields.recipe) or 1;
|
||||
recipe = basic_machines.tonumber(fields.recipe) or 1;
|
||||
else return;
|
||||
end
|
||||
meta:set_int("recipe",recipe);
|
||||
|
|
Loading…
Reference in New Issue