further furnace logic
This commit is contained in:
parent
1be6d97c1a
commit
d8050b716a
@ -11,33 +11,78 @@ minetest.register_node(minetest.get_current_modname() .. ":lv_furnace", {
|
||||
paramtype2 = "facedir",
|
||||
groups = { sparktech_techy = 1,
|
||||
sparktech_energy_conductor = 1,
|
||||
sparktech_energy_in = 50,
|
||||
sparktech_energy_out = 10,
|
||||
sparktech_energy_nobalance = 1,
|
||||
sparktech_energy_max = 300},
|
||||
sparktech_energy_max = 300,
|
||||
spark_energy_timer = 2},
|
||||
|
||||
on_timer = mytime, -- add a mytimer function
|
||||
allow_metadata_inventory_take = allow_metadata_inventory_take,
|
||||
infotext = "Fuck off!",
|
||||
on_construct = function(pos, placer)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string(
|
||||
"formspec",
|
||||
"size[8,6]"..
|
||||
"list[current_name;ressources;0,0;2,1;]" ..
|
||||
"list[current_name;products;6,0;2,1;]" ..
|
||||
"list[current_name;source;0,0;2,1;]" ..
|
||||
"list[current_name;product;6,0;2,1;]" ..
|
||||
"list[current_player;main;0,2;8,1;]"..
|
||||
"list[current_player;main;0,3;8,3;8]")
|
||||
meta:set_string("infotext","Furnace") --FIXME: replace with debug stuff or something idk
|
||||
local inventory = meta:get_inventory()
|
||||
inventory:set_size('ressources',2)
|
||||
inventory:set_size('products',2)
|
||||
inventory:set_size('source',2)
|
||||
inventory:set_size('product',2)
|
||||
end,
|
||||
on_metadata_inventory_move = function(pos)
|
||||
on_metadata_inventory_move = function(pos) --TODO: test these
|
||||
local meta = minetest.get_meta(pos)
|
||||
if meta:get_int("energy") = 0 then return end
|
||||
minetest.get_node_timer(pos):start(1.0)
|
||||
end,
|
||||
on_metadata_inventory_put = function(pos)
|
||||
minetest.get_node_timer(pos):start(1.0)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if meta:get_int("energy") = 0 then return end
|
||||
local timer = minetest.get_node_timer(pos)
|
||||
timer:start(1.0)
|
||||
end,
|
||||
--on_timer = mytimer, -- add a mytimer function
|
||||
})
|
||||
|
||||
local function mytime(pos, elapsed)
|
||||
|
||||
local function storeprogress(progress) --store the progress of burning in the node meta, burning items aren't take from source, they simply cant be removed any longer when starting to burn
|
||||
for x=1,table_getn(progress),1
|
||||
do
|
||||
meta.get_string("cookprogess_" + i.progress[x])
|
||||
end
|
||||
end
|
||||
|
||||
local function allow_metadata_inventory_take(pos, listname, index, stack, player) --FIXME: this *schould* stop people from taking source stuff... but it doesn't!
|
||||
--local meta = minetest.get_meta(pos)
|
||||
if listname == "product" then
|
||||
return stack:get_count() --sure, take the stuff that the furnace has cooked for you :D
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
local function restoreprogress(meta,count)
|
||||
local progress = {}
|
||||
for x=1,count,1
|
||||
do
|
||||
progress[x] = meta.get_string("cookprogess_" + i)
|
||||
end
|
||||
return progress
|
||||
end
|
||||
|
||||
|
||||
local function mytime(pos, elapsed)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local energy = meta:get_int("energy")
|
||||
local inventory = meta:get_inventory()
|
||||
local source = inventory:get_list("source")
|
||||
local progress = restoreprogress(meta,table.getn(source))
|
||||
local product = inventory:get_list("product")
|
||||
|
||||
local newcycle = false -- this is false, if we feel that we need a new cycle we set this to true so that the furnace may cook again (e.g enough fuel and items are available)
|
||||
|
||||
--TODO: start cook logic (if there is any energy available start to cook (progress[inventoryslot]++ and commit to meta after all were processed
|
||||
|
||||
if (newcycle) then
|
||||
minetest.get_node_timer(pos):start(1.0)
|
||||
end
|
||||
return
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user