summaryrefslogtreecommitdiff
path: root/node_diggers.lua
diff options
context:
space:
mode:
authorFaceDeer <derksenmobile@gmail.com>2017-01-01 17:12:32 -0700
committerFaceDeer <derksenmobile@gmail.com>2017-01-01 17:12:32 -0700
commit47e42801d291249d1d0da28904695c9411650d6d (patch)
tree730a9b02bcd4ec9e7fbb80162b7e9b9eaf2570c8 /node_diggers.lua
parent12748d2f89cc94f95c5132e8127fe9f5e21c17b8 (diff)
Adding fuel usage
Adding fuel usage for digging and building. Fuel storage hopper module added to hold fuel.
Diffstat (limited to 'node_diggers.lua')
-rw-r--r--node_diggers.lua19
1 files changed, 10 insertions, 9 deletions
diff --git a/node_diggers.lua b/node_diggers.lua
index 936c95a..676b86e 100644
--- a/node_diggers.lua
+++ b/node_diggers.lua
@@ -55,8 +55,8 @@ minetest.register_node("digtron:digger", {
"button_exit[2.2,0.5;1,0.1;set;Save]" ..
"tooltip[set;Saves settings]"
)
- meta:set_string("period", 1)
- meta:set_string("offset", 0)
+ meta:set_int("period", 1)
+ meta:set_int("offset", 0)
local inv = meta:get_inventory()
inv:set_size("main", 1)
@@ -67,24 +67,25 @@ minetest.register_node("digtron:digger", {
local period = tonumber(fields.period)
local offset = tonumber(fields.offset)
if period and period > 0 then
- meta:set_string("period", math.floor(tonumber(fields.period)))
+ meta:set_int("period", math.floor(tonumber(fields.period)))
end
if offset then
- meta:set_string("offset", math.floor(tonumber(fields.offset)))
+ meta:set_int("offset", math.floor(tonumber(fields.offset)))
end
end,
+ -- returns fuel_cost, item_produced
execute_dig = function(pos, protected_nodes, nodes_dug, controlling_coordinate)
local facing = minetest.get_node(pos).param2
local digpos = digtron.find_new_pos(pos, facing)
if protected_nodes:get(digpos.x, digpos.y, digpos.z) then
- return nil
+ return 0, nil
end
local meta = minetest.get_meta(pos)
- if (digpos[controlling_coordinate] + meta:get_string("offset")) % meta:get_string("period") ~= 0 then
- return nil
+ if (digpos[controlling_coordinate] + meta:get_int("offset")) % meta:get_int("period") ~= 0 then
+ return 0, nil
end
return digtron.mark_diggable(digpos, nodes_dug)
@@ -134,7 +135,7 @@ minetest.register_node("digtron:soft_digger", {
local digpos = digtron.find_new_pos(pos, facing)
if protected_nodes:get(digpos.x, digpos.y, digpos.z) then
- return nil
+ return 0, nil
end
local target_node = minetest.get_node(digpos)
@@ -146,6 +147,6 @@ minetest.register_node("digtron:soft_digger", {
return digtron.mark_diggable(digpos, nodes_dug)
end
- return nil
+ return 0, nil
end,
}) \ No newline at end of file