Added super furnaces.
|
@ -8,41 +8,41 @@ local S = default.get_translator
|
|||
--
|
||||
|
||||
function default.get_furnace_active_formspec(fuel_percent, item_percent)
|
||||
return "size[8,8.5]"..
|
||||
"list[context;src;2.75,0.5;1,1;]"..
|
||||
"list[context;fuel;2.75,2.5;1,1;]"..
|
||||
"image[2.75,1.5;1,1;default_furnace_fire_bg.png^[lowpart:"..
|
||||
(fuel_percent)..":default_furnace_fire_fg.png]"..
|
||||
"image[3.75,1.5;1,1;gui_furnace_arrow_bg.png^[lowpart:"..
|
||||
(item_percent)..":gui_furnace_arrow_fg.png^[transformR270]"..
|
||||
"list[context;dst;4.75,0.96;2,2;]"..
|
||||
"list[current_player;main;0,4.25;8,1;]"..
|
||||
"list[current_player;main;0,5.5;8,3;8]"..
|
||||
"listring[context;dst]"..
|
||||
"listring[current_player;main]"..
|
||||
"listring[context;src]"..
|
||||
"listring[current_player;main]"..
|
||||
"listring[context;fuel]"..
|
||||
"listring[current_player;main]"..
|
||||
default.get_hotbar_bg(0, 4.25)
|
||||
return 'size[8,8.5]'..
|
||||
'list[context;src;2.75,0.5;1,1;]'..
|
||||
'list[context;fuel;2.75,2.5;1,1;]'..
|
||||
'image[2.75,1.5;1,1;default_furnace_fire_bg.png^[lowpart:'..
|
||||
(fuel_percent)..':default_furnace_fire_fg.png]'..
|
||||
'image[3.75,1.5;1,1;gui_furnace_arrow_bg.png^[lowpart:'..
|
||||
(item_percent)..':gui_furnace_arrow_fg.png^[transformR270]'..
|
||||
'list[context;dst;4.75,0.96;2,2;]'..
|
||||
'list[current_player;main;0,4.25;8,1;]'..
|
||||
'list[current_player;main;0,5.5;8,3;8]'..
|
||||
'listring[context;dst]'..
|
||||
'listring[current_player;main]'..
|
||||
'listring[context;src]'..
|
||||
'listring[current_player;main]'..
|
||||
'listring[context;fuel]'..
|
||||
'listring[current_player;main]'..
|
||||
default.get_hotbar_bg(0, 4.25)
|
||||
end
|
||||
|
||||
function default.get_furnace_inactive_formspec()
|
||||
return "size[8,8.5]"..
|
||||
"list[context;src;2.75,0.5;1,1;]"..
|
||||
"list[context;fuel;2.75,2.5;1,1;]"..
|
||||
"image[2.75,1.5;1,1;default_furnace_fire_bg.png]"..
|
||||
"image[3.75,1.5;1,1;gui_furnace_arrow_bg.png^[transformR270]"..
|
||||
"list[context;dst;4.75,0.96;2,2;]"..
|
||||
"list[current_player;main;0,4.25;8,1;]"..
|
||||
"list[current_player;main;0,5.5;8,3;8]"..
|
||||
"listring[context;dst]"..
|
||||
"listring[current_player;main]"..
|
||||
"listring[context;src]"..
|
||||
"listring[current_player;main]"..
|
||||
"listring[context;fuel]"..
|
||||
"listring[current_player;main]"..
|
||||
default.get_hotbar_bg(0, 4.25)
|
||||
return 'size[8,8.5]'..
|
||||
'list[context;src;2.75,0.5;1,1;]'..
|
||||
'list[context;fuel;2.75,2.5;1,1;]'..
|
||||
'image[2.75,1.5;1,1;default_furnace_fire_bg.png]'..
|
||||
'image[3.75,1.5;1,1;gui_furnace_arrow_bg.png^[transformR270]'..
|
||||
'list[context;dst;4.75,0.96;2,2;]'..
|
||||
'list[current_player;main;0,4.25;8,1;]'..
|
||||
'list[current_player;main;0,5.5;8,3;8]'..
|
||||
'listring[context;dst]'..
|
||||
'listring[current_player;main]'..
|
||||
'listring[context;src]'..
|
||||
'listring[current_player;main]'..
|
||||
'listring[context;fuel]'..
|
||||
'listring[current_player;main]'..
|
||||
default.get_hotbar_bg(0, 4.25)
|
||||
end
|
||||
|
||||
--
|
||||
|
@ -50,314 +50,399 @@ end
|
|||
--
|
||||
|
||||
local function can_dig(pos, player)
|
||||
local meta = minetest.get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
return inv:is_empty("fuel") and inv:is_empty("dst") and inv:is_empty("src")
|
||||
local meta = minetest.get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
return inv:is_empty('fuel') and inv:is_empty('dst') and inv:is_empty('src')
|
||||
end
|
||||
|
||||
function default.is_heat_shield(name)
|
||||
-- just an example, u can change it or expand and we need to be able to use hoppers :)
|
||||
if name=='darkage:tuff_bricks' or string.match(name,'hopper:') then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
function default.is_hot_node(name)
|
||||
if name=='default:lava_source' or name=='hopper:hopper' then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
local function param2_to_front(param2)
|
||||
if param2==0 then
|
||||
return {x=0,y=0,z=-1}
|
||||
elseif param2==1 then
|
||||
return {x=-1,y=0,z=0}
|
||||
elseif param2==2 then
|
||||
return {x=0,y=0,z=1}
|
||||
elseif param2==3 then
|
||||
return {x=1,y=0,z=0}
|
||||
end
|
||||
end
|
||||
|
||||
local function pos_equal(pos1,pos2) --idk why i need this function, but i do
|
||||
if pos1.x==pos2.x and pos1.y==pos2.y and pos1.z==pos2.z then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
local function allow_metadata_inventory_put(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 == "fuel" then
|
||||
if minetest.get_craft_result({method="fuel", width=1, items={stack}}).time ~= 0 then
|
||||
if inv:is_empty("src") then
|
||||
meta:set_string("infotext", S("Furnace is empty"))
|
||||
end
|
||||
return stack:get_count()
|
||||
else
|
||||
return 0
|
||||
end
|
||||
elseif listname == "src" then
|
||||
return stack:get_count()
|
||||
elseif listname == "dst" then
|
||||
return 0
|
||||
end
|
||||
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 == 'fuel' then
|
||||
if minetest.get_craft_result({method='fuel', width=1, items={stack}}).time ~= 0 then
|
||||
if inv:is_empty('src') then
|
||||
meta:set_string('infotext', S('Furnace is empty'))
|
||||
end
|
||||
return stack:get_count()
|
||||
else
|
||||
return 0
|
||||
end
|
||||
elseif listname == 'src' then
|
||||
return stack:get_count()
|
||||
elseif listname == 'dst' then
|
||||
return 0
|
||||
end
|
||||
end
|
||||
|
||||
function default.is_super_furnace(pos)--function to check if a furnace should smelt extra quickly
|
||||
local node = minetest.get_node(pos)
|
||||
if node.name~='default:furnace' and node.name~='default:furnace_active' then --not even a furnace
|
||||
return false
|
||||
end
|
||||
if node.param2 > 3 then --seriously? just have it face a reasonable direction people.
|
||||
return false
|
||||
end
|
||||
-- ok, so we check from pos + {x=1,y=1,z=1} to pos + {x=-1,y=-2,z=-1} for heat_shield
|
||||
-- except pos+{x=0,y=-1,z=0} has to be hot_node (lava, fire, etc.)
|
||||
-- and pos+param2_to_front(node.param2) has to be air
|
||||
local underpos = vector.add(pos,{x=0,y=-1,z=0})
|
||||
local frontpos = vector.add(pos,param2_to_front(node.param2))
|
||||
if not default.is_hot_node(minetest.get_node(underpos).name) then-- nothing to keep us extra hot.
|
||||
return false
|
||||
end
|
||||
if not minetest.get_node(frontpos).name=='air' then --we need somewhere to vent
|
||||
return false
|
||||
end
|
||||
local pos1 = {x=pos.x+1, y=pos.y, z=pos.z+1}
|
||||
local pos0 = {x=pos.x-1, y=pos.y-2, z=pos.z-1}
|
||||
local can_replace = minetest.find_nodes_in_area(pos0, pos1, 'default:lava_source')
|
||||
local replace_num = #can_replace
|
||||
if replace_num < 12 then
|
||||
return false
|
||||
end
|
||||
return true --yay! this furnace has succeded and can smelt extra quickly!
|
||||
end
|
||||
|
||||
local function allow_metadata_inventory_move(pos, from_list, from_index, to_list, to_index, count, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local stack = inv:get_stack(from_list, from_index)
|
||||
return allow_metadata_inventory_put(pos, to_list, to_index, stack, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local stack = inv:get_stack(from_list, from_index)
|
||||
return allow_metadata_inventory_put(pos, to_list, to_index, stack, player)
|
||||
end
|
||||
|
||||
local function allow_metadata_inventory_take(pos, listname, index, stack, player)
|
||||
if minetest.is_protected(pos, player:get_player_name()) then
|
||||
return 0
|
||||
end
|
||||
return stack:get_count()
|
||||
if minetest.is_protected(pos, player:get_player_name()) then
|
||||
return 0
|
||||
end
|
||||
return stack:get_count()
|
||||
end
|
||||
|
||||
local function swap_node(pos, name)
|
||||
local node = minetest.get_node(pos)
|
||||
if node.name == name then
|
||||
return
|
||||
end
|
||||
node.name = name
|
||||
minetest.swap_node(pos, node)
|
||||
local node = minetest.get_node(pos)
|
||||
if node.name == name then
|
||||
return
|
||||
end
|
||||
node.name = name
|
||||
minetest.swap_node(pos, node)
|
||||
end
|
||||
|
||||
local function custom_cooking_check(itemlist,pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local super_furnace = meta:get_string('super')
|
||||
local cooked,aftercooked
|
||||
cooked,aftercooked = minetest.get_craft_result({method = 'cooking', width = 1, items = itemlist})
|
||||
if super_furnace == 'yes' then
|
||||
cooked.time = cooked.time/2 --or whatever speed increase u think is reasonable.
|
||||
end
|
||||
return cooked,aftercooked
|
||||
end
|
||||
|
||||
local function furnace_node_timer(pos, elapsed)
|
||||
--
|
||||
-- Initialize metadata
|
||||
--
|
||||
local meta = minetest.get_meta(pos)
|
||||
local fuel_time = meta:get_float("fuel_time") or 0
|
||||
local src_time = meta:get_float("src_time") or 0
|
||||
local fuel_totaltime = meta:get_float("fuel_totaltime") or 0
|
||||
-- Initialize metadata
|
||||
--
|
||||
local meta = minetest.get_meta(pos)
|
||||
local fuel_time = meta:get_float('fuel_time') or 0
|
||||
local src_time = meta:get_float('src_time') or 0
|
||||
local fuel_totaltime = meta:get_float('fuel_totaltime') or 0
|
||||
local super_furnace = meta:get_string('super')
|
||||
if super_furnace == 'maybe' then
|
||||
if default.is_super_furnace(pos) then
|
||||
meta:set_string('super', 'yes')
|
||||
else
|
||||
meta:set_string('super', 'no')
|
||||
end
|
||||
end
|
||||
local inv = meta:get_inventory()
|
||||
local srclist, fuellist
|
||||
local dst_full = false
|
||||
|
||||
local inv = meta:get_inventory()
|
||||
local srclist, fuellist
|
||||
local dst_full = false
|
||||
local cookable, cooked
|
||||
local fuel
|
||||
|
||||
local cookable, cooked
|
||||
local fuel
|
||||
local update = true
|
||||
while elapsed > 0 and update do
|
||||
update = false
|
||||
srclist = inv:get_list('src')
|
||||
fuellist = inv:get_list('fuel')
|
||||
|
||||
local update = true
|
||||
while elapsed > 0 and update do
|
||||
update = false
|
||||
--
|
||||
-- Cooking
|
||||
--
|
||||
|
||||
srclist = inv:get_list("src")
|
||||
fuellist = inv:get_list("fuel")
|
||||
-- Check if we have cookable content
|
||||
local aftercooked
|
||||
cooked, aftercooked = custom_cooking_check(srclist,pos)
|
||||
cookable = cooked.time ~= 0
|
||||
|
||||
--
|
||||
-- Cooking
|
||||
--
|
||||
local el = math.min(elapsed, fuel_totaltime - fuel_time)
|
||||
if cookable then -- fuel lasts long enough, adjust el to cooking duration
|
||||
el = math.min(el, cooked.time - src_time)
|
||||
end
|
||||
|
||||
-- Check if we have cookable content
|
||||
local aftercooked
|
||||
cooked, aftercooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist})
|
||||
cookable = cooked.time ~= 0
|
||||
-- Check if we have enough fuel to burn
|
||||
if fuel_time < fuel_totaltime then
|
||||
-- The furnace is currently active and has enough fuel
|
||||
fuel_time = fuel_time + el
|
||||
-- If there is a cookable item then check if it is ready yet
|
||||
if cookable then
|
||||
src_time = src_time + el
|
||||
if src_time >= cooked.time then
|
||||
-- Place result in dst list if possible
|
||||
if inv:room_for_item('dst', cooked.item) then
|
||||
inv:add_item('dst', cooked.item)
|
||||
inv:set_stack('src', 1, aftercooked.items[1])
|
||||
src_time = src_time - cooked.time
|
||||
update = true
|
||||
else
|
||||
dst_full = true
|
||||
end
|
||||
else
|
||||
-- Item could not be cooked: probably missing fuel
|
||||
update = true
|
||||
end
|
||||
end
|
||||
else
|
||||
-- Furnace ran out of fuel
|
||||
if cookable then
|
||||
-- We need to get new fuel
|
||||
local afterfuel
|
||||
fuel, afterfuel = minetest.get_craft_result({method = 'fuel', width = 1, items = fuellist})
|
||||
|
||||
local el = math.min(elapsed, fuel_totaltime - fuel_time)
|
||||
if cookable then -- fuel lasts long enough, adjust el to cooking duration
|
||||
el = math.min(el, cooked.time - src_time)
|
||||
end
|
||||
if fuel.time == 0 then
|
||||
-- No valid fuel in fuel list
|
||||
fuel_totaltime = 0
|
||||
src_time = 0
|
||||
else
|
||||
-- Take fuel from fuel list
|
||||
inv:set_stack('fuel', 1, afterfuel.items[1])
|
||||
-- Put replacements in dst list or drop them on the furnace.
|
||||
local replacements = fuel.replacements
|
||||
if replacements[1] then
|
||||
local leftover = inv:add_item('dst', replacements[1])
|
||||
if not leftover:is_empty() then
|
||||
local above = vector.new(pos.x, pos.y + 1, pos.z)
|
||||
local drop_pos = minetest.find_node_near(above, 1, {'air'}) or above
|
||||
minetest.item_drop(replacements[1], nil, drop_pos)
|
||||
end
|
||||
end
|
||||
update = true
|
||||
fuel_totaltime = fuel.time + (fuel_totaltime - fuel_time)
|
||||
end
|
||||
else
|
||||
-- We don't need to get new fuel since there is no cookable item
|
||||
fuel_totaltime = 0
|
||||
src_time = 0
|
||||
end
|
||||
fuel_time = 0
|
||||
end
|
||||
|
||||
-- Check if we have enough fuel to burn
|
||||
if fuel_time < fuel_totaltime then
|
||||
-- The furnace is currently active and has enough fuel
|
||||
fuel_time = fuel_time + el
|
||||
-- If there is a cookable item then check if it is ready yet
|
||||
if cookable then
|
||||
src_time = src_time + el
|
||||
if src_time >= cooked.time then
|
||||
-- Place result in dst list if possible
|
||||
if inv:room_for_item("dst", cooked.item) then
|
||||
inv:add_item("dst", cooked.item)
|
||||
inv:set_stack("src", 1, aftercooked.items[1])
|
||||
src_time = src_time - cooked.time
|
||||
update = true
|
||||
else
|
||||
dst_full = true
|
||||
end
|
||||
else
|
||||
-- Item could not be cooked: probably missing fuel
|
||||
update = true
|
||||
end
|
||||
end
|
||||
else
|
||||
-- Furnace ran out of fuel
|
||||
if cookable then
|
||||
-- We need to get new fuel
|
||||
local afterfuel
|
||||
fuel, afterfuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist})
|
||||
elapsed = elapsed - el
|
||||
end
|
||||
|
||||
if fuel.time == 0 then
|
||||
-- No valid fuel in fuel list
|
||||
fuel_totaltime = 0
|
||||
src_time = 0
|
||||
else
|
||||
-- Take fuel from fuel list
|
||||
inv:set_stack("fuel", 1, afterfuel.items[1])
|
||||
-- Put replacements in dst list or drop them on the furnace.
|
||||
local replacements = fuel.replacements
|
||||
if replacements[1] then
|
||||
local leftover = inv:add_item("dst", replacements[1])
|
||||
if not leftover:is_empty() then
|
||||
local above = vector.new(pos.x, pos.y + 1, pos.z)
|
||||
local drop_pos = minetest.find_node_near(above, 1, {"air"}) or above
|
||||
minetest.item_drop(replacements[1], nil, drop_pos)
|
||||
end
|
||||
end
|
||||
update = true
|
||||
fuel_totaltime = fuel.time + (fuel_totaltime - fuel_time)
|
||||
end
|
||||
else
|
||||
-- We don't need to get new fuel since there is no cookable item
|
||||
fuel_totaltime = 0
|
||||
src_time = 0
|
||||
end
|
||||
fuel_time = 0
|
||||
end
|
||||
if fuel and fuel_totaltime > fuel.time then
|
||||
fuel_totaltime = fuel.time
|
||||
end
|
||||
if srclist and srclist[1]:is_empty() then
|
||||
src_time = 0
|
||||
end
|
||||
--
|
||||
-- Update formspec, infotext and node
|
||||
--
|
||||
local formspec
|
||||
local item_state
|
||||
local item_percent = 0
|
||||
if cookable then
|
||||
item_percent = math.floor(src_time / cooked.time * 100)
|
||||
if dst_full then
|
||||
item_state = S('100% (output full)')
|
||||
else
|
||||
item_state = S('@1%', item_percent)
|
||||
end
|
||||
else
|
||||
if srclist and not srclist[1]:is_empty() then
|
||||
item_state = S('Not cookable')
|
||||
else
|
||||
item_state = S('Empty')
|
||||
end
|
||||
end
|
||||
|
||||
elapsed = elapsed - el
|
||||
end
|
||||
local fuel_state = S('Empty')
|
||||
local active = false
|
||||
local result = false
|
||||
|
||||
if fuel and fuel_totaltime > fuel.time then
|
||||
fuel_totaltime = fuel.time
|
||||
end
|
||||
if srclist and srclist[1]:is_empty() then
|
||||
src_time = 0
|
||||
end
|
||||
if fuel_totaltime ~= 0 then
|
||||
active = true
|
||||
local fuel_percent = 100 - math.floor(fuel_time / fuel_totaltime * 100)
|
||||
fuel_state = S('@1%', fuel_percent)
|
||||
formspec = default.get_furnace_active_formspec(fuel_percent, item_percent)
|
||||
swap_node(pos, 'default:furnace_active')
|
||||
-- make sure timer restarts automatically
|
||||
result = true
|
||||
else
|
||||
if fuellist and not fuellist[1]:is_empty() then
|
||||
fuel_state = S('@1%', 0)
|
||||
end
|
||||
formspec = default.get_furnace_inactive_formspec()
|
||||
swap_node(pos, 'default:furnace')
|
||||
-- stop timer on the inactive furnace
|
||||
minetest.get_node_timer(pos):stop()
|
||||
meta:set_string('super', 'maybe')
|
||||
end
|
||||
local infotext
|
||||
if active then
|
||||
infotext = S('Furnace active')
|
||||
else
|
||||
infotext = S('Furnace inactive')
|
||||
end
|
||||
infotext = infotext .. '\n' .. S('(Item: @1; Fuel: @2)', item_state, fuel_state)
|
||||
|
||||
--
|
||||
-- Update formspec, infotext and node
|
||||
--
|
||||
local formspec
|
||||
local item_state
|
||||
local item_percent = 0
|
||||
if cookable then
|
||||
item_percent = math.floor(src_time / cooked.time * 100)
|
||||
if dst_full then
|
||||
item_state = S("100% (output full)")
|
||||
else
|
||||
item_state = S("@1%", item_percent)
|
||||
end
|
||||
else
|
||||
if srclist and not srclist[1]:is_empty() then
|
||||
item_state = S("Not cookable")
|
||||
else
|
||||
item_state = S("Empty")
|
||||
end
|
||||
end
|
||||
--
|
||||
-- Set meta values
|
||||
--
|
||||
meta:set_float('fuel_totaltime', fuel_totaltime)
|
||||
meta:set_float('fuel_time', fuel_time)
|
||||
meta:set_float('src_time', src_time)
|
||||
meta:set_string('formspec', formspec)
|
||||
meta:set_string('infotext', infotext)
|
||||
|
||||
local fuel_state = S("Empty")
|
||||
local active = false
|
||||
local result = false
|
||||
|
||||
if fuel_totaltime ~= 0 then
|
||||
active = true
|
||||
local fuel_percent = 100 - math.floor(fuel_time / fuel_totaltime * 100)
|
||||
fuel_state = S("@1%", fuel_percent)
|
||||
formspec = default.get_furnace_active_formspec(fuel_percent, item_percent)
|
||||
swap_node(pos, "default:furnace_active")
|
||||
-- make sure timer restarts automatically
|
||||
result = true
|
||||
else
|
||||
if fuellist and not fuellist[1]:is_empty() then
|
||||
fuel_state = S("@1%", 0)
|
||||
end
|
||||
formspec = default.get_furnace_inactive_formspec()
|
||||
swap_node(pos, "default:furnace")
|
||||
-- stop timer on the inactive furnace
|
||||
minetest.get_node_timer(pos):stop()
|
||||
end
|
||||
|
||||
|
||||
local infotext
|
||||
if active then
|
||||
infotext = S("Furnace active")
|
||||
else
|
||||
infotext = S("Furnace inactive")
|
||||
end
|
||||
infotext = infotext .. "\n" .. S("(Item: @1; Fuel: @2)", item_state, fuel_state)
|
||||
|
||||
--
|
||||
-- Set meta values
|
||||
--
|
||||
meta:set_float("fuel_totaltime", fuel_totaltime)
|
||||
meta:set_float("fuel_time", fuel_time)
|
||||
meta:set_float("src_time", src_time)
|
||||
meta:set_string("formspec", formspec)
|
||||
meta:set_string("infotext", infotext)
|
||||
|
||||
return result
|
||||
return result
|
||||
end
|
||||
|
||||
--added by idiot12 from here
|
||||
|
||||
|
||||
--
|
||||
-- Node definitions
|
||||
--
|
||||
|
||||
minetest.register_node("default:furnace", {
|
||||
description = S("Furnace"),
|
||||
tiles = {
|
||||
"default_furnace_top.png", "default_furnace_bottom.png",
|
||||
"default_furnace_side.png", "default_furnace_side.png",
|
||||
"default_furnace_side.png", "default_furnace_front.png"
|
||||
},
|
||||
paramtype2 = "facedir",
|
||||
groups = {cracky=2},
|
||||
legacy_facedir_simple = true,
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
minetest.register_node('default:furnace', {
|
||||
description = S('Furnace'),
|
||||
tiles = {
|
||||
'default_furnace_top.png', 'default_furnace_bottom.png',
|
||||
'default_furnace_side.png', 'default_furnace_side.png',
|
||||
'default_furnace_side.png', 'default_furnace_front.png'
|
||||
},
|
||||
paramtype2 = 'facedir',
|
||||
groups = {cracky=2},
|
||||
legacy_facedir_simple = true,
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
|
||||
can_dig = can_dig,
|
||||
can_dig = can_dig,
|
||||
|
||||
on_timer = furnace_node_timer,
|
||||
on_timer = furnace_node_timer,
|
||||
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size('src', 1)
|
||||
inv:set_size('fuel', 1)
|
||||
inv:set_size('dst', 4)
|
||||
furnace_node_timer(pos, 0)
|
||||
end,
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string('super', 'maybe')
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size('src', 1)
|
||||
inv:set_size('fuel', 1)
|
||||
inv:set_size('dst', 4)
|
||||
furnace_node_timer(pos, 0)
|
||||
end,
|
||||
|
||||
on_metadata_inventory_move = function(pos)
|
||||
minetest.get_node_timer(pos):start(1.0)
|
||||
end,
|
||||
on_metadata_inventory_put = function(pos)
|
||||
-- start timer function, it will sort out whether furnace can burn or not.
|
||||
minetest.get_node_timer(pos):start(1.0)
|
||||
end,
|
||||
on_blast = function(pos)
|
||||
local drops = {}
|
||||
default.get_inventory_drops(pos, "src", drops)
|
||||
default.get_inventory_drops(pos, "fuel", drops)
|
||||
default.get_inventory_drops(pos, "dst", drops)
|
||||
drops[#drops+1] = "default:furnace"
|
||||
minetest.remove_node(pos)
|
||||
return drops
|
||||
end,
|
||||
on_metadata_inventory_move = function(pos)
|
||||
minetest.get_node_timer(pos):start(1.0)
|
||||
end,
|
||||
on_metadata_inventory_put = function(pos)
|
||||
-- start timer function, it will sort out whether furnace can burn or not.
|
||||
minetest.get_node_timer(pos):start(1.0)
|
||||
|
||||
allow_metadata_inventory_put = allow_metadata_inventory_put,
|
||||
allow_metadata_inventory_move = allow_metadata_inventory_move,
|
||||
allow_metadata_inventory_take = allow_metadata_inventory_take,
|
||||
end,
|
||||
on_blast = function(pos)
|
||||
local drops = {}
|
||||
default.get_inventory_drops(pos, 'src', drops)
|
||||
default.get_inventory_drops(pos, 'fuel', drops)
|
||||
default.get_inventory_drops(pos, 'dst', drops)
|
||||
drops[#drops+1] = 'default:furnace'
|
||||
minetest.remove_node(pos)
|
||||
return drops
|
||||
end,
|
||||
|
||||
allow_metadata_inventory_put = allow_metadata_inventory_put,
|
||||
allow_metadata_inventory_move = allow_metadata_inventory_move,
|
||||
allow_metadata_inventory_take = allow_metadata_inventory_take,
|
||||
})
|
||||
|
||||
minetest.register_node("default:furnace_active", {
|
||||
description = S("Furnace"),
|
||||
tiles = {
|
||||
"default_furnace_top.png", "default_furnace_bottom.png",
|
||||
"default_furnace_side.png", "default_furnace_side.png",
|
||||
"default_furnace_side.png",
|
||||
{
|
||||
image = "default_furnace_front_active.png",
|
||||
backface_culling = false,
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 16,
|
||||
aspect_h = 16,
|
||||
length = 1.5
|
||||
},
|
||||
}
|
||||
},
|
||||
paramtype2 = "facedir",
|
||||
light_source = 8,
|
||||
drop = "default:furnace",
|
||||
groups = {cracky=2, not_in_creative_inventory=1},
|
||||
legacy_facedir_simple = true,
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
on_timer = furnace_node_timer,
|
||||
minetest.register_node('default:furnace_active', {
|
||||
description = S('Furnace'),
|
||||
tiles = {
|
||||
'default_furnace_top.png', 'default_furnace_bottom.png',
|
||||
'default_furnace_side.png', 'default_furnace_side.png',
|
||||
'default_furnace_side.png',
|
||||
{
|
||||
image = 'default_furnace_front_active.png',
|
||||
backface_culling = false,
|
||||
animation = {
|
||||
type = 'vertical_frames',
|
||||
aspect_w = 16,
|
||||
aspect_h = 16,
|
||||
length = 1.5
|
||||
},
|
||||
}
|
||||
},
|
||||
paramtype2 = 'facedir',
|
||||
light_source = 8,
|
||||
drop = 'default:furnace',
|
||||
groups = {cracky=2, not_in_creative_inventory=1},
|
||||
legacy_facedir_simple = true,
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
on_timer = furnace_node_timer,
|
||||
|
||||
can_dig = can_dig,
|
||||
can_dig = can_dig,
|
||||
|
||||
allow_metadata_inventory_put = allow_metadata_inventory_put,
|
||||
allow_metadata_inventory_move = allow_metadata_inventory_move,
|
||||
allow_metadata_inventory_take = allow_metadata_inventory_take,
|
||||
allow_metadata_inventory_put = allow_metadata_inventory_put,
|
||||
allow_metadata_inventory_move = allow_metadata_inventory_move,
|
||||
allow_metadata_inventory_take = allow_metadata_inventory_take,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "default:furnace",
|
||||
recipe = {
|
||||
{"group:stone", "group:stone", "group:stone"},
|
||||
{"group:stone", "", "group:stone"},
|
||||
{"group:stone", "group:stone", "group:stone"},
|
||||
}
|
||||
output = 'default:furnace',
|
||||
recipe = {
|
||||
{'group:stone', 'group:stone', 'group:stone'},
|
||||
{'group:stone', '', 'group:stone'},
|
||||
{'group:stone', 'group:stone', 'group:stone'},
|
||||
}
|
||||
})
|
||||
|
|
|
@ -0,0 +1,363 @@
|
|||
-- default/furnace.lua
|
||||
|
||||
-- support for MT game translation.
|
||||
local S = default.get_translator
|
||||
|
||||
--
|
||||
-- Formspecs
|
||||
--
|
||||
|
||||
function default.get_furnace_active_formspec(fuel_percent, item_percent)
|
||||
return "size[8,8.5]"..
|
||||
"list[context;src;2.75,0.5;1,1;]"..
|
||||
"list[context;fuel;2.75,2.5;1,1;]"..
|
||||
"image[2.75,1.5;1,1;default_furnace_fire_bg.png^[lowpart:"..
|
||||
(fuel_percent)..":default_furnace_fire_fg.png]"..
|
||||
"image[3.75,1.5;1,1;gui_furnace_arrow_bg.png^[lowpart:"..
|
||||
(item_percent)..":gui_furnace_arrow_fg.png^[transformR270]"..
|
||||
"list[context;dst;4.75,0.96;2,2;]"..
|
||||
"list[current_player;main;0,4.25;8,1;]"..
|
||||
"list[current_player;main;0,5.5;8,3;8]"..
|
||||
"listring[context;dst]"..
|
||||
"listring[current_player;main]"..
|
||||
"listring[context;src]"..
|
||||
"listring[current_player;main]"..
|
||||
"listring[context;fuel]"..
|
||||
"listring[current_player;main]"..
|
||||
default.get_hotbar_bg(0, 4.25)
|
||||
end
|
||||
|
||||
function default.get_furnace_inactive_formspec()
|
||||
return "size[8,8.5]"..
|
||||
"list[context;src;2.75,0.5;1,1;]"..
|
||||
"list[context;fuel;2.75,2.5;1,1;]"..
|
||||
"image[2.75,1.5;1,1;default_furnace_fire_bg.png]"..
|
||||
"image[3.75,1.5;1,1;gui_furnace_arrow_bg.png^[transformR270]"..
|
||||
"list[context;dst;4.75,0.96;2,2;]"..
|
||||
"list[current_player;main;0,4.25;8,1;]"..
|
||||
"list[current_player;main;0,5.5;8,3;8]"..
|
||||
"listring[context;dst]"..
|
||||
"listring[current_player;main]"..
|
||||
"listring[context;src]"..
|
||||
"listring[current_player;main]"..
|
||||
"listring[context;fuel]"..
|
||||
"listring[current_player;main]"..
|
||||
default.get_hotbar_bg(0, 4.25)
|
||||
end
|
||||
|
||||
--
|
||||
-- Node callback functions that are the same for active and inactive furnace
|
||||
--
|
||||
|
||||
local function can_dig(pos, player)
|
||||
local meta = minetest.get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
return inv:is_empty("fuel") and inv:is_empty("dst") and inv:is_empty("src")
|
||||
end
|
||||
|
||||
local function allow_metadata_inventory_put(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 == "fuel" then
|
||||
if minetest.get_craft_result({method="fuel", width=1, items={stack}}).time ~= 0 then
|
||||
if inv:is_empty("src") then
|
||||
meta:set_string("infotext", S("Furnace is empty"))
|
||||
end
|
||||
return stack:get_count()
|
||||
else
|
||||
return 0
|
||||
end
|
||||
elseif listname == "src" then
|
||||
return stack:get_count()
|
||||
elseif listname == "dst" then
|
||||
return 0
|
||||
end
|
||||
end
|
||||
|
||||
local function allow_metadata_inventory_move(pos, from_list, from_index, to_list, to_index, count, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local stack = inv:get_stack(from_list, from_index)
|
||||
return allow_metadata_inventory_put(pos, to_list, to_index, stack, player)
|
||||
end
|
||||
|
||||
local function allow_metadata_inventory_take(pos, listname, index, stack, player)
|
||||
if minetest.is_protected(pos, player:get_player_name()) then
|
||||
return 0
|
||||
end
|
||||
return stack:get_count()
|
||||
end
|
||||
|
||||
local function swap_node(pos, name)
|
||||
local node = minetest.get_node(pos)
|
||||
if node.name == name then
|
||||
return
|
||||
end
|
||||
node.name = name
|
||||
minetest.swap_node(pos, node)
|
||||
end
|
||||
|
||||
local function furnace_node_timer(pos, elapsed)
|
||||
--
|
||||
-- Initialize metadata
|
||||
--
|
||||
local meta = minetest.get_meta(pos)
|
||||
local fuel_time = meta:get_float("fuel_time") or 0
|
||||
local src_time = meta:get_float("src_time") or 0
|
||||
local fuel_totaltime = meta:get_float("fuel_totaltime") or 0
|
||||
|
||||
local inv = meta:get_inventory()
|
||||
local srclist, fuellist
|
||||
local dst_full = false
|
||||
|
||||
local cookable, cooked
|
||||
local fuel
|
||||
|
||||
local update = true
|
||||
while elapsed > 0 and update do
|
||||
update = false
|
||||
|
||||
srclist = inv:get_list("src")
|
||||
fuellist = inv:get_list("fuel")
|
||||
|
||||
--
|
||||
-- Cooking
|
||||
--
|
||||
|
||||
-- Check if we have cookable content
|
||||
local aftercooked
|
||||
cooked, aftercooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist})
|
||||
cookable = cooked.time ~= 0
|
||||
|
||||
local el = math.min(elapsed, fuel_totaltime - fuel_time)
|
||||
if cookable then -- fuel lasts long enough, adjust el to cooking duration
|
||||
el = math.min(el, cooked.time - src_time)
|
||||
end
|
||||
|
||||
-- Check if we have enough fuel to burn
|
||||
if fuel_time < fuel_totaltime then
|
||||
-- The furnace is currently active and has enough fuel
|
||||
fuel_time = fuel_time + el
|
||||
-- If there is a cookable item then check if it is ready yet
|
||||
if cookable then
|
||||
src_time = src_time + el
|
||||
if src_time >= cooked.time then
|
||||
-- Place result in dst list if possible
|
||||
if inv:room_for_item("dst", cooked.item) then
|
||||
inv:add_item("dst", cooked.item)
|
||||
inv:set_stack("src", 1, aftercooked.items[1])
|
||||
src_time = src_time - cooked.time
|
||||
update = true
|
||||
else
|
||||
dst_full = true
|
||||
end
|
||||
else
|
||||
-- Item could not be cooked: probably missing fuel
|
||||
update = true
|
||||
end
|
||||
end
|
||||
else
|
||||
-- Furnace ran out of fuel
|
||||
if cookable then
|
||||
-- We need to get new fuel
|
||||
local afterfuel
|
||||
fuel, afterfuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist})
|
||||
|
||||
if fuel.time == 0 then
|
||||
-- No valid fuel in fuel list
|
||||
fuel_totaltime = 0
|
||||
src_time = 0
|
||||
else
|
||||
-- Take fuel from fuel list
|
||||
inv:set_stack("fuel", 1, afterfuel.items[1])
|
||||
-- Put replacements in dst list or drop them on the furnace.
|
||||
local replacements = fuel.replacements
|
||||
if replacements[1] then
|
||||
local leftover = inv:add_item("dst", replacements[1])
|
||||
if not leftover:is_empty() then
|
||||
local above = vector.new(pos.x, pos.y + 1, pos.z)
|
||||
local drop_pos = minetest.find_node_near(above, 1, {"air"}) or above
|
||||
minetest.item_drop(replacements[1], nil, drop_pos)
|
||||
end
|
||||
end
|
||||
update = true
|
||||
fuel_totaltime = fuel.time + (fuel_totaltime - fuel_time)
|
||||
end
|
||||
else
|
||||
-- We don't need to get new fuel since there is no cookable item
|
||||
fuel_totaltime = 0
|
||||
src_time = 0
|
||||
end
|
||||
fuel_time = 0
|
||||
end
|
||||
|
||||
elapsed = elapsed - el
|
||||
end
|
||||
|
||||
if fuel and fuel_totaltime > fuel.time then
|
||||
fuel_totaltime = fuel.time
|
||||
end
|
||||
if srclist and srclist[1]:is_empty() then
|
||||
src_time = 0
|
||||
end
|
||||
|
||||
--
|
||||
-- Update formspec, infotext and node
|
||||
--
|
||||
local formspec
|
||||
local item_state
|
||||
local item_percent = 0
|
||||
if cookable then
|
||||
item_percent = math.floor(src_time / cooked.time * 100)
|
||||
if dst_full then
|
||||
item_state = S("100% (output full)")
|
||||
else
|
||||
item_state = S("@1%", item_percent)
|
||||
end
|
||||
else
|
||||
if srclist and not srclist[1]:is_empty() then
|
||||
item_state = S("Not cookable")
|
||||
else
|
||||
item_state = S("Empty")
|
||||
end
|
||||
end
|
||||
|
||||
local fuel_state = S("Empty")
|
||||
local active = false
|
||||
local result = false
|
||||
|
||||
if fuel_totaltime ~= 0 then
|
||||
active = true
|
||||
local fuel_percent = 100 - math.floor(fuel_time / fuel_totaltime * 100)
|
||||
fuel_state = S("@1%", fuel_percent)
|
||||
formspec = default.get_furnace_active_formspec(fuel_percent, item_percent)
|
||||
swap_node(pos, "default:furnace_active")
|
||||
-- make sure timer restarts automatically
|
||||
result = true
|
||||
else
|
||||
if fuellist and not fuellist[1]:is_empty() then
|
||||
fuel_state = S("@1%", 0)
|
||||
end
|
||||
formspec = default.get_furnace_inactive_formspec()
|
||||
swap_node(pos, "default:furnace")
|
||||
-- stop timer on the inactive furnace
|
||||
minetest.get_node_timer(pos):stop()
|
||||
end
|
||||
|
||||
|
||||
local infotext
|
||||
if active then
|
||||
infotext = S("Furnace active")
|
||||
else
|
||||
infotext = S("Furnace inactive")
|
||||
end
|
||||
infotext = infotext .. "\n" .. S("(Item: @1; Fuel: @2)", item_state, fuel_state)
|
||||
|
||||
--
|
||||
-- Set meta values
|
||||
--
|
||||
meta:set_float("fuel_totaltime", fuel_totaltime)
|
||||
meta:set_float("fuel_time", fuel_time)
|
||||
meta:set_float("src_time", src_time)
|
||||
meta:set_string("formspec", formspec)
|
||||
meta:set_string("infotext", infotext)
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
--
|
||||
-- Node definitions
|
||||
--
|
||||
|
||||
minetest.register_node("default:furnace", {
|
||||
description = S("Furnace"),
|
||||
tiles = {
|
||||
"default_furnace_top.png", "default_furnace_bottom.png",
|
||||
"default_furnace_side.png", "default_furnace_side.png",
|
||||
"default_furnace_side.png", "default_furnace_front.png"
|
||||
},
|
||||
paramtype2 = "facedir",
|
||||
groups = {cracky=2},
|
||||
legacy_facedir_simple = true,
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
|
||||
can_dig = can_dig,
|
||||
|
||||
on_timer = furnace_node_timer,
|
||||
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size('src', 1)
|
||||
inv:set_size('fuel', 1)
|
||||
inv:set_size('dst', 4)
|
||||
furnace_node_timer(pos, 0)
|
||||
end,
|
||||
|
||||
on_metadata_inventory_move = function(pos)
|
||||
minetest.get_node_timer(pos):start(1.0)
|
||||
end,
|
||||
on_metadata_inventory_put = function(pos)
|
||||
-- start timer function, it will sort out whether furnace can burn or not.
|
||||
minetest.get_node_timer(pos):start(1.0)
|
||||
end,
|
||||
on_blast = function(pos)
|
||||
local drops = {}
|
||||
default.get_inventory_drops(pos, "src", drops)
|
||||
default.get_inventory_drops(pos, "fuel", drops)
|
||||
default.get_inventory_drops(pos, "dst", drops)
|
||||
drops[#drops+1] = "default:furnace"
|
||||
minetest.remove_node(pos)
|
||||
return drops
|
||||
end,
|
||||
|
||||
allow_metadata_inventory_put = allow_metadata_inventory_put,
|
||||
allow_metadata_inventory_move = allow_metadata_inventory_move,
|
||||
allow_metadata_inventory_take = allow_metadata_inventory_take,
|
||||
})
|
||||
|
||||
minetest.register_node("default:furnace_active", {
|
||||
description = S("Furnace"),
|
||||
tiles = {
|
||||
"default_furnace_top.png", "default_furnace_bottom.png",
|
||||
"default_furnace_side.png", "default_furnace_side.png",
|
||||
"default_furnace_side.png",
|
||||
{
|
||||
image = "default_furnace_front_active.png",
|
||||
backface_culling = false,
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 16,
|
||||
aspect_h = 16,
|
||||
length = 1.5
|
||||
},
|
||||
}
|
||||
},
|
||||
paramtype2 = "facedir",
|
||||
light_source = 8,
|
||||
drop = "default:furnace",
|
||||
groups = {cracky=2, not_in_creative_inventory=1},
|
||||
legacy_facedir_simple = true,
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
on_timer = furnace_node_timer,
|
||||
|
||||
can_dig = can_dig,
|
||||
|
||||
allow_metadata_inventory_put = allow_metadata_inventory_put,
|
||||
allow_metadata_inventory_move = allow_metadata_inventory_move,
|
||||
allow_metadata_inventory_take = allow_metadata_inventory_take,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "default:furnace",
|
||||
recipe = {
|
||||
{"group:stone", "group:stone", "group:stone"},
|
||||
{"group:stone", "", "group:stone"},
|
||||
{"group:stone", "group:stone", "group:stone"},
|
||||
}
|
||||
})
|
|
@ -6,14 +6,29 @@
|
|||
|
||||
local S = farming.intllib
|
||||
|
||||
-- corn seeds
|
||||
minetest.register_node("farming:seed_corn", {
|
||||
description = S("Corn Kernel"),
|
||||
tiles = {"farming_corn_seed.png"},
|
||||
inventory_image = "farming_corn_seed.png",
|
||||
wield_image = "farming_corn_seed.png",
|
||||
drawtype = "signlike",
|
||||
groups = {seed = 1, snappy = 3, attached_node = 1},
|
||||
paramtype = "light",
|
||||
paramtype2 = "wallmounted",
|
||||
walkable = false,
|
||||
sunlight_propagates = true,
|
||||
selection_box = farming.select,
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
return farming.place_seed(itemstack, placer, pointed_thing, "farming:corn_1")
|
||||
end,
|
||||
})
|
||||
|
||||
-- corn
|
||||
minetest.register_craftitem("farming:corn", {
|
||||
description = S("Corn"),
|
||||
inventory_image = "farming_corn.png",
|
||||
groups = {seed = 2, food_corn = 1, flammable = 2},
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
return farming.place_seed(itemstack, placer, pointed_thing, "farming:corn_1")
|
||||
end,
|
||||
on_use = minetest.item_eat(3),
|
||||
})
|
||||
|
||||
|
@ -132,6 +147,7 @@ crop_def.drop = {
|
|||
{items = {"farming:corn"}, rarity = 1},
|
||||
{items = {"farming:corn"}, rarity = 2},
|
||||
{items = {"farming:corn"}, rarity = 3},
|
||||
{items = {"farming:seed_corn"}, rarity = 2},
|
||||
}
|
||||
}
|
||||
minetest.register_node("farming:corn_7", table.copy(crop_def))
|
||||
|
@ -144,6 +160,8 @@ crop_def.drop = {
|
|||
{items = {"farming:corn 2"}, rarity = 1},
|
||||
{items = {"farming:corn 2"}, rarity = 2},
|
||||
{items = {"farming:corn 2"}, rarity = 2},
|
||||
{items = {"farming:seed_corn"}, rarity = 1},
|
||||
{items = {"farming:seed_corn"}, rarity = 2}
|
||||
}
|
||||
}
|
||||
minetest.register_node("farming:corn_8", table.copy(crop_def))
|
||||
|
@ -151,7 +169,7 @@ minetest.register_node("farming:corn_8", table.copy(crop_def))
|
|||
-- add to registered_plants
|
||||
farming.registered_plants["farming:corn"] = {
|
||||
crop = "farming:corn",
|
||||
seed = "farming:corn",
|
||||
seed = "farming:seed_corn",
|
||||
minlight = 13,
|
||||
maxlight = 15,
|
||||
steps = 8
|
||||
|
|
|
@ -34,7 +34,7 @@ minetest.override_item("farming:oat", {
|
|||
-- Rice
|
||||
|
||||
farming.register_plant("farming:rice", {
|
||||
description = "Rice grains",
|
||||
description = "Rice seed",
|
||||
paramtype2 = "meshoptions",
|
||||
inventory_image = "farming_rice_seed.png",
|
||||
steps = 8,
|
||||
|
@ -58,13 +58,6 @@ minetest.register_craftitem("farming:rice_flour", {
|
|||
groups = {food_rice_flour = 1, flammable = 1},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
cooktime = 15,
|
||||
output = "farming:rice_bread",
|
||||
recipe = "farming:rice_flour"
|
||||
})
|
||||
|
||||
-- Multigrain flour
|
||||
|
||||
minetest.register_craftitem("farming:flour_multigrain", {
|
||||
|
@ -81,42 +74,3 @@ minetest.register_craftitem("farming:bread_multigrain", {
|
|||
on_use = minetest.item_eat(7),
|
||||
groups = {food_bread = 1, flammable = 2},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
cooktime = 15,
|
||||
output = "farming:bread_multigrain",
|
||||
recipe = "farming:flour_multigrain"
|
||||
})
|
||||
|
||||
-- Fuels
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "farming:rice_bread",
|
||||
burntime = 1,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "farming:bread_multigrain",
|
||||
burntime = 1,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "farming:rye",
|
||||
burntime = 1,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "farming:oat",
|
||||
burntime = 1,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "farming:rice",
|
||||
burntime = 1,
|
||||
})
|
||||
|
|
Before Width: | Height: | Size: 145 B After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 201 B After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 142 B After Width: | Height: | Size: 2.1 KiB |
|
@ -15,3 +15,39 @@ minetest.register_node('shapes:gold_triangle_0', {
|
|||
fixed = {-.5, -.5, -.1, .5, .5, .1},
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_node('shapes:gold_triangle_1', {
|
||||
description = 'Offset Golden Triangle.',
|
||||
drawtype = 'mesh',
|
||||
mesh = 'shapes_triangle_1.obj',
|
||||
tiles = {'default_gold_block.png'},
|
||||
paramtype = 'light',
|
||||
paramtype2 = 'facedir',
|
||||
groups = {cracky=2},
|
||||
selection_box = {
|
||||
type = 'fixed',
|
||||
fixed = {-.5, -.5, -.1, .5, .5, .1},
|
||||
},
|
||||
collision_box = {
|
||||
type = 'fixed',
|
||||
fixed = {-.5, -.5, -.1, .5, .5, .1},
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_node('shapes:gold_triangle_2', {
|
||||
description = 'Corner Golden Triangle.',
|
||||
drawtype = 'mesh',
|
||||
mesh = 'shapes_triangle_2.obj',
|
||||
tiles = {'default_gold_block.png'},
|
||||
paramtype = 'light',
|
||||
paramtype2 = 'facedir',
|
||||
groups = {cracky=2},
|
||||
selection_box = {
|
||||
type = 'fixed',
|
||||
fixed = {-.5, -.5, -.1, .5, .5, .1},
|
||||
},
|
||||
collision_box = {
|
||||
type = 'fixed',
|
||||
fixed = {-.5, -.5, -.1, .5, .5, .1},
|
||||
},
|
||||
})
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
# Blender v2.82 (sub 7) OBJ File: 'shapes.blend'
|
||||
# www.blender.org
|
||||
o Triangle_offset_triangle_0.001
|
||||
v -0.500000 -0.500000 -0.312500
|
||||
v -0.500000 -0.500000 -0.437500
|
||||
v 0.500000 -0.500000 -0.312500
|
||||
v 0.000000 0.500000 -0.312500
|
||||
v 0.500000 -0.500000 -0.437500
|
||||
v 0.000000 0.500000 -0.437500
|
||||
vt 0.375000 1.000000
|
||||
vt 0.375000 0.000000
|
||||
vt 0.500000 0.000000
|
||||
vt 0.500000 1.000000
|
||||
vt 0.000000 0.000000
|
||||
vt 0.500000 1.000000
|
||||
vt 1.000000 0.000000
|
||||
vt 0.125000 1.000000
|
||||
vt 0.125000 0.000000
|
||||
vt 0.250000 0.000000
|
||||
vt 0.250000 1.000000
|
||||
vt 1.000000 0.000000
|
||||
vt 0.500000 1.000000
|
||||
vt 0.000000 0.000000
|
||||
vn -0.8944 0.4472 0.0000
|
||||
vn 0.0000 0.0000 -1.0000
|
||||
vn 0.8944 0.4472 0.0000
|
||||
vn 0.0000 0.0000 1.0000
|
||||
vn 0.0000 -1.0000 0.0000
|
||||
s off
|
||||
f 1/1/1 4/2/1 6/3/1 2/4/1
|
||||
f 2/5/2 6/6/2 5/7/2
|
||||
f 5/8/3 6/9/3 4/10/3 3/11/3
|
||||
f 3/12/4 4/13/4 1/14/4
|
||||
f 2/5/5 5/7/5 3/12/5 1/14/5
|
|
@ -0,0 +1,75 @@
|
|||
# Blender v2.82 (sub 7) OBJ File: 'shapes.blend'
|
||||
# www.blender.org
|
||||
o Triangle_corner_triangle_0.002
|
||||
v -0.062500 -0.500000 0.062500
|
||||
v -0.062500 -0.500000 -0.062500
|
||||
v -0.062500 0.500000 -0.062500
|
||||
v -0.062500 0.500000 0.062500
|
||||
v 0.062500 -0.500000 0.500000
|
||||
v -0.062500 -0.500000 0.500000
|
||||
v -0.500000 -0.500000 -0.062500
|
||||
v 0.062500 0.500000 0.062500
|
||||
v -0.500000 -0.500000 0.062500
|
||||
v -0.062500 0.500000 0.062500
|
||||
v -0.062500 -0.500000 0.062500
|
||||
v 0.062500 -0.500000 0.062500
|
||||
v 0.062500 -0.500000 -0.062500
|
||||
v 0.062500 0.500000 -0.062500
|
||||
vt 0.437508 0.999934
|
||||
vt 0.000066 0.000066
|
||||
vt 0.437508 0.000066
|
||||
vt 0.562500 0.000000
|
||||
vt 1.000000 -0.000000
|
||||
vt 0.562500 1.000000
|
||||
vt 0.125000 0.500000
|
||||
vt 0.000000 0.500000
|
||||
vt 0.000000 0.125000
|
||||
vt 0.125000 0.125000
|
||||
vt 0.375000 1.000000
|
||||
vt 0.375000 0.000000
|
||||
vt 0.500000 0.000000
|
||||
vt 0.500000 1.000000
|
||||
vt 0.437509 0.999925
|
||||
vt 0.000075 0.000075
|
||||
vt 0.437509 0.000075
|
||||
vt 0.375000 1.000000
|
||||
vt 0.375000 0.000000
|
||||
vt 0.500000 0.000000
|
||||
vt 0.500000 1.000000
|
||||
vt 0.500000 -0.000000
|
||||
vt 0.500000 0.125000
|
||||
vt 0.125000 0.125000
|
||||
vt 0.125000 0.000000
|
||||
vt 0.562500 -0.000000
|
||||
vt 1.000000 -0.000000
|
||||
vt 0.562500 1.000000
|
||||
vt 0.437500 1.000000
|
||||
vt 0.437500 -0.000000
|
||||
vt 0.562491 0.000075
|
||||
vt 0.562491 0.999925
|
||||
vt 0.000000 0.875000
|
||||
vt 0.125000 0.875000
|
||||
vt 0.125000 1.000000
|
||||
vt -0.000000 1.000000
|
||||
vt 0.000000 0.000000
|
||||
vn -0.0000 -0.0000 1.0000
|
||||
vn -1.0000 -0.0000 -0.0000
|
||||
vn 0.0000 -1.0000 0.0000
|
||||
vn 0.0000 0.4008 0.9162
|
||||
vn 1.0000 -0.0000 0.0000
|
||||
vn -0.9162 0.4008 0.0000
|
||||
vn 0.0000 -0.0000 -1.0000
|
||||
vn 0.0000 1.0000 0.0000
|
||||
s off
|
||||
f 4/1/1 9/2/1 1/3/1
|
||||
f 11/4/2 6/5/2 10/6/2
|
||||
f 9/7/3 7/8/3 2/9/3 1/10/3
|
||||
f 5/11/4 8/12/4 10/13/4 6/14/4
|
||||
f 8/15/5 5/16/5 12/17/5
|
||||
f 9/18/6 4/19/6 3/20/6 7/21/6
|
||||
f 5/22/3 6/23/3 11/24/3 12/25/3
|
||||
f 2/26/7 7/27/7 3/28/7
|
||||
f 2/26/7 3/28/7 14/29/7 13/30/7
|
||||
f 8/15/5 12/17/5 13/31/5 14/32/5
|
||||
f 3/33/8 4/34/8 8/35/8 14/36/8
|
||||
f 2/9/3 13/37/3 12/25/3 1/10/3
|
|
@ -1,4 +1,18 @@
|
|||
local news = {
|
||||
'8/18/20',
|
||||
'Added locked version to the new stations.',
|
||||
'',
|
||||
'8/16/20',
|
||||
'Fabric dying is now listed in unified inventory.',
|
||||
'',
|
||||
'8/15/20',
|
||||
'Migrated server to an SSD, hopefully this bring some performance improvements.',
|
||||
'New texture for the Barley and Rye seeds.',
|
||||
'',
|
||||
'8/14/20',
|
||||
'Added corn to the threshing machine and flour mill.',
|
||||
'New texture on the rice seed.',
|
||||
'',
|
||||
'8/13/20',
|
||||
'Added recipe for white fabric in unified inventory.',
|
||||
'New texure for rice, and rice can be threshed into rice grains.',
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
name = stations
|
||||
depends = simplecrafting_lib, epic
|
||||
depends = simplecrafting_lib, epic, dye
|
||||
|
|
|
@ -68,17 +68,20 @@ minetest.register_craft({
|
|||
--Locked to Unlocked Stations
|
||||
local stations = {
|
||||
anvil1 = 'anvil_locked',
|
||||
churn = 'churn_locked',
|
||||
crystal_workshop = 'crystal_workshop_locked',
|
||||
glazier_workshop = 'glazier_workshop_locked',
|
||||
woodworking = 'woodworking_locked',
|
||||
mortar = 'mortar_locked',
|
||||
puck_creator = 'puck_creator_locked',
|
||||
spinning_wheel = 'spinning_wheel_locked',
|
||||
sewing = 'sewing_locked',
|
||||
stain = 'stain_locked',
|
||||
weaving_loom = 'weaving_loom_locked',
|
||||
dying = 'dying_locked',
|
||||
food_prep = 'food_prep_locked'
|
||||
flour_mill = 'flour_mill_locked',
|
||||
food_prep = 'food_prep_locked',
|
||||
puck_creator = 'puck_creator_locked',
|
||||
glazier_workshop = 'glazier_workshop_locked',
|
||||
mortar = 'mortar_locked',
|
||||
sewing = 'sewing_locked',
|
||||
spinning_wheel = 'spinning_wheel_locked',
|
||||
stain = 'stain_locked',
|
||||
threshing = 'threshing_locked',
|
||||
weaving_loom = 'weaving_loom_locked',
|
||||
woodworking = 'woodworking_locked',
|
||||
}
|
||||
|
||||
for unlocked, locked in pairs(stations) do
|
||||
|
|
|
@ -499,6 +499,20 @@ stations.dual_register_recipe('anvil', {
|
|||
output = 'shapes:gold_triangle_0',
|
||||
})
|
||||
|
||||
stations.dual_register_recipe('anvil', {
|
||||
input = {
|
||||
['default:gold_ingot'] = 1,
|
||||
},
|
||||
output = 'shapes:gold_triangle_1',
|
||||
})
|
||||
|
||||
stations.dual_register_recipe('anvil', {
|
||||
input = {
|
||||
['default:gold_ingot'] = 1,
|
||||
},
|
||||
output = 'shapes:gold_triangle_2',
|
||||
})
|
||||
|
||||
|
||||
--Hoppers
|
||||
stations.dual_register_recipe('anvil', {
|
||||
|
|
|
@ -119,3 +119,107 @@ minetest.register_node('stations:churn', {
|
|||
end
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_node('stations:churn_locked', {
|
||||
description = 'Butter Churn (locked)',
|
||||
drawtype = 'mesh',
|
||||
mesh = 'stations_churn.obj',
|
||||
tiles = {'stations_churn.png'},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
paramtype2 = 'facedir',
|
||||
paramtype = 'light',
|
||||
selection_box = {
|
||||
type = 'fixed',
|
||||
fixed = {{-.3, -.5, -.3, .3, .3, .3},
|
||||
{-.1, .3, -.1, .1, 1, .1}}},
|
||||
collision_box = {
|
||||
type = 'fixed',
|
||||
fixed = {{-.3, -.5, -.3, .3, .3, .3},
|
||||
{-.1, .3, -.1, .1, 1, .1}}},
|
||||
groups = {oddly_breakable_by_hand = 1, choppy=3},
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size('input', 1)
|
||||
inv:set_size('output', 1)
|
||||
meta:set_string('infotext', 'Butter Churn (locked)')
|
||||
meta:set_string('milk', 0)
|
||||
meta:set_string('formspec', milk_formspec(pos))
|
||||
end,
|
||||
after_place_node = function(pos, placer, itemstack)
|
||||
if not epic.space_on_top(pos) then
|
||||
minetest.remove_node(pos)
|
||||
return itemstack
|
||||
end
|
||||
end,
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
epic.remove_top_node(pos, oldnode)
|
||||
end,
|
||||
can_dig = function(pos,player)
|
||||
local meta = minetest.get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
if inv:is_empty('input') and inv:is_empty('output') then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end,
|
||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
local player_name = player:get_player_name()
|
||||
if minetest.is_protected(pos, player_name) and not minetest.check_player_privs(player, 'protection_bypass') then
|
||||
return 0
|
||||
else
|
||||
local input = stack:get_name()
|
||||
if listname == 'input' then
|
||||
if input == 'mobs:bucket_milk' then
|
||||
return 99
|
||||
else
|
||||
return 0
|
||||
end
|
||||
elseif listname == 'output' then
|
||||
return 0
|
||||
end
|
||||
end
|
||||
end,
|
||||
on_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
local input = stack:get_name()
|
||||
if listname == 'input' then
|
||||
if input == 'mobs:bucket_milk' then
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local milk_level = tonumber(meta:get_string('milk'))
|
||||
if milk_level + 4 <= 8 then
|
||||
local timer = minetest.get_node_timer(pos)
|
||||
inv:set_stack('input', 1, 'bucket:bucket_empty')
|
||||
meta:set_string('milk', (milk_level + 4))
|
||||
timer:start(10)
|
||||
meta:set_string('formspec', milk_formspec(pos))
|
||||
meta:set_string('infotext', 'Making Butter')
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
on_timer = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local milk_level = tonumber(meta:get_string('milk'))
|
||||
if milk_level >= 1 then
|
||||
local timer = minetest.get_node_timer(pos)
|
||||
inv:add_item('output', 'food:butter')
|
||||
meta:set_string('milk', (milk_level - 1))
|
||||
timer:start(10)
|
||||
meta:set_string('formspec', milk_formspec(pos))
|
||||
meta:set_string('infotext', 'Making Butter')
|
||||
else
|
||||
meta:set_string('infotext', 'Butter Churn')
|
||||
end
|
||||
end,
|
||||
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
local player_name = player:get_player_name()
|
||||
if minetest.is_protected(pos, player_name) and not minetest.check_player_privs(player, 'protection_bypass') then
|
||||
return 0
|
||||
else
|
||||
return 99
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
|
|
@ -1,3 +1,23 @@
|
|||
unified_inventory.register_craft_type('stain', {
|
||||
description = 'Stain Station',
|
||||
icon = 'stations_stain_icon.png',
|
||||
width = 2,
|
||||
height = 1
|
||||
})
|
||||
|
||||
local dye_table = dye.dyes
|
||||
|
||||
for i in ipairs(dye_table) do
|
||||
local name = dye_table[i][1]
|
||||
|
||||
unified_inventory.register_craft({
|
||||
type = 'stain',
|
||||
items = {'furniture:fabric_white', 'dye:'..name},
|
||||
output = 'furniture:fabric_'..name
|
||||
})
|
||||
|
||||
end
|
||||
|
||||
local function dying_formspec(water_level)
|
||||
formspec =
|
||||
'size[8,8.5]'..
|
||||
|
|
|
@ -11,6 +11,12 @@ unified_inventory.register_craft({
|
|||
output = 'food:flour_barley'
|
||||
})
|
||||
|
||||
unified_inventory.register_craft({
|
||||
type = 'mill',
|
||||
items = {'farming:seed_corn 4'},
|
||||
output = 'food:flour_corn'
|
||||
})
|
||||
|
||||
unified_inventory.register_craft({
|
||||
type = 'mill',
|
||||
items = {'farming:seed_oat 4'},
|
||||
|
@ -37,6 +43,7 @@ unified_inventory.register_craft({
|
|||
|
||||
stations.flour_seeds = {}
|
||||
stations.flour_seeds['farming:seed_barley'] = true
|
||||
stations.flour_seeds['farming:seed_corn'] = true
|
||||
stations.flour_seeds['farming:seed_oat'] = true
|
||||
stations.flour_seeds['farming:seed_rice'] = true
|
||||
stations.flour_seeds['farming:seed_rye'] = true
|
||||
|
@ -123,3 +130,88 @@ minetest.register_node('stations:flour_mill', {
|
|||
end
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_node('stations:flour_mill_locked', {
|
||||
description = 'Flour Mill (locked)',
|
||||
drawtype = 'mesh',
|
||||
mesh = 'stations_flour_mill.obj',
|
||||
tiles = {'stations_flour_mill.png'},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
paramtype2 = 'facedir',
|
||||
paramtype = 'light',
|
||||
selection_box = {
|
||||
type = 'fixed',
|
||||
fixed = {-.5, -.5, -.5, .5, .5, .5}},
|
||||
collision_box = {
|
||||
type = 'fixed',
|
||||
fixed = {-.5, -.5, -.5, .5, .5, .5}},
|
||||
groups = {oddly_breakable_by_hand = 1, choppy=3},
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size('input', 1)
|
||||
inv:set_size('output', 2*2)
|
||||
meta:set_string('infotext', 'Flour Mill')
|
||||
meta:set_string('formspec', formspec)
|
||||
end,
|
||||
after_place_node = function(pos, placer, itemstack)
|
||||
if not epic.space_to_side(pos) then
|
||||
minetest.remove_node(pos)
|
||||
return itemstack
|
||||
end
|
||||
end,
|
||||
can_dig = function(pos,player)
|
||||
local meta = minetest.get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
if inv:is_empty('input') and inv:is_empty('output') then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end,
|
||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
local player_name = player:get_player_name()
|
||||
if minetest.is_protected(pos, player_name) and not minetest.check_player_privs(player, 'protection_bypass') then
|
||||
return 0
|
||||
else
|
||||
local input = stack:get_name()
|
||||
if listname == 'input' then
|
||||
if stations.flour_seeds[input] then
|
||||
return 99
|
||||
else
|
||||
return 0
|
||||
end
|
||||
elseif listname == 'output' then
|
||||
return 0
|
||||
end
|
||||
end
|
||||
end,
|
||||
on_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
local timer = minetest.get_node_timer(pos)
|
||||
timer:start(3)
|
||||
end,
|
||||
on_timer = function(pos)
|
||||
local timer = minetest.get_node_timer(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local input = inv:get_stack('input', 1)
|
||||
local input_count = input:get_count()
|
||||
if input_count >= 4 then
|
||||
local output = inv:get_stack('output', 1)
|
||||
local grain_name = input:get_name()
|
||||
local grain = string.sub(grain_name, 14,-1)
|
||||
inv:add_item('output', 'food:flour_'..grain)
|
||||
input:take_item(4)
|
||||
inv:set_stack('input',1,input)
|
||||
timer:start(3)
|
||||
end
|
||||
end,
|
||||
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
local player_name = player:get_player_name()
|
||||
if minetest.is_protected(pos, player_name) and not minetest.check_player_privs(player, 'protection_bypass') then
|
||||
return 0
|
||||
else
|
||||
return 99
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
stations.grains = {}
|
||||
stations.grains['farming:barley'] = true
|
||||
stations.grains['farming:corn'] = true
|
||||
stations.grains['farming:oat'] = true
|
||||
stations.grains['farming:rice'] = true
|
||||
stations.grains['farming:rye'] = true
|
||||
stations.grains['farming:wheat'] = true
|
||||
stations.grains['farming:rice'] = true
|
||||
|
||||
local function threshing_formspec(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
@ -93,6 +94,16 @@ minetest.register_node('stations:threshing', {
|
|||
timer:start(3)
|
||||
end
|
||||
end,
|
||||
on_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
local timer = minetest.get_node_timer(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local speed = meta:get_string('speed')
|
||||
if speed == 'slow' then
|
||||
timer:start(10)
|
||||
elseif speed == 'fast' then
|
||||
timer:start(3)
|
||||
end
|
||||
end,
|
||||
on_timer = function(pos)
|
||||
local timer = minetest.get_node_timer(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
@ -121,4 +132,132 @@ minetest.register_node('stations:threshing', {
|
|||
end
|
||||
end
|
||||
end,
|
||||
on_rotate = function(pos, node)
|
||||
return false
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_node('stations:threshing_locked', {
|
||||
description = 'Threshing Machine (locked)',
|
||||
drawtype = 'mesh',
|
||||
mesh = 'stations_threshing.obj',
|
||||
tiles = {'stations_threshing.png'},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
paramtype2 = 'facedir',
|
||||
paramtype = 'light',
|
||||
selection_box = {
|
||||
type = 'fixed',
|
||||
fixed = {-.45, -.5, -.5, 1.25, .5, .5}},
|
||||
collision_box = {
|
||||
type = 'fixed',
|
||||
fixed = {-.45, -.5, -.5, 1.25, .5, .5}},
|
||||
groups = {oddly_breakable_by_hand=3, choppy=3},
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size('input', 1)
|
||||
inv:set_size('output', 6)
|
||||
inv:set_size('straw', 3)
|
||||
meta:set_string('speed', 'slow')
|
||||
meta:set_string('infotext', 'Threshing Machine (locked)')
|
||||
meta:set_string('formspec', threshing_formspec(pos))
|
||||
end,
|
||||
after_place_node = function(pos, placer, itemstack)
|
||||
if not epic.space_to_side(pos) then
|
||||
minetest.remove_node(pos)
|
||||
return itemstack
|
||||
end
|
||||
end,
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
epic.remove_side_node(pos, oldnode)
|
||||
end,
|
||||
can_dig = function(pos,player)
|
||||
local meta = minetest.get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
if inv:is_empty('input') and inv:is_empty('output') then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end,
|
||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
local player_name = player:get_player_name()
|
||||
if minetest.is_protected(pos, player_name) and not minetest.check_player_privs(player, 'protection_bypass') then
|
||||
return 0
|
||||
else
|
||||
local input = stack:get_name()
|
||||
if listname == 'input' then
|
||||
if stations.grains[input] then
|
||||
return 99
|
||||
else
|
||||
return 0
|
||||
end
|
||||
return 0
|
||||
else
|
||||
return 0
|
||||
end
|
||||
end
|
||||
end,
|
||||
on_receive_fields = function(pos, formname, fields, sender)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local timer = minetest.get_node_timer(pos)
|
||||
if fields ['slow'] then
|
||||
meta:set_string('speed', 'slow')
|
||||
meta:set_string('formspec', threshing_formspec(pos))
|
||||
timer:start(10)
|
||||
elseif fields ['fast'] then
|
||||
meta:set_string('speed', 'fast')
|
||||
meta:set_string('formspec', threshing_formspec(pos))
|
||||
timer:start(3)
|
||||
end
|
||||
end,
|
||||
on_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
local timer = minetest.get_node_timer(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local speed = meta:get_string('speed')
|
||||
if speed == 'slow' then
|
||||
timer:start(10)
|
||||
elseif speed == 'fast' then
|
||||
timer:start(3)
|
||||
end
|
||||
end,
|
||||
on_timer = function(pos)
|
||||
local timer = minetest.get_node_timer(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local input = inv:get_stack('input', 1)
|
||||
local input_count = input:get_count()
|
||||
if input_count >= 1 then
|
||||
local output = inv:get_stack('output', 1)
|
||||
local grain_name = input:get_name()
|
||||
local grain = string.sub(grain_name, 9,-1)
|
||||
local speed = meta:get_string('speed')
|
||||
if speed == 'slow' then
|
||||
local num = math.random(3, 7)
|
||||
inv:add_item('output', 'farming:seed_'..grain..' '..num)
|
||||
inv:add_item('straw', 'farming:hay')
|
||||
input:take_item(1)
|
||||
inv:set_stack('input',1,input)
|
||||
timer:start(10)
|
||||
elseif speed == 'fast' then
|
||||
local num = math.random(1, 3)
|
||||
inv:add_item('output', 'farming:seed_'..grain..' '..num)
|
||||
inv:add_item('straw', 'farming:hay')
|
||||
input:take_item(1)
|
||||
inv:set_stack('input',1,input)
|
||||
timer:start(3)
|
||||
end
|
||||
end
|
||||
end,
|
||||
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
local player_name = player:get_player_name()
|
||||
if minetest.is_protected(pos, player_name) and not minetest.check_player_privs(player, 'protection_bypass') then
|
||||
return 0
|
||||
else
|
||||
return 99
|
||||
end
|
||||
end,
|
||||
on_rotate = function(pos, node)
|
||||
return false
|
||||
end,
|
||||
})
|
||||
|
|
After Width: | Height: | Size: 18 KiB |