did some more stuff

This commit is contained in:
kamirama 2017-01-13 21:18:45 +01:00
parent d8050b716a
commit e28a75d2ee

View File

@ -1,48 +1,9 @@
minetest.register_node(minetest.get_current_modname() .. ":lv_furnace", {
description = "Electric furnace",
tiles = {
"furnace2.png",
"furnace2.png",
"furnace2.png",
"furnace2.png",
"furnace2.png",
"furnace.png"
},
paramtype2 = "facedir",
groups = { sparktech_techy = 1,
sparktech_energy_conductor = 1,
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;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('source',2)
inventory:set_size('product',2)
end,
on_metadata_inventory_move = function(pos) --TODO: test these
local function ongetitem(pos)
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)
local meta = minetest.get_meta(pos)
if meta:get_int("energy") = 0 then return end
if meta:get_int("energy") == 0 then return end
local timer = minetest.get_node_timer(pos)
timer:start(1.0)
end,
})
end
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
@ -51,24 +12,15 @@ local function storeprogress(progress) --store the progress of burning in the no
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)
progress[x] = meta:get_string("cookprogess_" .. x)
end
return progress
end
local function mytime(pos, elapsed)
local meta = minetest.get_meta(pos)
local energy = meta:get_int("energy")
@ -85,4 +37,58 @@ local function mytime(pos, elapsed)
minetest.get_node_timer(pos):start(1.0)
end
return
end
end
local function maytake()
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
local table = restoreprogress(meta,2)
if listname == "product" then
if table[pos] > 0 then
return (stack:get_count())
end
return stack:get_count()
end
end
minetest.register_node(minetest.get_current_modname() .. ":lv_furnace", {
description = "Electric furnace",
tiles = {
"furnace2.png",
"furnace2.png",
"furnace2.png",
"furnace2.png",
"furnace2.png",
"furnace.png"
},
paramtype2 = "facedir",
groups = { sparktech_techy = 1,
sparktech_energy_conductor = 1,
sparktech_energy_max = 300,
spark_energy_timer = 2},
on_timer = mytime, -- add a mytimer function
allow_metadata_inventory_take = maytake,
on_construct = function(pos, placer)
local meta = minetest.get_meta(pos)
meta:set_string(
"formspec",
"size[8,6]"..
"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]" ..
"bgcolor[#FC05E344;false]" ..
"listcolors[#fc059db0;#fc059dd0]")
local inventory = meta:get_inventory()
inventory:set_size('source',2)
inventory:set_size('product',2)
end,
on_metadata_inventory_move = ongetitem, --TODO: test these
on_metadata_inventory_put = ongetitem
})