Compare commits

...

2 Commits

2 changed files with 46 additions and 3 deletions

View File

@ -103,6 +103,12 @@ minetest.register_globalstep(function(dtime)
end
elseif outputType == "Inventory" then
hudString = hudString .. outputname .. ": Inventory (viewing not implemented)"
elseif outputType == "InventoryList" then
local count = 1
for listItemName, listItem in pairs(output) do
hudString = hudString .. outputname .. "[" .. count .. "]:" .. listItem:get_name() .. "[" .. listItem:get_count() .. "] (item)\n"
count = count +1
end
else
hudString = hudString .. outputType .. "?\n".. dump2(output)
end

View File

@ -21,8 +21,8 @@ local function is_smeltable(items)
end
local function is_item_allowed(pos, target, _, stack)
if target ~= "source" then return 0 end
if target ~= "source" or not sparktech.getoption(pos, "acceptInput") then return 0 end
if not is_smeltable({stack}) then
return 0
else
@ -39,6 +39,7 @@ end
local function ongetitem(pos)
local meta = minetest.get_meta(pos)
if not sparktech.getoption(pos, "enabled") then return end
if meta:get_int("energy") < modifier then return end
local timer = minetest.get_node_timer(pos)
timer:start(1.0)
@ -46,6 +47,8 @@ end
local function mytime(pos, elapsed)
local meta = minetest.get_meta(pos)
if not sparktech.getoption(pos, "enabled") then return end -- TODO: show in the gui somehow
local energy = meta:get_int("energy")
local inventory = meta:get_inventory()
local source = inventory:get_list("source")
@ -125,7 +128,41 @@ minetest.register_node( NAME .. ":furnace", {
allow_metadata_inventory_put = is_item_allowed,
allow_metadata_inventory_move = is_item_allowed_move,
on_metadata_inventory_put = ongetitem
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
if listname ~= "product" then return stack:get_count() end
if not sparktech.getoption(pos, "acceptRemoval") then return 0 end
return stack:get_count()
end,
on_metadata_inventory_put = ongetitem,
_sparkoptionchanged = function(pos, name)
if name == "enabled" then
local timer = minetest.get_node_timer(pos)
if sparktech.getoption(pos, name) then
timer:start(1.0)
else
timer:stop()
end
end
end,
_sparkoption = {
enabled = true,
acceptInput = true,
acceptRemoval = true
},
_sparkoutput = {
inputItems = function(nodepos)
local inventory = minetest.get_meta(nodepos):get_inventory()
return inventory:get_list("source")
end,
outputItems = function(nodepos)
local inventory = minetest.get_meta(nodepos):get_inventory()
return inventory:get_list("product")
end
},
_sparkoutputtype = {
inputItems = "InventoryList",
outputItems = "InventoryList"
}
})
minetest.register_craft({