diff --git a/mover.lua b/mover.lua index 7dccd1f..06a15a9 100644 --- a/mover.lua +++ b/mover.lua @@ -6,12 +6,14 @@ -- *** SETTINGS *** -- -local machines_timer = 5 -- main timestep -local 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) -local machines_TTL = 16; -- time to live for signals, how many hops before signal dissipates -basic_machines.version = "09/25/2018a"; +basic_machines.timer = 5 -- main timestep +basic_machines.machines_minstep = 1 -- minimal allowed activation timestep, if faster machines overheat + +basic_machines.max_range = 10 -- machines normal range of operation +basic_machines.machines_operations = 10 -- 1 coal will provide 10 mover basic operations ( moving dirt 1 block distance) +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 -- 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 *** -- +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 = {}; @@ -835,53 +843,19 @@ minetest.register_node("basic_machines:mover", { -- REMOVE DIGGED NODE if not(target_chest) then - if not drop then - -- 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 not drop then minetest.set_node(pos2, {name = node1.name}); end if drop then - local stack = ItemStack(node1.name) + local stack = ItemStack(node1.name); minetest.add_item(pos2,stack) -- drops it end - end - + end if not(source_chest) and not(harvest) then if dig then minetest.check_for_falling(pos1) end minetest.set_node(pos1, {name = "air"}); end end, - + + action_off = function (pos, node,ttl) -- this toggles reverse option of mover if type(ttl)~="number" then ttl = 1 end local meta = minetest.get_meta(pos); @@ -2210,9 +2184,9 @@ minetest.register_on_player_receive_fields(function(player,formname,fields) -- 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; + 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; -- 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 @@ -2256,10 +2230,11 @@ minetest.register_on_player_receive_fields(function(player,formname,fields) if fields.inv2 then meta:set_string("inv2",fields.inv2); 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."); - else -- MODE + else -- MODE 1 if fields.mode then meta:set_string("mode",fields.mode); @@ -2290,6 +2265,9 @@ minetest.register_on_player_receive_fields(function(player,formname,fields) end meta:set_string("prefer", meta_prefer); + + --notification + meta:set_string("infotext", "Mover block. Mode or filter changed."); end if meta:get_float("fuel")<0 then meta:set_float("fuel",0) end -- reset block diff --git a/protect.lua b/protect.lua index b93266a..8e6f56b 100644 --- a/protect.lua +++ b/protect.lua @@ -5,7 +5,7 @@ local old_is_protected = minetest.is_protected local round = math.floor; -local machines_TTL=16 +local machines_TTL = basic_machines.machines_TTL or 16 function minetest.is_protected(pos, digger) diff --git a/technic_power.lua b/technic_power.lua index d319dbe..2ec4cc1 100644 --- a/technic_power.lua +++ b/technic_power.lua @@ -1,5 +1,5 @@ -local machines_timer=5 -local machines_minstep = 1 +local machines_timer = basic_machines.machines_timer or 5 +local machines_minstep = basic_machines.machines_minstep or 1 -- BATTERY