upgrade from basic machines repo
parent
bc6b63a907
commit
048ceab624
78
mover.lua
78
mover.lua
|
@ -6,12 +6,14 @@
|
||||||
|
|
||||||
|
|
||||||
-- *** SETTINGS *** --
|
-- *** SETTINGS *** --
|
||||||
local machines_timer = 5 -- main timestep
|
basic_machines.timer = 5 -- main timestep
|
||||||
local machines_minstep = 1 -- minimal allowed activation timestep, if faster machines overheat
|
basic_machines.machines_minstep = 1 -- minimal allowed activation timestep, if faster machines overheat
|
||||||
local max_range = 10; -- machines normal range of operation
|
|
||||||
local machines_operations = 10; -- 1 coal will provide 10 mover basic operations ( moving dirt 1 block distance)
|
basic_machines.max_range = 10 -- machines normal range of operation
|
||||||
local machines_TTL = 16; -- time to live for signals, how many hops before signal dissipates
|
basic_machines.machines_operations = 10 -- 1 coal will provide 10 mover basic operations ( moving dirt 1 block distance)
|
||||||
basic_machines.version = "09/25/2018a";
|
basic_machines.machines_TTL = 16 -- time to live for signals, how many hops before signal dissipates
|
||||||
|
|
||||||
|
basic_machines.version = "10/22/2018a";
|
||||||
basic_machines.clockgen = 1; -- if 0 all background continuously running activity (clockgen/keypad) repeating is disabled
|
basic_machines.clockgen = 1; -- if 0 all background continuously running activity (clockgen/keypad) repeating is disabled
|
||||||
|
|
||||||
-- how hard it is to move blocks, default factor 1, note fuel cost is this multiplied by distance and divided by machine_operations..
|
-- how hard it is to move blocks, default factor 1, note fuel cost is this multiplied by distance and divided by machine_operations..
|
||||||
|
@ -150,6 +152,12 @@ basic_machines.signs = {
|
||||||
-- *** END OF SETTINGS *** --
|
-- *** 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 = {};
|
||||||
|
|
||||||
|
@ -835,53 +843,19 @@ minetest.register_node("basic_machines:mover", {
|
||||||
|
|
||||||
-- REMOVE DIGGED NODE
|
-- REMOVE DIGGED NODE
|
||||||
if not(target_chest) then
|
if not(target_chest) then
|
||||||
if not drop then
|
if not drop then minetest.set_node(pos2, {name = node1.name}); end
|
||||||
-- get node (seed) table definition
|
|
||||||
local udef = minetest.registered_nodes[node1.name]
|
|
||||||
|
|
||||||
-- create pointed_thing table
|
|
||||||
local pointed_thing = {
|
|
||||||
type = "node",
|
|
||||||
above = {
|
|
||||||
y = pos2.y,
|
|
||||||
x = pos2.x,
|
|
||||||
z = pos2.z
|
|
||||||
},
|
|
||||||
under = {
|
|
||||||
y = pos2.y - 1,
|
|
||||||
x = pos2.x,
|
|
||||||
z = pos2.z
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
-- get ObjectRef
|
|
||||||
local placer = minetest.get_player_by_name(owner)
|
|
||||||
-- create ItemStack table
|
|
||||||
local stack = ItemStack(node1.name)
|
|
||||||
|
|
||||||
-- use default behaviour on_place if found in udef
|
|
||||||
if udef and
|
|
||||||
udef.on_place and
|
|
||||||
placer ~= nil then
|
|
||||||
udef.on_place(stack, placer, pointed_thing)
|
|
||||||
-- on_place not found in udef - use set_node instead
|
|
||||||
else
|
|
||||||
minetest.set_node(pos2, {name = node1.name})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if drop then
|
if drop then
|
||||||
local stack = ItemStack(node1.name)
|
local stack = ItemStack(node1.name);
|
||||||
minetest.add_item(pos2,stack) -- drops it
|
minetest.add_item(pos2,stack) -- drops it
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if not(source_chest) and not(harvest) then
|
if not(source_chest) and not(harvest) then
|
||||||
if dig then minetest.check_for_falling(pos1) end
|
if dig then minetest.check_for_falling(pos1) end
|
||||||
minetest.set_node(pos1, {name = "air"});
|
minetest.set_node(pos1, {name = "air"});
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
|
||||||
action_off = function (pos, node,ttl) -- this toggles reverse option of mover
|
action_off = function (pos, node,ttl) -- this toggles reverse option of mover
|
||||||
if type(ttl)~="number" then ttl = 1 end
|
if type(ttl)~="number" then ttl = 1 end
|
||||||
local meta = minetest.get_meta(pos);
|
local meta = minetest.get_meta(pos);
|
||||||
|
@ -2210,9 +2184,9 @@ minetest.register_on_player_receive_fields(function(player,formname,fields)
|
||||||
|
|
||||||
-- positions
|
-- positions
|
||||||
local x0,y0,z0,x1,y1,z1,x2,y2,z2;
|
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
|
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
|
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;
|
x2=tonumber(fields.x2) or 0;y2=tonumber(fields.y2) or 1;z2 = tonumber(fields.z2) or 0;
|
||||||
|
|
||||||
-- did the numbers change from last time?
|
-- 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
|
if meta:get_int("x0")~=x0 or meta:get_int("y0")~=y0 or meta:get_int("z0")~=z0 or
|
||||||
|
@ -2256,10 +2230,11 @@ minetest.register_on_player_receive_fields(function(player,formname,fields)
|
||||||
if fields.inv2 then
|
if fields.inv2 then
|
||||||
meta:set_string("inv2",fields.inv2);
|
meta:set_string("inv2",fields.inv2);
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--notification
|
||||||
meta:set_string("infotext", "Mover block. Set up with source coordinates ".. x0 ..","..y0..","..z0.. " -> ".. x1 ..","..y1..","..z1.. " and target coord ".. x2 ..","..y2..",".. z2 .. ". Put charged battery next to it and start it with keypad/mese signal.");
|
meta:set_string("infotext", "Mover block. Set up with source coordinates ".. x0 ..","..y0..","..z0.. " -> ".. x1 ..","..y1..","..z1.. " and target coord ".. x2 ..","..y2..",".. z2 .. ". Put charged battery next to it and start it with keypad/mese signal.");
|
||||||
|
|
||||||
else -- MODE
|
else -- MODE 1
|
||||||
|
|
||||||
if fields.mode then
|
if fields.mode then
|
||||||
meta:set_string("mode",fields.mode);
|
meta:set_string("mode",fields.mode);
|
||||||
|
@ -2290,6 +2265,9 @@ minetest.register_on_player_receive_fields(function(player,formname,fields)
|
||||||
end
|
end
|
||||||
|
|
||||||
meta:set_string("prefer", meta_prefer);
|
meta:set_string("prefer", meta_prefer);
|
||||||
|
|
||||||
|
--notification
|
||||||
|
meta:set_string("infotext", "Mover block. Mode or filter changed.");
|
||||||
end
|
end
|
||||||
|
|
||||||
if meta:get_float("fuel")<0 then meta:set_float("fuel",0) end -- reset block
|
if meta:get_float("fuel")<0 then meta:set_float("fuel",0) end -- reset block
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
local old_is_protected = minetest.is_protected
|
local old_is_protected = minetest.is_protected
|
||||||
local round = math.floor;
|
local round = math.floor;
|
||||||
local machines_TTL=16
|
local machines_TTL = basic_machines.machines_TTL or 16
|
||||||
|
|
||||||
function minetest.is_protected(pos, digger)
|
function minetest.is_protected(pos, digger)
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
local machines_timer=5
|
local machines_timer = basic_machines.machines_timer or 5
|
||||||
local machines_minstep = 1
|
local machines_minstep = basic_machines.machines_minstep or 1
|
||||||
|
|
||||||
-- BATTERY
|
-- BATTERY
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue