From 6af67133be0524a1482e512038c5c1267b0ba1b9 Mon Sep 17 00:00:00 2001 From: FaceDeer Date: Fri, 6 Jan 2017 12:07:27 -0700 Subject: [PATCH] Adding combined storage module --- README.txt | 13 ++- init.lua | 28 ++++- node_misc.lua | 92 --------------- node_storage.lua | 159 ++++++++++++++++++++++++++ recipes.lua | 16 +++ textures/digtron_combined_storage.png | Bin 0 -> 853 bytes textures/digtron_inventory.png | Bin 752 -> 749 bytes util.lua | 9 +- 8 files changed, 221 insertions(+), 96 deletions(-) create mode 100644 node_storage.lua create mode 100644 textures/digtron_combined_storage.png diff --git a/README.txt b/README.txt index d9f8c8a..94fc9c9 100644 --- a/README.txt +++ b/README.txt @@ -102,6 +102,11 @@ The fuel costs for digging and building can be configured in the init.lua file. * Dig 60 wood nodes * Dig 80 dirt or sand nodes +Combined Storage Module +----------------------- + +For smaller jobs the two dedicated modules may simply be too much of a good thing, wasting precious Digtron space to give unneeded capacity. The combined storage module is the best of both worlds, splitting its internal space between building material inventory and fuel storage. It has 3/4 building material capacity and 1/4 fuel storage capacity. + Structural Module ----------------- @@ -190,7 +195,13 @@ Fuel storage modules: [furnace,] [core,] - + +Combined storage: + +[furnace,] +[core,] +[chest,] + Structural modules: [stick, , stick] diff --git a/init.lua b/init.lua index 1576130..91d7c7c 100644 --- a/init.lua +++ b/init.lua @@ -1,7 +1,8 @@ dofile( minetest.get_modpath( "digtron" ) .. "/util.lua" ) dofile( minetest.get_modpath( "digtron" ) .. "/pointset.lua" ) dofile( minetest.get_modpath( "digtron" ) .. "/entities.lua" ) -dofile( minetest.get_modpath( "digtron" ) .. "/node_misc.lua" ) -- contains inventory and structure nodes +dofile( minetest.get_modpath( "digtron" ) .. "/node_misc.lua" ) -- contains structure and light nodes +dofile( minetest.get_modpath( "digtron" ) .. "/node_storage.lua" ) -- contains inventory and fuel storage nodes dofile( minetest.get_modpath( "digtron" ) .. "/node_diggers.lua" ) -- contains all diggers dofile( minetest.get_modpath( "digtron" ) .. "/node_builders.lua" ) -- contains all builders (there's just one currently) dofile( minetest.get_modpath( "digtron" ) .. "/node_controllers.lua" ) -- controllers @@ -49,4 +50,29 @@ minetest.register_lbm({ meta:set_string("offset", offset) meta:set_string("period", period) end +}) + +minetest.register_lbm({ + name = "digtron:fuelstore_upgrade", + nodenames = {"digtron:fuelstore"}, + action = function(pos, node) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + local list = inv:get_list("main") + inv:set_list("main", {}) + inv:set_list("fuel", list) + 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;fuel;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;fuel]" .. + "listring[current_player;main]" .. + default.get_hotbar_bg(0,5.15) + ) + end }) \ No newline at end of file diff --git a/node_misc.lua b/node_misc.lua index 30b4e65..b8153cb 100644 --- a/node_misc.lua +++ b/node_misc.lua @@ -48,95 +48,3 @@ minetest.register_node("digtron:light", { wall_side = {-0.5, -0.25, -0.25, -0.1875, 0.25, 0.25}, }, }) - --- Storage buffer. Builder nodes draw from this inventory and digger nodes deposit into it. --- Note that inventories are digtron group 2. -minetest.register_node("digtron:inventory", -{ - description = "Digtron Inventory Hopper", - groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 2}, - drop = "digtron:inventory", - sounds = digtron.metal_sounds, - paramtype2= "facedir", - is_ground_content = false, - tiles = {"digtron_inventory.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;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,5.15) - ) - local inv = meta:get_inventory() - inv:set_size("main", 8*4) - end, - - can_dig = function(pos,player) - local meta = minetest.get_meta(pos) - 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, oddly_breakable_by_hand=3, digtron = 5}, - drop = "digtron:fuelstore", - sounds = digtron.metal_sounds, - paramtype2= "facedir", - is_ground_content = false, - 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 diff --git a/node_storage.lua b/node_storage.lua new file mode 100644 index 0000000..1a9d39b --- /dev/null +++ b/node_storage.lua @@ -0,0 +1,159 @@ +-- Storage buffer. Builder nodes draw from this inventory and digger nodes deposit into it. +-- Note that inventories are digtron group 2. +minetest.register_node("digtron:inventory", +{ + description = "Digtron Inventory Hopper", + groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 2}, + drop = "digtron:inventory", + sounds = digtron.metal_sounds, + paramtype2= "facedir", + is_ground_content = false, + tiles = {"digtron_inventory.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;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,5.15) + ) + local inv = meta:get_inventory() + inv:set_size("main", 8*4) + end, + + can_dig = function(pos,player) + local meta = minetest.get_meta(pos) + 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, oddly_breakable_by_hand=3, digtron = 5}, + drop = "digtron:fuelstore", + sounds = digtron.metal_sounds, + paramtype2= "facedir", + is_ground_content = false, + 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;fuel;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;fuel]" .. + "listring[current_player;main]" .. + default.get_hotbar_bg(0,5.15) + ) + local inv = meta:get_inventory() + inv:set_size("fuel", 8*4) + end, + + -- Only allow fuel items to be placed in fuel + allow_metadata_inventory_put = function(pos, listname, index, stack, player) + if minetest.is_protected(pos, player:get_player_name()) then + return 0 + end + if listname == "fuel" then + if minetest.get_craft_result({method="fuel", width=1, items={stack}}).time ~= 0 then + return stack:get_count() + else + return 0 + end + end + return 0 + end, + + can_dig = function(pos,player) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + return inv:is_empty("fuel") + end, +}) + +-- Combined storage. Group 6 has both an inventory and a fuel store +minetest.register_node("digtron:combined_storage", +{ + description = "Digtron Combined Storage", + groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 6}, + drop = "digtron:combined_storage", + sounds = digtron.metal_sounds, + paramtype2= "facedir", + is_ground_content = false, + tiles = {"digtron_combined_storage.png"}, + + on_construct = function(pos) + local meta = minetest.get_meta(pos) + meta:set_string("formspec", + "size[8,9.9]" .. + default.gui_bg .. + default.gui_bg_img .. + default.gui_slots .. + "label[0,0;Inventory items]" .. + "list[current_name;main;0,0.6;8,3;]" .. + "label[0,3.5;Fuel items]" .. + "list[current_name;fuel;0,4.1;8,1;]" .. + "list[current_player;main;0,5.75;8,1;]" .. + "list[current_player;main;0,6.98;8,3;8]" .. + "listring[current_name;fuel]" .. + "listring[current_player;main]" .. + default.get_hotbar_bg(0,5.75) + ) + local inv = meta:get_inventory() + inv:set_size("main", 8*3) + inv:set_size("fuel", 8*1) + end, + + -- Only allow fuel items to be placed in fuel + allow_metadata_inventory_put = function(pos, listname, index, stack, player) + if minetest.is_protected(pos, player:get_player_name()) then + return 0 + end + if listname == "fuel" then + if minetest.get_craft_result({method="fuel", width=1, items={stack}}).time ~= 0 then + return stack:get_count() + else + return 0 + end + end + return stack:get_count() -- otherwise, allow all drops + end, + + allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) + if to_list == "main" then + return count + end + + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + local stack = inv:get_stack(from_list, from_index) + if minetest.get_craft_result({method="fuel", width=1, items={stack}}).time ~= 0 then + return stack:get_count() + end + return 0 + end, + + can_dig = function(pos,player) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + return inv:is_empty("fuel") and inv:is_empty("main") + end, +}) diff --git a/recipes.lua b/recipes.lua index 6f5fead..d4786c4 100644 --- a/recipes.lua +++ b/recipes.lua @@ -84,6 +84,15 @@ minetest.register_craft({ } }) +minetest.register_craft({ + output = "digtron:combined_storage", + recipe = { + {"","default:furnace",""}, + {"","digtron:digtron_core",""}, + {"","default:chest",""} + } +}) + minetest.register_craft({ output = "digtron:structure", recipe = { @@ -151,6 +160,13 @@ minetest.register_craft({ } }) +minetest.register_craft({ + output = "digtron:digtron_core", + recipe = { + {"digtron:combined_storage"}, + } +}) + minetest.register_craft({ output = "digtron:digtron_core", recipe = { diff --git a/textures/digtron_combined_storage.png b/textures/digtron_combined_storage.png new file mode 100644 index 0000000000000000000000000000000000000000..0925d12de1fae96aeaf29192877d0b59ffb4d71e GIT binary patch literal 853 zcmV-b1FHOqP)WFU8GbZ8()Nlj2>E@cM*00Oy5L_t(I%O$}}ZyQwr zfYI+h<~{a!>^x}Hh6V|w!U9+!b-{)u5)ugh68{guh5`|36I2T)aqO|@&V91r9Pz{V z-=%Io!+S>vj%hSp|NV}Su3nlpX z>XMtHXH1r=s!&>!ya&Jqi}>Qp&y$i0r4%Ve>}2@s`i74$FE}d{Q%v0M4R`;%=kmi# zLX3Ft>AH@|81(7MisSJ>Q)YM{nY5%TbIxBpXFh95Qju>5w!48>pT44QYO*Y2x7$IC z=<^TGsq>u4dol^5HN3lf&*`&gWID%96H{ero0_W3DT;y+0(Dtqj(eoD4u_zu8%AS@ zQP9q2q##Hs5`$wr476=So@IFN0YRog=NVEeMUfSRV9|L^)yyc00v{|{mXnagl*o&c zqZw(MmZHcxJ-gs(yF>oFUUT#In*A^`3{OnXa(84aw=}QJMmdx00000NkvXXu0mjfsf2MN literal 0 HcmV?d00001 diff --git a/textures/digtron_inventory.png b/textures/digtron_inventory.png index 0e5ad0c1d6cfebcc64a12e09deeedc2b0fef1032..97e5d2f76dc53223fd8a006002c01beefcf81bb9 100644 GIT binary patch delta 639 zcmV-_0)YMS1?>fpQ3~M!1`;L%OtP_Sky|W(QAtEWR4C5{!C8(JM-Twe$jGg>?&_*u z7!XJ^*gxY7SmF>!_~0ypFF*(zkZ9=Hy0+XR((j3XUcGGBtCS*9^o#rQ_1p8SOQ~ee zc^Ier^Z4xP6Nw^(m_Y>Rux{#U3H{+v){QBv)9roWyzVyTdIO*UAZOULZP%`MyF-S5 ztgNwp*NF^>QfmzYnxYJ=kV>K?qL3n`M3j^< z^Wv2)LJSB1l+ev{1~!EWF^uCBV;}}MEz!-K;dDF><2cU?a1PD^fOzrZZy{s`NHH+e z$B&aRYFmInlwy3i@rj5T z5t$OAK$M75DJcK|AY}q6ks&iP6IWHOt*Pq@5i-g)<>o>%lQfk}QJE!)$?L1F)p;Kb7uq@12y4Pc>j($ Z{|^uvZS>=jCl3Gs002ovPDHLkV1m>yJ*fZy delta 642 zcmV-|0)74M1@HxsQ3~J;9v2@c-k)-hky|W(R7pfZR4C5{!P{~hMGyeco}Sy@S1ZX5 zPQ@5_3opQrPz8TZ!6Q}(i7^VYE$^;&=hi)(BYyqm=e}!GibT<`?(o;A@4o#;Dw%Vh z=F54UZ{NL@C_;!CL~su4roOCUdwpHjjVY_s^Eq(thE3UR02Bb^44b|m`fk6!&XARV zHFi4;A_Jn-T7!V5sg<6a~uD@i@)%vaG;4I0pdg&-;TAG6SR-m}#2k z4~Gv%O96SDmT8_JA0EHRFG7gE-@H73oz!+1647qAb8ek3v$~gs(OuW1#Kb~MrL^Ak zy_9mA=Iwr~hQ95$L-4UI3rI;I?yrWn=`t`;M1O3d_RWzPoAL z77$<0^E6KHzkgrVmDYM3M_^WOzIsy`<5SWIYjB?){=K@n(aJ>ceHog%Dhp$+C8DaR z+%jPdF@h+ndUcLjG;Nzn`+6SnzvJ=a--l^l=lRvg@bLLFaGuXkLJAb><>fiJ@ceW-9glzf c{u^`tANyZvEFOC>tN;K207*qoM6N<$f)%YaXaE2J diff --git a/util.lua b/util.lua index 05582e3..6709614 100644 --- a/util.lua +++ b/util.lua @@ -105,11 +105,13 @@ digtron.move_node = function(pos, newpos, player_name) local oldmeta = minetest.get_meta(pos) local oldinv = oldmeta:get_inventory() local list = oldinv:get_list("main") + local fuel = oldinv:get_list("fuel") local oldformspec = oldmeta:get_string("formspec") local newmeta = minetest.get_meta(newpos) local newinv = newmeta:get_inventory() newinv:set_list("main", list) + newinv:set_list("fuel", fuel) newmeta:set_string("formspec", oldformspec) newmeta:set_string("triggering_player", oldmeta:get_string("triggering_player")) -- for auto-controllers @@ -217,6 +219,9 @@ digtron.get_all_digtron_neighbours = function(pos, player) table.insert(layout.builders, testpos) elseif group_number == 5 then table.insert(layout.fuelstores, testpos) + elseif group_number == 6 then + table.insert(layout.inventories, testpos) + table.insert(layout.fuelstores, testpos) end --queue up potential new test points adjacent to this digtron node @@ -371,7 +376,7 @@ digtron.burn = function(fuelstore_positions, target, test) break end local inv = minetest.get_inventory({type="node", pos=location}) - local invlist = inv:get_list("main") + local invlist = inv:get_list("fuel") for i, itemstack in pairs(invlist) do local fuel_per_item = minetest.get_craft_result({method="fuel", width=1, items={itemstack:peek_item(1)}}).time if fuel_per_item ~= 0 then @@ -391,7 +396,7 @@ digtron.burn = function(fuelstore_positions, target, test) end if test ~= true then -- only update the list if we're doing this for real. - inv:set_list("main", invlist) + inv:set_list("fuel", invlist) end end return current_burned