diff options
author | FaceDeer <derksenmobile@gmail.com> | 2017-01-01 17:12:32 -0700 |
---|---|---|
committer | FaceDeer <derksenmobile@gmail.com> | 2017-01-01 17:12:32 -0700 |
commit | 47e42801d291249d1d0da28904695c9411650d6d (patch) | |
tree | 730a9b02bcd4ec9e7fbb80162b7e9b9eaf2570c8 /node_misc.lua | |
parent | 12748d2f89cc94f95c5132e8127fe9f5e21c17b8 (diff) |
Adding fuel usage
Adding fuel usage for digging and building. Fuel storage hopper module
added to hold fuel.
Diffstat (limited to 'node_misc.lua')
-rw-r--r-- | node_misc.lua | 63 |
1 files changed, 58 insertions, 5 deletions
diff --git a/node_misc.lua b/node_misc.lua index c26d6a2..262ef6e 100644 --- a/node_misc.lua +++ b/node_misc.lua @@ -58,16 +58,17 @@ minetest.register_node("digtron:inventory", on_construct = function(pos) local meta = minetest.get_meta(pos) meta:set_string("formspec", - "size[8,9]" .. + "size[8,9.3]" .. default.gui_bg .. default.gui_bg_img .. default.gui_slots .. - "list[current_name;main;0,0.3;8,4;]" .. - "list[current_player;main;0,4.85;8,1;]" .. - "list[current_player;main;0,6.08;8,3;8]" .. + "label[0,0;Inventory items]" .. + "list[current_name;main;0,0.6;8,4;]" .. + "list[current_player;main;0,5.15;8,1;]" .. + "list[current_player;main;0,6.38;8,3;8]" .. "listring[current_name;main]" .. "listring[current_player;main]" .. - default.get_hotbar_bg(0,4.85) + default.get_hotbar_bg(0,5.15) ) local inv = meta:get_inventory() inv:set_size("main", 8*4) @@ -78,4 +79,56 @@ minetest.register_node("digtron:inventory", local inv = meta:get_inventory() return inv:is_empty("main") end, +}) + +-- Fuel storage. Controller node draws fuel from here. +-- Note that fuel stores are digtron group 5. +minetest.register_node("digtron:fuelstore", +{ + description = "Digtron Fuel Hopper", + groups = {cracky = 3, stone = 1, digtron = 5}, + drop = 'digtron:fuelstore', + paramtype2= 'facedir', + tiles = {"digtron_fuelstore.png"}, + + on_construct = function(pos) + local meta = minetest.get_meta(pos) + meta:set_string("formspec", + "size[8,9.3]" .. + default.gui_bg .. + default.gui_bg_img .. + default.gui_slots .. + "label[0,0;Fuel items]" .. + "list[current_name;main;0,0.6;8,4;]" .. + "list[current_player;main;0,5.15;8,1;]" .. + "list[current_player;main;0,6.38;8,3;8]" .. + "listring[current_name;main]" .. + "listring[current_player;main]" .. + default.get_hotbar_bg(0,5.15) + ) + local inv = meta:get_inventory() + inv:set_size("main", 8*4) + end, + + -- Only allow fuel items to be placed in here + allow_metadata_inventory_put = function(pos, listname, index, stack, player) + if minetest.is_protected(pos, player:get_player_name()) then + return 0 + end + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + if listname == "main" then + if minetest.get_craft_result({method="fuel", width=1, items={stack}}).time ~= 0 then + return stack:get_count() + else + return 0 + end + end + end, + + can_dig = function(pos,player) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + return inv:is_empty("main") + end, })
\ No newline at end of file |