unfinished business

This commit is contained in:
Evert Prants 2018-06-30 22:23:30 +03:00
parent a56af3dabd
commit b36d718ec6
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
10 changed files with 61 additions and 8 deletions

View File

@ -0,0 +1,3 @@
-- Elepower Compatibility registrations
dofile(elepd.modpath.."/compat/plastic.lua")

View File

@ -178,6 +178,12 @@ minetest.register_craftitem("elepower_dynamics:control_circuit", {
groups = {ic = 2, assembled_component = 1, control_circuit = 1}
})
minetest.register_craftitem("elepower_dynamics:micro_circuit", {
description = "Microcontroller Circuit",
inventory_image = "elepower_ic_3.png",
groups = {ic = 3, assembled_component = 1, control_circuit = 2}
})
---------------
-- Overrides --
---------------

View File

@ -8,7 +8,7 @@ elepd.modpath = modpath
dofile(modpath.."/conduits.lua")
dofile(modpath.."/craftitems.lua")
dofile(modpath.."/plastic.lua")
dofile(modpath.."/compat/init.lua")
dofile(modpath.."/tools.lua")
dofile(modpath.."/nodes.lua")
dofile(modpath.."/liquids.lua")

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@ -11,12 +11,32 @@ function ele.formspec.get_crafter_formspec(craft_type, power, percent)
(percent)..":gui_furnace_arrow_fg.png^[transformR270]"
end
local in_width = input_size
local in_height = 1
for n = 2, 4 do
if input_size % n == 0 and input_size ~= n then
in_width = input_size / n
in_height = input_size / n
end
end
local y = 1.5
local x = 1.5
if in_height == 2 then
y = 1
x = 1
elseif in_height >= 3 then
y = 0.5
x = 1
end
return "size[8,8.5]"..
default.gui_bg..
default.gui_bg_img..
default.gui_slots..
ele.formspec.power_meter(power)..
"list[context;src;1.5,1.5;"..input_size..",1;]"..
"list[context;src;"..x..","..y..";"..in_width..","..in_height..";]"..
bar..
"list[context;dst;5,1;2,2;]"..
"list[current_player;main;0,4.25;8,1;]"..

View File

@ -0,0 +1,17 @@
elepm.register_craft_type("assembly", {
description = "Assembly",
inputs = 9,
})
elepm.register_crafter("elepower_machines:assembler", {
description = "Assembler",
craft_type = "assembly",
tiles = {
"elepower_machine_top.png", "elepower_machine_base.png", "elepower_machine_side.png",
"elepower_machine_side.png", "elepower_machine_side.png", "elepower_machine_side.png",
},
groups = {oddly_breakable_by_hand = 1},
ele_capacity = 64000,
ele_usage = 124
})

View File

@ -25,6 +25,7 @@ function elepm.register_crafter(nodename, nodedef)
local machine_speed = nodedef.craft_speed or 1
local capacity = ele.helpers.get_node_property(meta, pos, "capacity")
local time = meta:get_int("src_time")
while true do
local result = elepm.get_recipe(craft_type, inv:get_list("src"))
@ -45,7 +46,7 @@ function elepm.register_crafter(nodename, nodedef)
if result.time == 0 then
meta:set_string("formspec", ele.formspec.get_crafter_formspec(craft_type, pow_percent))
meta:set_int("src_time", 0)
time = 0
meta:set_string("infotext", ("%s Idle"):format(nodedef.description) ..
"\n" .. ele.capacity_text(capacity, storage))
else
@ -63,7 +64,7 @@ function elepm.register_crafter(nodename, nodedef)
-- One step
meta:set_int("storage", storage - usage)
pow_percent = math.floor((storage / capacity) * 100)
meta:set_int("src_time", meta:get_int("src_time") + ele.helpers.round(machine_speed * 10))
time = time + ele.helpers.round(machine_speed * 10)
meta:set_string("infotext", ("%s Active"):format(nodedef.description) ..
"\n" .. ele.capacity_text(capacity, storage))
@ -76,8 +77,8 @@ function elepm.register_crafter(nodename, nodedef)
ele.helpers.swap_node(pos, active_node)
end
if meta:get_int("src_time") <= ele.helpers.round(result.time * 10) then
local pct = math.floor((meta:get_int("src_time") / ele.helpers.round(result.time * 10)) * 100)
if time <= ele.helpers.round(result.time * 10) then
local pct = math.floor((time / ele.helpers.round(result.time * 10)) * 100)
meta:set_string("formspec", ele.formspec.get_crafter_formspec(craft_type, pow_percent, pct))
break
end
@ -104,17 +105,19 @@ function elepm.register_crafter(nodename, nodedef)
if not room_for_output then
ele.helpers.swap_node(pos, machine_node)
meta:set_string("formspec", ele.formspec.get_crafter_formspec(craft_type, pow_percent))
meta:set_int("src_time", ele.helpers.round(result.time*10))
time = ele.helpers.round(result.time*10)
meta:set_string("infotext", ("%s Output Full!"):format(nodedef.description) ..
"\n" .. ele.capacity_text(capacity, storage))
break
end
meta:set_int("src_time", meta:get_int("src_time") - ele.helpers.round(result.time*10))
time = 0
inv:set_list("src", result.new_input)
inv:set_list("dst", inv:get_list("dst_tmp"))
end
meta:set_int("src_time", time)
return refresh
end

View File

@ -1,4 +1,5 @@
-- Basic
dofile(elepm.modpath.."/machines/bases/init.lua")
dofile(elepm.modpath.."/machines/accumulator.lua")
dofile(elepm.modpath.."/machines/furnace.lua")
@ -10,3 +11,6 @@ dofile(elepm.modpath.."/machines/sawmill.lua")
dofile(elepm.modpath.."/machines/generator.lua")
dofile(elepm.modpath.."/machines/storage.lua")
dofile(elepm.modpath.."/machines/lava_cooler.lua")
-- Hardened
dofile(elepm.modpath.."/machines/assembler.lua")

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB