This commit is contained in:
Evert Prants 2018-08-12 18:05:39 +03:00
parent 18bc34b28f
commit 88d9b64519
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
14 changed files with 69 additions and 49 deletions

View File

@ -160,7 +160,7 @@ minetest.register_craft({
})
minetest.register_craft({
output = "elepower_dynamics:copper_wire",
output = "elepower_dynamics:copper_wire 8",
recipe = {
{"default:copper_ingot", "default:copper_ingot", "default:copper_ingot"},
{"default:copper_ingot", "", "default:copper_ingot"},

View File

@ -8,5 +8,6 @@ elefarm.modpath = modpath
dofile(modpath.."/treecutter.lua")
dofile(modpath.."/craftitems.lua")
dofile(modpath.."/nodes/init.lua")
dofile(modpath.."/nodes.lua")
dofile(modpath.."/machines/init.lua")
dofile(modpath.."/crafting.lua")

View File

@ -113,9 +113,9 @@ local function on_timer(pos, elapsed)
local is_enabled = ele.helpers.state_enabled(meta, pos, state)
local active = "Idle"
local power = {capacity = capacity, storage = storage, usage = 0}
local pow_buffer = {capacity = capacity, storage = storage, usage = 0}
if storage > usage and sludge.amount + SLUDGE_PRODUCED < sludge.capacity and is_enabled then
if pow_buffer.storage > usage and sludge.amount + SLUDGE_PRODUCED < sludge.capacity and is_enabled then
if work == HARVESTER_TICK then
local harvested = {}
@ -123,7 +123,7 @@ local function on_timer(pos, elapsed)
work = 0
if #harvested > 0 then
storage = storage - usage
pow_buffer.storage = pow_buffer.storage - usage
sludge.amount = sludge.amount + SLUDGE_PRODUCED
for _,itm in ipairs(harvested) do
local stack = ItemStack(itm)
@ -138,7 +138,7 @@ local function on_timer(pos, elapsed)
active = "Active"
refresh = true
power.usage = usage
pow_buffer.usage = usage
ele.helpers.swap_node(pos, "elepower_farming:harvester_active")
else
if not is_enabled then
@ -150,11 +150,11 @@ local function on_timer(pos, elapsed)
local work_percent = math.floor((work / HARVESTER_TICK)*100)
meta:set_string("formspec", get_formspec(work_percent, power, sludge, state))
meta:set_string("formspec", get_formspec(work_percent, pow_buffer, sludge, state))
meta:set_string("infotext", ("Harvester %s\n%s"):format(active,
ele.capacity_text(capacity, storage)))
meta:set_int("storage", storage)
meta:set_int("storage", pow_buffer.storage)
meta:set_int("src_time", work)
meta:set_string("sludge_fluid", "elepower_farming:sludge_source")

View File

@ -0,0 +1,14 @@
local mp = elefarm.modpath.."/machines/"
dofile(mp.."fluids.lua")
dofile(mp.."planter.lua")
dofile(mp.."harvester.lua")
dofile(mp.."tree_extractor.lua")
dofile(mp.."tree_processor.lua")
dofile(mp.."composter.lua")
-- Mobs Redo support
if minetest.get_modpath("mobs") ~= nil and mobs.mod and mobs.mod == "redo" then
dofile(mp.."spawner.lua")
end

View File

@ -234,10 +234,10 @@ local function on_timer(pos, elapsed)
local state = meta:get_int("state")
local is_enabled = ele.helpers.state_enabled(meta, pos, state)
local power = {capacity = capacity, storage = storage, usage = 0}
local pow_buffer = {capacity = capacity, storage = storage, usage = 0}
local active = "Idle"
if storage > usage and is_enabled then
if pow_buffer.storage > usage and is_enabled then
if work == PLANTER_TICK then
local planted = 0
for index, slot in ipairs(inv:get_list("layout")) do
@ -249,7 +249,7 @@ local function on_timer(pos, elapsed)
work = 0
if planted > 0 then
storage = storage - usage
pow_buffer.storage = pow_buffer.storage - usage
end
else
work = work + 1
@ -257,18 +257,18 @@ local function on_timer(pos, elapsed)
active = "Active"
refresh = true
power.usage = usage
pow_buffer.usage = usage
elseif not is_enabled then
active = "Off"
end
local work_percent = math.floor((work / PLANTER_TICK)*100)
meta:set_string("formspec", get_formspec(work_percent, power, state))
meta:set_string("formspec", get_formspec(work_percent, pow_buffer, state))
meta:set_string("infotext", ("Planter %s\n%s"):format(active,
ele.capacity_text(capacity, storage)))
meta:set_int("storage", storage)
meta:set_int("storage", pow_buffer.storage)
meta:set_int("src_time", work)
return refresh

View File

@ -126,9 +126,10 @@ local function on_timer(pos, elapsed)
local mob_desc = "None"
local active = "Active"
local power = {capacity = capacity, storage = storage, usage = 0}
local pow_buffer = {capacity = capacity, storage = storage, usage = 0}
if storage > usage and not egg_slot:is_empty() and ele.helpers.get_item_group(egg_name, "spawn_egg") and is_enabled then
if pow_buffer.storage > usage and not egg_slot:is_empty() and
ele.helpers.get_item_group(egg_name, "spawn_egg") and is_enabled then
local mob_name = egg_name:gsub("_set", "")
if work == SPAWNER_TICK then
@ -141,7 +142,7 @@ local function on_timer(pos, elapsed)
work = 0
if spawned > 0 then
storage = storage - usage
pow_buffer.storage = pow_buffer.storage - usage
end
else
work = work + 1
@ -149,7 +150,7 @@ local function on_timer(pos, elapsed)
refresh = true
mob_desc = minetest.registered_items[mob_name].description
power.usage = usage
pow_buffer.usage = usage
elseif not is_enabled then
active = "Off"
else
@ -158,12 +159,12 @@ local function on_timer(pos, elapsed)
end
meta:set_string("infotext", ("Powered Mob Spawner %s\nMob: %s\n%s"):format(
active, mob_desc, ele.capacity_text(capacity, storage)))
active, mob_desc, ele.capacity_text(capacity, pow_buffer.storage)))
local work_percent = math.floor((work / SPAWNER_TICK)*100)
meta:set_string("formspec", get_formspec(work_percent, power, state))
meta:set_int("storage", storage)
meta:set_string("formspec", get_formspec(work_percent, pow_buffer, state))
meta:set_int("storage", pow_buffer.storage)
meta:set_int("src_time", work)
return refresh

View File

@ -21,7 +21,7 @@ local tree_fluid_recipes = {
},
}
local function get_formspec(timer, power, fluid_buffer, water_buffer, output_buffer)
local function get_formspec(timer, power, fluid_buffer, water_buffer, output_buffer, state)
return "size[8,8.5]"..
default.gui_bg..
default.gui_bg_img..
@ -31,6 +31,7 @@ local function get_formspec(timer, power, fluid_buffer, water_buffer, output_buf
ele.formspec.fluid_bar(2, 0, fluid_buffer)..
ele.formspec.fluid_bar(3, 0, water_buffer)..
ele.formspec.fluid_bar(7, 0, output_buffer)..
ele.formspec.state_switcher(7, 2.5, state)..
"list[context;dst;5,1;1,1;]"..
"list[current_player;main;0,4.25;8,1;]"..
"list[current_player;main;0,5.5;8,3;8]"..
@ -56,8 +57,18 @@ local function on_timer(pos, elapsed)
local time_max = meta:get_int("src_time_max")
local recipe = tree_fluid_recipes[tree_buffer.fluid]
local pow_buffer = {capacity = capacity, storage = storage, usage = 0}
local state = meta:get_int("state")
local is_enabled = ele.helpers.state_enabled(meta, pos, state)
local active = "Idle"
while true do
if not is_enabled then
active = "Off"
break
end
if not recipe then
break
end
@ -65,7 +76,7 @@ local function on_timer(pos, elapsed)
local conditions = water_buffer.amount >= recipe.water and
tree_buffer.amount >= recipe.amount and
out_buffer.amount + recipe.output.amount < out_buffer.capacity and
storage > usage and
pow_buffer.storage > usage and
(out_buffer.fluid == "" or out_buffer.fluid == recipe.output.fluid)
if not conditions then
@ -79,8 +90,9 @@ local function on_timer(pos, elapsed)
break
end
storage = storage - usage
meta:set_int("storage", storage)
pow_buffer.storage = pow_buffer.storage - usage
pow_buffer.usage = usage
active = "Active"
if time < time_max then
time = time + 1
@ -105,6 +117,7 @@ local function on_timer(pos, elapsed)
end
if not room_for_output then
active = "Output Full!"
break
end
@ -131,12 +144,15 @@ local function on_timer(pos, elapsed)
end
local timer = 0
local power = {capacity = capacity, storage = storage}
if time_max > 0 then
timer = math.floor(100 * time / time_max)
end
meta:set_string("formspec", get_formspec(timer, power, tree_buffer, water_buffer, out_buffer))
meta:set_string("formspec", get_formspec(timer, pow_buffer, tree_buffer,
water_buffer, out_buffer, state))
meta:set_string("infotext", ("Tree Processor %s\n%s"):format(active,
ele.capacity_text(capacity, pow_buffer.storage)))
meta:set_int("storage", pow_buffer.storage)
return refresh
end

View File

@ -0,0 +1,9 @@
minetest.register_node("elepower_farming:device_frame", {
description = "Plastic Device Frame\nSafe for decoration",
tiles = {
"elefarming_machine_base.png", "elefarming_machine_base.png", "elefarming_machine_side.png",
"elefarming_machine_side.png", "elefarming_machine_side.png", "elefarming_machine_side.png",
},
groups = {oddly_breakable_by_hand = 1, cracky = 1}
})

View File

@ -1,21 +0,0 @@
minetest.register_node("elepower_farming:device_frame", {
description = "Plastic Device Frame\nSafe for decoration",
tiles = {
"elefarming_machine_base.png", "elefarming_machine_base.png", "elefarming_machine_side.png",
"elefarming_machine_side.png", "elefarming_machine_side.png", "elefarming_machine_side.png",
},
groups = {oddly_breakable_by_hand = 1, cracky = 1}
})
dofile(elefarm.modpath.."/nodes/fluids.lua")
dofile(elefarm.modpath.."/nodes/planter.lua")
dofile(elefarm.modpath.."/nodes/harvester.lua")
dofile(elefarm.modpath.."/nodes/tree_extractor.lua")
dofile(elefarm.modpath.."/nodes/tree_processor.lua")
dofile(elefarm.modpath.."/nodes/composter.lua")
-- Mobs Redo support
if minetest.get_modpath("mobs") ~= nil and mobs.mod and mobs.mod == "redo" then
dofile(elefarm.modpath.."/nodes/spawner.lua")
end

View File

@ -22,6 +22,6 @@ ele.register_fluid_generator("elepower_machines:fuel_burner", {
},
}
},
fuel_burn_time = 4,
fuel_burn_time = 8,
fuel_usage = 100,
})

Binary file not shown.

Before

Width:  |  Height:  |  Size: 889 KiB

After

Width:  |  Height:  |  Size: 918 KiB