Sawmill texture change, some API changes
This commit is contained in:
parent
016379e444
commit
230705604f
@ -26,7 +26,6 @@ function elefluid.register_transfer_node(nodename, nodedef)
|
||||
end
|
||||
|
||||
nodedef.on_punch = function (pos, node, puncher, pointed_thing)
|
||||
local meta = minetest.get_meta(pos)
|
||||
minetest.get_node_timer(pos):start(1.0)
|
||||
minetest.node_punch(pos, node, puncher, pointed_thing)
|
||||
end
|
||||
|
@ -6,7 +6,8 @@ function elepm.register_craft_type(name, def)
|
||||
elepm.craft.types[name] = {
|
||||
inputs = def.inputs or 2,
|
||||
description = def.description or name,
|
||||
time = def.time or 0
|
||||
time = def.time or 0,
|
||||
gui_name = def.gui_name,
|
||||
}
|
||||
|
||||
elepm.craft[name] = {}
|
||||
|
@ -4,11 +4,16 @@ function ele.formspec.get_crafter_formspec(craft_type, power, percent)
|
||||
local craftstats = elepm.craft.types[craft_type]
|
||||
local input_size = craftstats.inputs
|
||||
|
||||
local bar = "image[4,1.5;1,1;gui_furnace_arrow_bg.png^[transformR270]"
|
||||
local gui_name = "gui_furnace_arrow"
|
||||
if craftstats.gui_name then
|
||||
gui_name = craftstats.gui_name
|
||||
end
|
||||
|
||||
local bar = "image[4,1.5;1,1;"..gui_name.."_bg.png^[transformR270]"
|
||||
|
||||
if percent ~= nil then
|
||||
bar = "image[4,1.5;1,1;gui_furnace_arrow_bg.png^[lowpart:"..
|
||||
(percent)..":gui_furnace_arrow_fg.png^[transformR270]"
|
||||
bar = "image[4,1.5;1,1;"..gui_name.."_bg.png^[lowpart:"..
|
||||
(percent)..":"..gui_name.."_fg.png^[transformR270]"
|
||||
end
|
||||
|
||||
local in_width = input_size
|
||||
@ -51,7 +56,7 @@ function ele.formspec.get_crafter_formspec(craft_type, power, percent)
|
||||
default.get_hotbar_bg(0, 4.25)
|
||||
end
|
||||
|
||||
function ele.formspec.get_lava_generator_formspec(power, percent, buffer)
|
||||
function ele.formspec.get_fluid_generator_formspec(power, percent, buffer)
|
||||
return "size[8,8.5]"..
|
||||
default.gui_bg..
|
||||
default.gui_bg_img..
|
||||
|
108
elepower_machines/machines/bases/fluidgenerator.lua
Normal file
108
elepower_machines/machines/bases/fluidgenerator.lua
Normal file
@ -0,0 +1,108 @@
|
||||
|
||||
-- A generator that creates power using a fuel
|
||||
function ele.register_fluid_generator(nodename, nodedef)
|
||||
local fuel = nodedef.fuel
|
||||
local btime = nodedef.fuel_burn_time or 60
|
||||
|
||||
local buffer_name = nil
|
||||
|
||||
-- Autodetect fluid buffer and the fuel if necessary
|
||||
if not nodedef.fluid_buffers then return nil end
|
||||
for buf,data in pairs(nodedef.fluid_buffers) do
|
||||
buffer_name = buf
|
||||
|
||||
if not fuel and data.accepts and type(data.accepts) == "table" then
|
||||
fuel = data.accepts[1]
|
||||
end
|
||||
|
||||
break
|
||||
end
|
||||
|
||||
local defaults = {
|
||||
groups = {
|
||||
fluid_container = 1,
|
||||
ele_provider = 1,
|
||||
oddly_breakable_by_hand = 1,
|
||||
},
|
||||
tube = false,
|
||||
on_timer = function (pos, elapsed)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local nodename = nodename
|
||||
|
||||
local burn_time = meta:get_int("burn_time")
|
||||
local burn_totaltime = meta:get_int("burn_totaltime")
|
||||
|
||||
local capacity = ele.helpers.get_node_property(meta, pos, "capacity")
|
||||
local generation = ele.helpers.get_node_property(meta, pos, "usage")
|
||||
local storage = ele.helpers.get_node_property(meta, pos, "storage")
|
||||
|
||||
-- Fluid buffer
|
||||
local flbuffer = fluid_lib.get_buffer_data(pos, buffer_name)
|
||||
if not flbuffer or flbuffer.fluid == "" then return false end
|
||||
|
||||
-- If more to burn and the energy produced was used: produce some more
|
||||
if burn_time > 0 then
|
||||
if storage + generation > capacity then
|
||||
return false
|
||||
end
|
||||
|
||||
meta:set_int("storage", storage + generation)
|
||||
|
||||
burn_time = burn_time - 1
|
||||
meta:set_int("burn_time", burn_time)
|
||||
end
|
||||
|
||||
local pow_percent = math.floor((storage / capacity) * 100)
|
||||
|
||||
-- Burn another bucket of lava
|
||||
if burn_time == 0 then
|
||||
local inv = meta:get_inventory()
|
||||
if flbuffer.amount >= 1000 then
|
||||
meta:set_int("burn_time", btime)
|
||||
meta:set_int("burn_totaltime", btime)
|
||||
|
||||
-- Take lava
|
||||
flbuffer.amount = flbuffer.amount - 1000
|
||||
|
||||
local active_node = nodename.."_active"
|
||||
ele.helpers.swap_node(pos, active_node)
|
||||
else
|
||||
meta:set_string("formspec", ele.formspec.get_fluid_generator_formspec(pow_percent, 0, flbuffer))
|
||||
meta:set_string("infotext", ("%s Idle\n%s\n%s"):format(nodedef.description,
|
||||
ele.capacity_text(capacity, storage), fluid_lib.buffer_to_string(flbuffer)))
|
||||
|
||||
ele.helpers.swap_node(pos, nodename)
|
||||
return false
|
||||
end
|
||||
end
|
||||
if burn_totaltime == 0 then burn_totaltime = 1 end
|
||||
|
||||
local percent = math.floor((burn_time / burn_totaltime) * 100)
|
||||
meta:set_string("formspec", ele.formspec.get_fluid_generator_formspec(pow_percent, percent, flbuffer))
|
||||
meta:set_string("infotext", ("%s Active\n%s\n%s"):format(nodedef.description,
|
||||
ele.capacity_text(capacity, storage), fluid_lib.buffer_to_string(flbuffer)))
|
||||
|
||||
meta:set_int(buffer_name .. "_fluid_storage", flbuffer.amount)
|
||||
|
||||
return true
|
||||
end,
|
||||
on_construct = function (pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
||||
local capacity = ele.helpers.get_node_property(meta, pos, "capacity")
|
||||
local storage = ele.helpers.get_node_property(meta, pos, "storage")
|
||||
|
||||
meta:set_string("formspec", ele.formspec.get_fluid_generator_formspec(math.floor((storage / capacity) * 100), 0))
|
||||
end
|
||||
}
|
||||
|
||||
nodedef.fuel = nil
|
||||
|
||||
for key,val in pairs(defaults) do
|
||||
if not nodedef[key] then
|
||||
nodedef[key] = val
|
||||
end
|
||||
end
|
||||
|
||||
ele.register_machine(nodename, nodedef)
|
||||
end
|
@ -1,4 +1,5 @@
|
||||
|
||||
dofile(elepm.modpath.."/machines/bases/crafter.lua")
|
||||
dofile(elepm.modpath.."/machines/bases/generator.lua")
|
||||
dofile(elepm.modpath.."/machines/bases/fluidgenerator.lua")
|
||||
dofile(elepm.modpath.."/machines/bases/storage.lua")
|
||||
|
@ -13,3 +13,4 @@ dofile(elepm.modpath.."/machines/storage.lua")
|
||||
dofile(elepm.modpath.."/machines/lava_cooler.lua")
|
||||
dofile(elepm.modpath.."/machines/solderer.lua")
|
||||
dofile(elepm.modpath.."/machines/lava_generator.lua")
|
||||
dofile(elepm.modpath.."/machines/steam_turbine.lua")
|
||||
|
@ -1,11 +1,6 @@
|
||||
|
||||
ele.register_machine("elepower_machines:lava_generator", {
|
||||
ele.register_fluid_generator("elepower_machines:lava_generator", {
|
||||
description = "Lava Generator",
|
||||
groups = {
|
||||
fluid_container = 1,
|
||||
ele_provider = 1,
|
||||
oddly_breakable_by_hand = 1,
|
||||
},
|
||||
ele_usage = 64,
|
||||
tiles = {
|
||||
"elepower_machine_top.png", "elepower_machine_base.png", "elepower_machine_side.png",
|
||||
@ -26,75 +21,4 @@ ele.register_machine("elepower_machines:lava_generator", {
|
||||
}
|
||||
},
|
||||
tube = false,
|
||||
on_timer = function (pos, elapsed)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local nodename = "elepower_machines:lava_generator"
|
||||
|
||||
local burn_time = meta:get_int("burn_time")
|
||||
local burn_totaltime = meta:get_int("burn_totaltime")
|
||||
|
||||
local capacity = ele.helpers.get_node_property(meta, pos, "capacity")
|
||||
local generation = ele.helpers.get_node_property(meta, pos, "usage")
|
||||
local storage = ele.helpers.get_node_property(meta, pos, "storage")
|
||||
|
||||
-- Fluid buffer
|
||||
local flbuffer = fluid_lib.get_buffer_data(pos, "lava")
|
||||
if not flbuffer or flbuffer.fluid == "" then return false end
|
||||
|
||||
-- If more to burn and the energy produced was used: produce some more
|
||||
if burn_time > 0 then
|
||||
if storage + generation > capacity then
|
||||
return false
|
||||
end
|
||||
|
||||
meta:set_int("storage", storage + generation)
|
||||
|
||||
burn_time = burn_time - 1
|
||||
meta:set_int("burn_time", burn_time)
|
||||
end
|
||||
|
||||
local pow_percent = math.floor((storage / capacity) * 100)
|
||||
|
||||
-- Burn another bucket of lava
|
||||
if burn_time == 0 then
|
||||
local inv = meta:get_inventory()
|
||||
if flbuffer.amount >= 1000 then
|
||||
-- Lava burn time
|
||||
local fuel = 60
|
||||
|
||||
meta:set_int("burn_time", fuel)
|
||||
meta:set_int("burn_totaltime", fuel)
|
||||
|
||||
-- Take lava
|
||||
flbuffer.amount = flbuffer.amount - 1000
|
||||
|
||||
local active_node = nodename.."_active"
|
||||
ele.helpers.swap_node(pos, active_node)
|
||||
else
|
||||
meta:set_string("formspec", ele.formspec.get_lava_generator_formspec(pow_percent, 0, flbuffer))
|
||||
meta:set_string("infotext", "Lava Generator Idle\n" .. ele.capacity_text(capacity, storage) ..
|
||||
"\n" .. fluid_lib.buffer_to_string(flbuffer))
|
||||
ele.helpers.swap_node(pos, nodename)
|
||||
return false
|
||||
end
|
||||
end
|
||||
if burn_totaltime == 0 then burn_totaltime = 1 end
|
||||
|
||||
local percent = math.floor((burn_time / burn_totaltime) * 100)
|
||||
meta:set_string("formspec", ele.formspec.get_lava_generator_formspec(pow_percent, percent, flbuffer))
|
||||
meta:set_string("infotext", "Lava Generator Active\n" .. ele.capacity_text(capacity, storage) ..
|
||||
"\n" .. fluid_lib.buffer_to_string(flbuffer))
|
||||
|
||||
meta:set_int("lava_fluid_storage", flbuffer.amount)
|
||||
|
||||
return true
|
||||
end,
|
||||
on_construct = function (pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
||||
local capacity = ele.helpers.get_node_property(meta, pos, "capacity")
|
||||
local storage = ele.helpers.get_node_property(meta, pos, "storage")
|
||||
|
||||
meta:set_string("formspec", ele.formspec.get_lava_generator_formspec(math.floor((storage / capacity) * 100), 0))
|
||||
end
|
||||
})
|
||||
|
@ -2,6 +2,7 @@
|
||||
elepm.register_craft_type("saw", {
|
||||
description = "Sawmilling",
|
||||
inputs = 1,
|
||||
gui_name = "elepower_saw",
|
||||
})
|
||||
|
||||
elepm.register_crafter("elepower_machines:sawmill", {
|
||||
|
25
elepower_machines/machines/steam_turbine.lua
Normal file
25
elepower_machines/machines/steam_turbine.lua
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
ele.register_fluid_generator("elepower_machines:steam_turbine", {
|
||||
description = "Steam Turbine",
|
||||
ele_usage = 64,
|
||||
tiles = {
|
||||
"elepower_machine_top.png^elepower_power_port.png", "elepower_machine_base.png", "elepower_machine_side.png",
|
||||
"elepower_machine_side.png", "elepower_turbine_side.png", "elepower_turbine_side.png",
|
||||
},
|
||||
ele_active_node = true,
|
||||
ele_active_nodedef = {
|
||||
tiles = {
|
||||
"elepower_machine_top.png^elepower_power_port.png", "elepower_machine_base.png", "elepower_machine_side.png",
|
||||
"elepower_machine_side.png", "elepower_turbine_side.png", "elepower_turbine_side.png",
|
||||
},
|
||||
},
|
||||
fluid_buffers = {
|
||||
steam = {
|
||||
capacity = 8000,
|
||||
accepts = {"elepower_dynamics:steam"},
|
||||
drainable = false
|
||||
}
|
||||
},
|
||||
tube = false,
|
||||
ele_no_automatic_ports = true,
|
||||
})
|
BIN
elepower_machines/textures/elepower_saw_bg.png
Normal file
BIN
elepower_machines/textures/elepower_saw_bg.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.6 KiB |
BIN
elepower_machines/textures/elepower_saw_fg.png
Normal file
BIN
elepower_machines/textures/elepower_saw_fg.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.1 KiB |
Binary file not shown.
Before Width: | Height: | Size: 7.0 KiB After Width: | Height: | Size: 13 KiB |
Binary file not shown.
Before Width: | Height: | Size: 6.8 KiB After Width: | Height: | Size: 18 KiB |
Loading…
Reference in New Issue
Block a user