add automation option to item ejector

This commit is contained in:
FaceDeer 2017-10-21 22:29:18 -06:00
parent e93ff05956
commit 94ccab9c39
12 changed files with 262 additions and 114 deletions

@ -13,7 +13,7 @@ local get_node_image = function(pos, node)
local meta = minetest.get_meta(pos)
node_image.meta = meta:to_table()
if node_image.meta ~= nil and node_def._digtron_formspec ~= nil then
node_image.meta.fields.formspec = node_def._digtron_formspec -- causes formspec to be automatically upgraded whenever Digtron moves
node_image.meta.fields.formspec = node_def._digtron_formspec(pos, meta) -- causes formspec to be automatically upgraded whenever Digtron moves
end
-- Record what kind of thing we've got in a builder node so its facing can be rotated properly
@ -42,6 +42,7 @@ function DigtronLayout.create(pos, player)
self.power_connectors = {} -- technic power cable
self.diggers = {}
self.builders = {}
self.auto_ejectors = {}
self.extents = {}
self.water_touching = false
self.lava_touching = false
@ -128,6 +129,8 @@ function DigtronLayout.create(pos, player)
table.insert(self.battery_holders, node_image)
elseif group_number == 8 then
table.insert(self.power_connectors, node_image)
elseif group_number == 9 and node_image.meta.fields["autoeject"] == "true" then
table.insert(self.auto_ejectors, node_image)
end
if is_protected then

@ -197,7 +197,7 @@ digtron.doc.power_connector_usagehelp = S("A power connector node automatically
---------------------------------------------------------------------
digtron.doc.inventory_ejector_longdesc = S("An outlet that can be used to eject accumulated detritus from a Digtron's inventory.")
digtron.doc.inventory_ejector_usagehelp = S("When this block is right-clicked it will search the entire inventory of the Digtron and will eject a stack of items taken from it, provided the items are not set for use by any of the Digtron's builders. Will not eject if the destination block is occupied.")
digtron.doc.inventory_ejector_usagehelp = S("When this block is punched it will search the entire inventory of the Digtron and will eject a stack of items taken from it, provided the items are not set for use by any of the Digtron's builders. It will not eject if the destination block is occupied.")
if pipeworks_enabled then
digtron.doc.inventory_ejector_usagehelp = digtron.doc.inventory_ejector_usagehelp

@ -76,6 +76,8 @@ dofile( digtron_modpath .. "/upgrades.lua" ) -- various LBMs for upgrading older
-- 5 - fuel-holding digtron, has a "fuel" invetory that the control node can draw fuel items from. Separate from general inventory, nothing gets put here automatically.
-- 6 - holds both fuel and main inventories
-- 7 - holds batteries (RE Battery from technic) to provide clean renewable power
-- 8 - connects to adjacent HV technic cable
-- 9 - connects to pipeworks, auto-ejects mined items
-- This code was added for use with FaceDeer's fork of the [catacomb] mod. Paramat's version doesn't support customized protected nodes, which causes
-- it to "eat" Digtrons sometimes.

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-10-14 14:59-0600\n"
"POT-Creation-Date: 2017-10-21 22:27-0600\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -733,10 +733,10 @@ msgstr ""
#: doc.lua:200
msgid ""
"When this block is right-clicked it will search the entire inventory of the "
"When this block is punched it will search the entire inventory of the "
"Digtron and will eject a stack of items taken from it, provided the items "
"are not set for use by any of the Digtron's builders. Will not eject if the "
"destination block is occupied."
"are not set for use by any of the Digtron's builders. It will not eject if "
"the destination block is occupied."
msgstr ""
#: doc.lua:205
@ -972,17 +972,17 @@ msgid "Digtron has @1 blocks but only enough traction to move @2 blocks.\n"
msgstr ""
#: util_execute_cycle.lua:110
#: util_execute_cycle.lua:349
#: util_execute_cycle.lua:426
#: util_execute_cycle.lua:545
#: util_execute_cycle.lua:359
#: util_execute_cycle.lua:436
#: util_execute_cycle.lua:555
#: nodes\node_controllers.lua:48
#: nodes\node_controllers.lua:201
#: nodes\node_controllers.lua:202
msgid "Heat remaining in controller furnace: @1"
msgstr ""
#: util_execute_cycle.lua:173
#: util_execute_cycle.lua:399
#: util_execute_cycle.lua:489
#: util_execute_cycle.lua:409
#: util_execute_cycle.lua:499
#: nodes\node_axle.lua:57
msgid "Digtron is obstructed."
msgstr ""
@ -1000,7 +1000,7 @@ msgstr ""
msgid "Digtron has insufficient building materials. Needed: @1"
msgstr ""
#: util_execute_cycle.lua:328
#: util_execute_cycle.lua:338
msgid ""
"Digtron unexpectedly failed to execute one or more build operations, likely "
"due to an inventory error."
@ -1010,11 +1010,11 @@ msgstr ""
msgid "Digtron Rotation Axle"
msgstr ""
#: nodes\node_battery_holder.lua:14
#: nodes\node_battery_holder.lua:13
msgid "Batteries"
msgstr ""
#: nodes\node_battery_holder.lua:31
#: nodes\node_battery_holder.lua:33
msgid "Digtron Battery Holder"
msgstr ""
@ -1034,7 +1034,7 @@ msgid ""
msgstr ""
#: nodes\node_builders.lua:21
#: nodes\node_diggers.lua:32
#: nodes\node_diggers.lua:33
msgid "Periodicity"
msgstr ""
@ -1047,7 +1047,7 @@ msgstr ""
#: nodes\node_builders.lua:23
#: nodes\node_controllers.lua:91
#: nodes\node_diggers.lua:34
#: nodes\node_diggers.lua:35
msgid "Offset"
msgstr ""
@ -1060,14 +1060,14 @@ msgid ""
msgstr ""
#: nodes\node_builders.lua:25
#: nodes\node_diggers.lua:36
#: nodes\node_diggers.lua:37
msgid ""
"Save &\n"
"Show"
msgstr ""
#: nodes\node_builders.lua:26
#: nodes\node_diggers.lua:37
#: nodes\node_diggers.lua:38
msgid "Saves settings"
msgstr ""
@ -1097,18 +1097,20 @@ msgstr ""
#: nodes\node_builders.lua:39
#: nodes\node_controllers.lua:106
#: nodes\node_crate.lua:80
#: nodes\node_diggers.lua:41
#: nodes\node_diggers.lua:42
#: nodes\node_item_ejector.lua:17
msgid "Help"
msgstr ""
#: nodes\node_builders.lua:40
#: nodes\node_controllers.lua:107
#: nodes\node_crate.lua:81
#: nodes\node_diggers.lua:42
#: nodes\node_diggers.lua:43
#: nodes\node_item_ejector.lua:18
msgid "Show documentation about this block"
msgstr ""
#: nodes\node_builders.lua:45
#: nodes\node_builders.lua:49
msgid "Digtron Builder Module"
msgstr ""
@ -1194,11 +1196,11 @@ msgstr ""
msgid "Digtron Automatic Control Module"
msgstr ""
#: nodes\node_controllers.lua:285
#: nodes\node_controllers.lua:286
msgid "Interrupted!"
msgstr ""
#: nodes\node_controllers.lua:300
#: nodes\node_controllers.lua:301
msgid "Digtron Pusher Module"
msgstr ""
@ -1254,32 +1256,32 @@ msgstr ""
msgid "Attempts to unpack the Digtron on this location"
msgstr ""
#: nodes\node_crate.lua:98
#: nodes\node_crate.lua:103
msgid "Digtron Crate (Loaded)"
msgstr ""
#: nodes\node_crate.lua:133
#: nodes\node_crate.lua:138
msgid ""
"Unable to read layout from crate metadata, regrettably this Digtron may be "
"corrupted or lost."
msgstr ""
#: nodes\node_crate.lua:164
#: nodes\node_crate.lua:169
msgid "Unable to deploy Digtron due to protected blocks in target area"
msgstr ""
#: nodes\node_crate.lua:170
#: nodes\node_crate.lua:175
msgid "Unable to deploy Digtron due to obstruction in target area"
msgstr ""
#: nodes\node_diggers.lua:33
#: nodes\node_diggers.lua:34
msgid ""
"Digger will dig once every n steps.\n"
"These steps are globally aligned, all diggers with\n"
"the same period and offset will dig on the same location."
msgstr ""
#: nodes\node_diggers.lua:35
#: nodes\node_diggers.lua:36
msgid ""
"Offsets the start of periodicity counting by this amount.\n"
"For example, a digger with period 2 and offset 0 digs\n"
@ -1287,31 +1289,49 @@ msgid ""
"offset 1 digs every odd-numbered block."
msgstr ""
#: nodes\node_diggers.lua:75
#: nodes\node_diggers.lua:80
msgid "Digtron Digger Head"
msgstr ""
#: nodes\node_diggers.lua:128
#: nodes\node_diggers.lua:133
msgid "Digtron Intermittent Digger Head"
msgstr ""
#: nodes\node_diggers.lua:199
#: nodes\node_diggers.lua:204
msgid "Digtron Soft Material Digger Head"
msgstr ""
#: nodes\node_diggers.lua:254
#: nodes\node_diggers.lua:259
msgid "Digtron Intermittent Soft Material Digger Head"
msgstr ""
#: nodes\node_diggers.lua:328
#: nodes\node_diggers.lua:333
msgid "Digtron Dual Digger Head"
msgstr ""
#: nodes\node_diggers.lua:405
#: nodes\node_diggers.lua:410
msgid "Digtron Dual Soft Material Digger Head"
msgstr ""
#: nodes\node_item_ejector.lua:8
#: nodes\node_item_ejector.lua:27
msgid "Eject into world"
msgstr ""
#: nodes\node_item_ejector.lua:28
msgid "When checked, will eject items even if there's no pipe to accept it"
msgstr ""
#: nodes\node_item_ejector.lua:30
msgid "Automatic"
msgstr ""
#: nodes\node_item_ejector.lua:31
msgid ""
"When checked, will eject items automatically with every Digtron cycle.\n"
"Item ejectors can always be operated manually by punching them."
msgstr ""
#: nodes\node_item_ejector.lua:105
msgid "Digtron Inventory Ejector"
msgstr ""
@ -1357,29 +1377,29 @@ msgstr ""
msgid "Digtron HV Power Connector"
msgstr ""
#: nodes\node_power_connector.lua:67
#: nodes\node_power_connector.lua:66
msgid "Digtron Power @1/@2"
msgstr ""
#: nodes\node_storage.lua:12
#: nodes\node_storage.lua:172
#: nodes\node_storage.lua:180
msgid "Inventory items"
msgstr ""
#: nodes\node_storage.lua:23
#: nodes\node_storage.lua:27
msgid "Digtron Inventory Storage"
msgstr ""
#: nodes\node_storage.lua:83
#: nodes\node_storage.lua:174
#: nodes\node_storage.lua:87
#: nodes\node_storage.lua:182
msgid "Fuel items"
msgstr ""
#: nodes\node_storage.lua:94
#: nodes\node_storage.lua:102
msgid "Digtron Fuel Storage"
msgstr ""
#: nodes\node_storage.lua:185
#: nodes\node_storage.lua:196
msgid "Digtron Combined Storage"
msgstr ""

@ -6,8 +6,7 @@ local S, NS = dofile(MP.."/intllib.lua")
-- Battery storage. Controller node draws electrical power from here.
-- Note that batttery boxes are digtron group 7.
local battery_holder_formspec =
"size[8,9.3]" ..
local battery_holder_formspec_string = "size[8,9.3]" ..
default.gui_bg ..
default.gui_bg_img ..
default.gui_slots ..
@ -19,6 +18,9 @@ local battery_holder_formspec =
"listring[current_player;main]" ..
default.get_hotbar_bg(0,5.15)
local battery_holder_formspec = function(pos, meta)
return battery_holder_formspec_string
end
local holder_groups = {cracky = 3, oddly_breakable_by_hand = 3, digtron = 7, tubedevice = 1, tubedevice_receiver = 1}
if not minetest.get_modpath("technic") then
@ -50,7 +52,7 @@ minetest.register_node("digtron:battery_holder", {
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", battery_holder_formspec)
meta:set_string("formspec", battery_holder_formspec(pos, meta))
local inv = meta:get_inventory()
inv:set_size("batteries", 8*4)
end,

@ -9,7 +9,7 @@ if minetest.get_modpath("doc") then
displace_due_to_help_button = 0.0
end
local builder_formspec =
local builder_formspec_string =
"size[8,5.2]" ..
default.gui_bg ..
default.gui_bg_img ..
@ -35,11 +35,15 @@ local builder_formspec =
"listring[current_name;main]"
if minetest.get_modpath("doc") then
builder_formspec = builder_formspec ..
builder_formspec_string = builder_formspec_string ..
"button_exit[7.0,0.5;1,0.1;help;" .. S("Help") .. "]" ..
"tooltip[help;" .. S("Show documentation about this block") .. "]"
end
local builder_formspec = function(pos, meta)
return builder_formspec_string
end
-- Builds objects in the targeted node. This is a complicated beastie.
minetest.register_node("digtron:builder", {
description = S("Digtron Builder Module"),
@ -84,7 +88,7 @@ minetest.register_node("digtron:builder", {
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", builder_formspec)
meta:set_string("formspec", builder_formspec(pos, meta))
meta:set_int("period", 1)
meta:set_int("offset", 0)
meta:set_int("build_facing", 0)

@ -62,10 +62,10 @@ minetest.register_node("digtron:empty_crate", {
end,
})
local loaded_formspec
if minetest.get_modpath("doc") then
loaded_formspec =
local modpath_doc = minetest.get_modpath("doc")
local loaded_formspec_string
if modpath_doc then
loaded_formspec_string =
"size[4.1,1.5]" ..
default.gui_bg ..
default.gui_bg_img ..
@ -80,7 +80,7 @@ if minetest.get_modpath("doc") then
"button_exit[3.0,1.2;1,0.1;help;" .. S("Help") .. "]" ..
"tooltip[help;" .. S("Show documentation about this block") .. "]"
else
loaded_formspec =
loaded_formspec_string =
"size[4,1.5]" ..
default.gui_bg ..
default.gui_bg_img ..
@ -94,6 +94,11 @@ else
"tooltip[unpack;" .. S("Attempts to unpack the Digtron on this location") .. "]"
end
local loaded_formspec = function(pos, meta)
return loaded_formspec_string
end
minetest.register_node("digtron:loaded_crate", {
description = S("Digtron Crate (Loaded)"),
_doc_items_longdesc = digtron.doc.loaded_crate_longdesc,
@ -107,7 +112,7 @@ minetest.register_node("digtron:loaded_crate", {
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", loaded_formspec)
meta:set_string("formspec", loaded_formspec(pos, meta))
end,
on_receive_fields = function(pos, formname, fields, sender)
@ -202,7 +207,7 @@ minetest.register_node("digtron:loaded_crate", {
meta:set_string("crated_layout", deserialized.layout)
meta:set_string("title", deserialized.title)
meta:set_string("infotext", deserialized.title)
meta:set_string("formspec", loaded_formspec)
--meta:set_string("formspec", loaded_formspec(pos, meta)) -- not needed, on_construct handles this
itemstack:take_item(1)
return itemstack

@ -25,8 +25,9 @@ local dual_digger_nodebox = {
{-0.4375, -0.5, -0.3125, 0.4375, -0.4375, 0.3125}, -- Lower_Cutter_2
}
local intermittent_formspec =
default.gui_bg ..
local modpath_doc = minetest.get_modpath("doc")
local intermittent_formspec_string = default.gui_bg ..
default.gui_bg_img ..
default.gui_slots ..
"field[0.5,0.8;1,0.1;period;" .. S("Periodicity") .. ";${period}]" ..
@ -36,17 +37,21 @@ local intermittent_formspec =
"button_exit[2.2,0.5;1,0.1;set;" .. S("Save &\nShow") .. "]" ..
"tooltip[set;" .. S("Saves settings") .. "]"
if minetest.get_modpath("doc") then
intermittent_formspec = "size[4.5,1]" .. intermittent_formspec ..
if modpath_doc then
intermittent_formspec_string = "size[4.5,1]" .. intermittent_formspec_string ..
"button_exit[3.2,0.5;1,0.1;help;" .. S("Help") .. "]" ..
"tooltip[help;" .. S("Show documentation about this block") .. "]"
else
intermittent_formspec = "size[3.5,1]" .. intermittent_formspec
intermittent_formspec_string = "size[3.5,1]" .. intermittent_formspec_string
end
local intermittent_formspec = function(pos, meta)
return intermittent_formspec_string
end
local intermittent_on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", intermittent_formspec)
meta:set_string("formspec", intermittent_formspec(pos, meta))
meta:set_int("period", 1)
meta:set_int("offset", 0)
end

@ -2,13 +2,111 @@
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP.."/intllib.lua")
--Build up the formspec, somewhat complicated due to multiple mod options
local pipeworks_path = minetest.get_modpath("pipeworks")
local doc_path = minetest.get_modpath("doc")
local formspec_width = 1.5
local ejector_formspec_string =
default.gui_bg ..
default.gui_bg_img ..
default.gui_slots
if doc_path then
ejector_formspec_string = ejector_formspec_string ..
"button_exit[".. 0.2 + formspec_width ..",0.5;1,0.1;help;" .. S("Help") .. "]" ..
"tooltip[help;" .. S("Show documentation about this block") .. "]"
formspec_width = formspec_width + 1.5
end
local ejector_formspec_string = "size[".. formspec_width .. ",1]" .. ejector_formspec_string
local ejector_formspec = function(pos, meta)
local return_string = ejector_formspec_string
if pipeworks_path then
return_string = return_string .. "checkbox[0,0.5;nonpipe;"..S("Eject into world")..";"..meta:get_string("nonpipe").."]" ..
"tooltip[nonpipe;" .. S("When checked, will eject items even if there's no pipe to accept it") .. "]"
end
return return_string .. "checkbox[0,0;autoeject;"..S("Automatic")..";"..meta:get_string("autoeject").."]" ..
"tooltip[autoeject;" .. S("When checked, will eject items automatically with every Digtron cycle.\nItem ejectors can always be operated manually by punching them.") .. "]"
end
local function eject_items(pos, node, player, eject_even_without_pipeworks)
local dir = minetest.facedir_to_dir(node.param2)
local destination_pos = vector.add(pos, dir)
local destination_node_name = minetest.get_node(destination_pos).name
local destination_node_def = minetest.registered_nodes[destination_node_name]
if not pipeworks_path then eject_even_without_pipeworks = true end -- if pipeworks is not installed, always eject into world (there's no other option)
local insert_into_pipe = false
local eject_into_world = false
if pipeworks_path and minetest.get_node_group(destination_node_name, "tubedevice") > 0 then
insert_into_pipe = true
elseif eject_even_without_pipeworks then
if destination_node_def and not destination_node_def.walkable then
eject_into_world = true
else
minetest.sound_play("buzzer", {gain=0.5, pos=pos})
return false
end
else
return false
end
local layout = DigtronLayout.create(pos, player)
-- Build a list of all the items that builder nodes want to use.
local filter_items = {}
for _, node_image in pairs(layout.builders) do
filter_items[node_image.meta.inventory.main[1]:get_name()] = true
end
-- Look through the inventories and find an item that's not on that list.
local source_node = nil
local source_index = nil
local source_stack = nil
for _, node_image in pairs(layout.inventories) do
for index, item_stack in pairs(node_image.meta.inventory.main) do
if item_stack:get_count() > 0 and not filter_items[item_stack:get_name()] then
source_node = node_image
source_index = index
source_stack = item_stack
break
end
end
if source_node then break end
end
if source_node then
local meta = minetest.get_meta(source_node.pos)
local inv = meta:get_inventory()
if insert_into_pipe then
local from_pos = vector.add(pos, vector.multiply(dir, 0.5))
local start_pos = pos
inv:set_stack("main", source_index, nil)
pipeworks.tube_inject_item(from_pos, start_pos, vector.multiply(dir, 1), source_stack, player:get_player_name())
minetest.sound_play("steam_puff", {gain=0.5, pos=pos})
return true
elseif eject_into_world then
minetest.add_item(destination_pos, source_stack)
inv:set_stack("main", source_index, nil)
minetest.sound_play("steam_puff", {gain=0.5, pos=pos})
return true
end
end
-- couldn't find an item to eject
return false
end
minetest.register_node("digtron:inventory_ejector", {
description = S("Digtron Inventory Ejector"),
_doc_items_longdesc = digtron.doc.inventory_ejector_longdesc,
_doc_items_usagehelp = digtron.doc.inventory_ejector_usagehelp,
groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 1, tubedevice = 1},
_digtron_formspec = ejector_formspec,
groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 9, tubedevice = 1},
tiles = {"digtron_plate.png", "digtron_plate.png", "digtron_plate.png", "digtron_plate.png", "digtron_plate.png^digtron_output.png", "digtron_plate.png^digtron_output_back.png"},
drawtype = "nodebox",
sounds = digtron.metal_sounds,
@ -24,57 +122,43 @@ minetest.register_node("digtron:inventory_ejector", {
}
},
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("autoeject", "true")
meta:set_string("formspec", ejector_formspec(pos, meta))
end,
tube = (function() if pipeworks_path then return {
connect_sides = {back = 1}
} end end)(),
on_rightclick = function(pos, node, player)
local dir = minetest.facedir_to_dir(node.param2)
local destination_pos = vector.add(pos, dir)
local destination_node_name = minetest.get_node(destination_pos).name
local destination_node_def = minetest.registered_nodes[destination_node_name]
local layout = DigtronLayout.create(pos, player)
on_punch = function(pos, node, player)
eject_items(pos, node, player, true)
end,
-- Build a list of all the items that builder nodes want to use.
local filter_items = {}
for _, node_image in pairs(layout.builders) do
filter_items[node_image.meta.inventory.main[1]:get_name()] = true
execute_eject = function(pos, node, player)
local meta = minetest.get_meta(pos)
eject_items(pos, node, player, meta:get_string("nonpipe") == "true")
end,
on_receive_fields = function(pos, formname, fields, sender)
local meta = minetest.get_meta(pos)
if fields.help and minetest.get_modpath("doc") then --check for mod in case someone disabled it after this digger was built
local node_name = minetest.get_node(pos).name
minetest.after(0.5, doc.show_entry, sender:get_player_name(), "nodes", node_name, true)
end
-- Look through the inventories and find an item that's not on that list.
local source_node = nil
local source_index = nil
local source_stack = nil
for _, node_image in pairs(layout.inventories) do
for index, item_stack in pairs(node_image.meta.inventory.main) do
if item_stack:get_count() > 0 and not filter_items[item_stack:get_name()] then
source_node = node_image
source_index = index
source_stack = item_stack
break
end
end
if source_node then break end
if fields.nonpipe then
meta:set_string("nonpipe", fields.nonpipe)
end
if source_node then
local meta = minetest.get_meta(source_node.pos)
local inv = meta:get_inventory()
if pipeworks_path and minetest.get_node_group(destination_node_name, "tubedevice") > 0 then
local from_pos = vector.add(pos, vector.multiply(dir, 0.5))
local start_pos = pos--vector.add(pos, dir)
inv:set_stack("main", source_index, nil)
pipeworks.tube_inject_item(from_pos, start_pos, vector.multiply(dir, 1), source_stack, player:get_player_name())
minetest.sound_play("steam_puff", {gain=0.5, pos=pos})
elseif destination_node_def and not destination_node_def.walkable then
minetest.add_item(destination_pos, source_stack)
inv:set_stack("main", source_index, nil)
minetest.sound_play("steam_puff", {gain=0.5, pos=pos})
else
minetest.sound_play("buzzer", {gain=0.5, pos=pos})
end
if fields.autoeject then
meta:set_string("autoeject", fields.autoeject)
end
meta:set_string("formspec", ejector_formspec(pos, meta))
end,
after_place_node = (function() if pipeworks_path then return pipeworks.after_place end end)(),

@ -4,7 +4,7 @@ local S, NS = dofile(MP.."/intllib.lua")
local pipeworks_path = minetest.get_modpath("pipeworks")
local inventory_formspec =
local inventory_formspec_string =
"size[8,9.3]" ..
default.gui_bg ..
default.gui_bg_img ..
@ -17,6 +17,10 @@ local inventory_formspec =
"listring[current_player;main]" ..
default.get_hotbar_bg(0,5.15)
local inventory_formspec = function(pos, meta)
return inventory_formspec_string
end
-- 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", {
@ -42,7 +46,7 @@ minetest.register_node("digtron:inventory", {
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", inventory_formspec)
meta:set_string("formspec", inventory_formspec(pos, meta))
local inv = meta:get_inventory()
inv:set_size("main", 8*4)
end,
@ -75,7 +79,7 @@ minetest.register_node("digtron:inventory", {
after_dig_node = (function() if pipeworks_path then return pipeworks.after_dig end end)()
})
local fuelstore_formspec =
local fuelstore_formspec_string =
"size[8,9.3]" ..
default.gui_bg ..
default.gui_bg_img ..
@ -88,6 +92,10 @@ local fuelstore_formspec =
"listring[current_player;main]" ..
default.get_hotbar_bg(0,5.15)
local fuelstore_formspec = function(pos, meta)
return fuelstore_formspec_string
end
-- Fuel storage. Controller node draws fuel from here.
-- Note that fuel stores are digtron group 5.
minetest.register_node("digtron:fuelstore", {
@ -164,7 +172,7 @@ minetest.register_node("digtron:fuelstore", {
after_dig_node = (function() if pipeworks_path then return pipeworks.after_dig end end)()
})
local combined_storage_formspec =
local combined_storage_formspec_string =
"size[8,9.9]" ..
default.gui_bg ..
default.gui_bg_img ..
@ -179,6 +187,9 @@ local combined_storage_formspec =
"listring[current_player;main]" ..
default.get_hotbar_bg(0,5.75)
local combined_storage_formspec = function(pos, meta)
return combined_storage_formspec_string
end
-- Combined storage. Group 6 has both an inventory and a fuel store
minetest.register_node("digtron:combined_storage", {
@ -202,7 +213,7 @@ minetest.register_node("digtron:combined_storage", {
},
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", combined_storage_formspec)
meta:set_string("formspec", combined_storage_formspec(pos, meta))
local inv = meta:get_inventory()
inv:set_size("main", 8*3)
inv:set_size("fuel", 8*1)

@ -4,8 +4,10 @@ minetest.register_lbm({
nodenames = {"group:digtron"},
action = function(pos, node)
local node_def = minetest.registered_nodes[node.name]
local meta = minetest.get_meta(pos)
meta:set_string("formspec", node_def._digtron_formspec)
if node_def._digtron_formspec then
local meta = minetest.get_meta(pos)
meta:set_string("formspec", node_def._digtron_formspec(pos, meta))
end
end
})

@ -320,6 +320,16 @@ digtron.execute_dig_cycle = function(pos, clicker)
end
end
for k, location in pairs(layout.auto_ejectors) do
local target = minetest.get_node(location.pos)
local targetdef = minetest.registered_nodes[target.name]
if targetdef.execute_eject ~= nil then
targetdef.execute_eject(location.pos, target, clicker)
else
minetest.log(string.format("%s has an ejector group but is missing execute_eject method! This is an error in mod programming, file a bug.", targetdef.name))
end
end
local status_text = ""
if strange_failure then
-- We weren't able to detect this build failure ahead of time, so make a big noise now. This is strange, shouldn't happen.