Add a settings option to enable easier crafting

This commit is contained in:
Evert Prants 2018-08-07 22:47:59 +03:00
parent c4949c2935
commit 2ab287a64f
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
15 changed files with 214 additions and 123 deletions

View File

@ -1,4 +1,6 @@
local easycrafting = minetest.settings:get("elepower_easy_crafting") == "true"
---------------
-- Overrides --
---------------
@ -125,16 +127,6 @@ minetest.register_craft({
}
})
-- Fluid Transfer Node
minetest.register_craft({
output = "elepower_dynamics:fluid_transfer_node",
recipe = {
{"group:stone", "elepower_dynamics:control_circuit", "group:stone"},
{"elepower_dynamics:viridisium_gear", "elepower_dynamics:servo_valve", "elepower_dynamics:viridisium_gear"},
{"group:stone", "elepower_dynamics:fluid_duct", "group:stone"},
}
})
-- Portable Tank
minetest.register_craft({
output = "elepower_dynamics:portable_tank",
@ -210,6 +202,38 @@ minetest.register_craft({
}
})
if easycrafting then
minetest.register_craft({
output = "elepower_dynamics:pcb_blank",
recipe = {
{"default:copper_ingot", "default:copper_ingot", "default:copper_ingot"},
{"default:copper_ingot", "default:mese_crystal", "default:copper_ingot"},
{"default:gold_ingot", "default:gold_ingot", "default:gold_ingot"},
}
})
minetest.register_craft({
type = "shapeless",
output = "elepower_dynamics:acidic_compound",
recipe = {
"elepower_dynamics:copper_dust",
"elepower_dynamics:copper_dust",
"elepower_dynamics:copper_dust",
"elepower_dynamics:copper_dust",
"farming:seed_wheat",
}
})
-- Fluid Transfer Node
minetest.register_craft({
output = "elepower_dynamics:fluid_transfer_node",
recipe = {
{"group:stone", "elepower_dynamics:control_circuit", "group:stone"},
{"elepower_dynamics:electrum_gear", "elepower_dynamics:servo_valve", "elepower_dynamics:electrum_gear"},
{"group:stone", "elepower_dynamics:fluid_duct", "group:stone"},
}
})
else
minetest.register_craft({
output = "elepower_dynamics:pcb_blank",
recipe = {
@ -235,6 +259,17 @@ minetest.register_craft({
}
})
-- Fluid Transfer Node
minetest.register_craft({
output = "elepower_dynamics:fluid_transfer_node",
recipe = {
{"group:stone", "elepower_dynamics:control_circuit", "group:stone"},
{"elepower_dynamics:viridisium_gear", "elepower_dynamics:servo_valve", "elepower_dynamics:viridisium_gear"},
{"group:stone", "elepower_dynamics:fluid_duct", "group:stone"},
}
})
end
minetest.register_craft({
output = "elepower_dynamics:integrated_circuit",
recipe = {

View File

@ -1,4 +1,6 @@
local easycrafting = minetest.settings:get("elepower_easy_crafting") == true
--------------
-- Worldgen --
--------------
@ -64,6 +66,7 @@ minetest.register_ore({
-- Viridisium
if not easycrafting then
minetest.register_ore({
ore_type = "scatter",
ore = "elepower_dynamics:stone_with_viridisium",
@ -96,6 +99,7 @@ minetest.register_ore({
y_max = -12000,
y_min = -31000,
})
end
-- Zinc

View File

@ -1,4 +1,10 @@
local easycrafting = minetest.settings:get("elepower_easy_crafting") == "true"
local ingot = "elepower_dynamics:viridisium_ingot"
if easycrafting then
ingot = "elepower_dynamics:wound_copper_coil"
end
-----------
-- Nodes --
-----------
@ -17,7 +23,7 @@ minetest.register_craft({
minetest.register_craft({
output = "elepower_farming:planter",
recipe = {
{"elepower_dynamics:viridisium_ingot", "elepower_dynamics:control_circuit", "elepower_dynamics:viridisium_ingot"},
{ingot, "elepower_dynamics:control_circuit", ingot},
{"farming:hoe_steel", "elepower_farming:device_frame", "farming:hoe_steel"},
{"elepower_dynamics:wound_copper_coil", "elepower_dynamics:motor", "elepower_dynamics:wound_copper_coil"},
}
@ -27,7 +33,7 @@ minetest.register_craft({
minetest.register_craft({
output = "elepower_farming:harvester",
recipe = {
{"elepower_dynamics:viridisium_ingot", "elepower_dynamics:control_circuit", "elepower_dynamics:viridisium_ingot"},
{ingot, "elepower_dynamics:control_circuit", ingot},
{"default:axe_steel", "elepower_farming:device_frame", "farming:hoe_steel"},
{"elepower_dynamics:motor", "elepower_dynamics:diamond_gear", "elepower_dynamics:motor"},
}

View File

@ -135,7 +135,7 @@ local function on_timer(pos, elapsed)
ele.helpers.swap_node(pos, "elepower_farming:harvester")
end
local power = {capacity = capacity, storage = storage}
local power = {capacity = capacity, storage = storage, usage = usage}
local work_percent = math.floor((work / HARVESTER_TICK)*100)
meta:set_string("formspec", get_formspec(work_percent, power, sludge))
@ -180,7 +180,7 @@ ele.register_machine("elepower_farming:harvester", {
meta:set_int("src_time", 0)
local capacity = ele.helpers.get_node_property(meta, pos, "capacity")
meta:set_string("formspec", get_formspec(0, {capacity = capacity, storage = 0}))
meta:set_string("formspec", get_formspec(0, {capacity = capacity, storage = 0, usage = 0}))
local node = minetest.get_node(pos)
end,

View File

@ -252,7 +252,7 @@ local function on_timer(pos, elapsed)
refresh = true
end
local power = {capacity = capacity, storage = storage}
local power = {capacity = capacity, storage = storage, usage = usage}
local work_percent = math.floor((work / PLANTER_TICK)*100)
meta:set_string("formspec", get_formspec(work_percent, power))

View File

@ -150,7 +150,7 @@ local function on_timer(pos, elapsed)
meta:set_string("infotext", ("Powered Mob Spawner %s\nMob: %s\n%s"):format(
active, mob_desc, ele.capacity_text(capacity, storage)))
local power = {capacity = capacity, storage = storage}
local power = {capacity = capacity, storage = storage, usage = usage}
local work_percent = math.floor((work / SPAWNER_TICK)*100)
meta:set_string("formspec", get_formspec(work_percent, power))

View File

@ -1,4 +1,6 @@
local easycrafting = minetest.settings:get("elepower_easy_crafting") == "true"
--*****************--
-- MACHINE RECIPES --
--*****************--
@ -142,12 +144,21 @@ for name in pairs(minetest.registered_nodes) do
end
end
if easycrafting then
elepm.register_craft({
type = "compress",
recipe = { "default:steel_block 9" },
output = "elepower_dynamics:xycrone_lump",
time = 20,
})
else
elepm.register_craft({
type = "compress",
recipe = { "elepower_dynamics:viridisium_block 9" },
output = "elepower_dynamics:xycrone_lump",
time = 20,
})
end
-------------
-- Sawmill --
@ -188,6 +199,10 @@ end)
---------------
-- Soldering --
---------------
local induction_dust = "elepower_dynamics:viridisium_dust"
if easycrafting then
induction_dust = "elepower_dynamics:zinc_dust"
end
local soldering_recipes = {
{
@ -216,7 +231,7 @@ local soldering_recipes = {
time = 16,
},
{
recipe = { "elepower_dynamics:induction_coil 4", "elepower_dynamics:copper_wire", "elepower_dynamics:viridisium_dust 2" },
recipe = { "elepower_dynamics:induction_coil 4", "elepower_dynamics:copper_wire", induction_dust .. " 2" },
output = "elepower_dynamics:induction_coil_advanced",
time = 18,
}
@ -265,11 +280,16 @@ minetest.register_craft({
}
})
local ingot_machine = "elepower_dynamics:viridisium_ingot"
if easycrafting then
ingot_machine = "default:steel_ingot"
end
-- Machine block
minetest.register_craft({
output = "elepower_machines:machine_block",
recipe = {
{"elepower_dynamics:viridisium_ingot", "default:steel_ingot", "elepower_dynamics:viridisium_ingot"},
{ingot_machine, "default:steel_ingot", ingot_machine},
{"default:steel_ingot", "default:mese_crystal", "default:steel_ingot"},
{"elepower_dynamics:viridisium_ingot", "elepower_dynamics:motor", "elepower_dynamics:viridisium_ingot"},
}

View File

@ -96,13 +96,14 @@ function elepm.register_crafter(nodename, nodedef)
local usage = ele.helpers.get_node_property(meta, pos, "usage")
local storage = ele.helpers.get_node_property(meta, pos, "storage")
local pow_buffer = {capacity = capacity, storage = storage}
local pow_buffer = {capacity = capacity, storage = storage, usage = 0}
local power_operation = false
-- Determine if there is enough power for this action
if result.time ~= 0 and storage >= usage then
power_operation = true
pow_buffer.usage = usage
end
if result.time == 0 or not power_operation then
@ -127,7 +128,7 @@ function elepm.register_crafter(nodename, nodedef)
-- One step
meta:set_int("storage", storage - usage)
pow_buffer = {capacity = capacity, storage = storage}
pow_buffer = {capacity = capacity, storage = storage, usage = usage}
time = time + ele.helpers.round(machine_speed * 10)
meta:set_string("infotext", ("%s Active"):format(nodedef.description) ..
"\n" .. ele.capacity_text(capacity, storage))
@ -194,7 +195,7 @@ function elepm.register_crafter(nodename, nodedef)
local storage = ele.helpers.get_node_property(meta, pos, "storage")
local capacity = ele.helpers.get_node_property(meta, pos, "capacity")
local pow_buffer = {capacity = capacity, storage = storage}
local pow_buffer = {capacity = capacity, storage = storage, usage = 0}
meta:set_string("formspec", get_formspec(craft_type, pow_buffer, nil, pos))
end

View File

@ -77,7 +77,7 @@ function ele.register_fluid_generator(nodename, nodedef)
meta:set_int("burn_time", burn_time)
end
pow_buffer = {capacity = capacity, storage = storage}
pow_buffer = {capacity = capacity, storage = storage, usage = 0}
-- Burn another bucket of lava
if burn_time == 0 then
@ -88,6 +88,7 @@ function ele.register_fluid_generator(nodename, nodedef)
-- Take lava
flbuffer.amount = flbuffer.amount - 1000
pow_buffer.usage = generation
local active_node = nodename.."_active"
ele.helpers.swap_node(pos, active_node)
@ -120,7 +121,7 @@ function ele.register_fluid_generator(nodename, nodedef)
local capacity = ele.helpers.get_node_property(meta, pos, "capacity")
local storage = ele.helpers.get_node_property(meta, pos, "storage")
meta:set_string("formspec", get_formspec({capacity = capacity, storage = storage}, 0))
meta:set_string("formspec", get_formspec({capacity = capacity, storage = storage, usage = 0}, 0))
end
}

View File

@ -34,6 +34,7 @@ function elepm.register_fuel_generator(nodename, nodedef)
end
nodedef.on_timer = function (pos, elapsed)
local refresh = false
local meta = minetest.get_meta(pos)
local burn_time = meta:get_int("burn_time")
@ -56,8 +57,9 @@ function elepm.register_fuel_generator(nodename, nodedef)
meta:set_int("burn_time", burn_time)
end
local pow_buffer = {capacity = capacity, storage = storage}
local pow_buffer = {capacity = capacity, storage = storage, usage = 0}
while true do
-- Burn another piece of fuel
if burn_time == 0 then
local inv = meta:get_inventory()
@ -67,12 +69,13 @@ function elepm.register_fuel_generator(nodename, nodedef)
if not fuel or fuel.time == 0 then
ele.helpers.swap_node(pos, nodename)
return false
break
end
meta:set_int("burn_time", fuel.time)
meta:set_int("burn_totaltime", fuel.time)
inv:set_stack("src", 1, afterfuel.items[1])
pow_buffer.usage = generation
if nodedef.ele_active_node then
local active_node = nodename.."_active"
@ -82,22 +85,25 @@ function elepm.register_fuel_generator(nodename, nodedef)
ele.helpers.swap_node(pos, active_node)
end
refresh = true
else
meta:set_string("formspec", get_formspec(pow_buffer, 0))
meta:set_string("infotext", ("%s Idle"):format(nodedef.description) ..
"\n" .. ele.capacity_text(capacity, storage))
ele.helpers.swap_node(pos, nodename)
return false
end
end
if burn_totaltime == 0 then burn_totaltime = 1 end
break
end
local percent = math.floor((burn_time / burn_totaltime) * 100)
meta:set_string("formspec", get_formspec(pow_buffer, percent))
meta:set_string("infotext", ("%s Active"):format(nodedef.description) ..
"\n" .. ele.capacity_text(capacity, storage))
return true
return refresh
end
nodedef.on_construct = function (pos)
@ -108,7 +114,7 @@ function elepm.register_fuel_generator(nodename, nodedef)
local capacity = ele.helpers.get_node_property(meta, pos, "capacity")
local storage = ele.helpers.get_node_property(meta, pos, "storage")
meta:set_string("formspec", get_formspec({capacity = capacity, storage = storage}, 0))
meta:set_string("formspec", get_formspec({capacity = capacity, storage = storage, usage = 0}, 0))
end
ele.register_machine(nodename, nodedef)

View File

@ -60,7 +60,7 @@ function elepm.register_storage(nodename, nodedef)
local level = math.floor(percent * levels)
ele.helpers.swap_node(pos, nodename .. "_" .. level)
meta:set_string("formspec", get_formspec({capacity = capacity, storage = storage}))
meta:set_string("formspec", get_formspec({capacity = capacity, storage = storage, usage = 0}))
meta:set_string("infotext", ("%s Active"):format(nodedef.description) .. "\n" ..
ele.capacity_text(capacity, storage))
@ -140,7 +140,7 @@ function elepm.register_storage(nodename, nodedef)
inv:set_size("in", 1)
local capacity = ele.helpers.get_node_property(meta, pos, "capacity")
meta:set_string("formspec", get_formspec({ capacity = capacity, storage = 0 }))
meta:set_string("formspec", get_formspec({ capacity = capacity, storage = 0, usage = 0 }))
end
for i = 0, levels do

View File

@ -15,7 +15,7 @@ minetest.register_craft({
recipe = {
{"elepower_dynamics:induction_coil_advanced", "elepower_dynamics:soc", "elepower_dynamics:induction_coil_advanced"},
{"elepower_nuclear:graphite_rod", "elepower_nuclear:machine_block", "elepower_nuclear:graphite_rod"},
{"elepower_dynamics:wound_silver_coil", "elepower_dynamics:viridisium_gear", "elepower_dynamics:wound_silver_coil"},
{"elepower_dynamics:wound_silver_coil", "elepower_dynamics:electrum_gear", "elepower_dynamics:wound_silver_coil"},
}
})
@ -35,7 +35,7 @@ minetest.register_craft({
recipe = {
{"elepower_dynamics:wound_copper_coil", "elepower_nuclear:graphite_moderator", "elepower_dynamics:wound_copper_coil"},
{"elepower_nuclear:graphite_moderator", "elepower_nuclear:machine_block", "elepower_nuclear:graphite_moderator"},
{"elepower_dynamics:viridisium_gear", "elepower_nuclear:graphite_moderator", "elepower_dynamics:viridisium_gear"},
{"elepower_dynamics:electrum_gear", "elepower_nuclear:graphite_moderator", "elepower_dynamics:electrum_gear"},
}
})
@ -45,7 +45,7 @@ minetest.register_craft({
recipe = {
{"elepower_dynamics:induction_coil_advanced", "elepower_dynamics:graphite_ingot", "elepower_dynamics:induction_coil_advanced"},
{"elepower_nuclear:graphite_moderator", "elepower_nuclear:machine_block", "elepower_nuclear:graphite_moderator"},
{"elepower_dynamics:viridisium_gear", "elepower_dynamics:copper_plate", "elepower_dynamics:viridisium_gear"},
{"elepower_dynamics:electrum_gear", "elepower_dynamics:copper_plate", "elepower_dynamics:electrum_gear"},
}
})
@ -55,7 +55,7 @@ minetest.register_craft({
recipe = {
{"elepower_dynamics:portable_tank", "elepower_dynamics:copper_plate", "elepower_dynamics:portable_tank"},
{"elepower_nuclear:graphite_moderator", "elepower_nuclear:machine_block", "elepower_nuclear:graphite_moderator"},
{"elepower_dynamics:viridisium_gear", "elepower_dynamics:copper_plate", "elepower_dynamics:viridisium_gear"},
{"elepower_dynamics:electrum_gear", "elepower_dynamics:copper_plate", "elepower_dynamics:electrum_gear"},
}
})

View File

@ -21,11 +21,18 @@ end
function ele.formspec.power_meter(capacitor)
if not capacitor then
capacitor = { capacity = 8000, storage = 0 }
capacitor = { capacity = 8000, storage = 0, usage = 0 }
end
local pw_percent = math.floor(100 * capacitor.storage / capacitor.capacity)
local usage = capacitor.usage
if not usage then
usage = 0
end
return ele.formspec.create_bar(0, 0, pw_percent, "#00a1ff") ..
"tooltip[0,0;1,2.5;Power Buffer\n" .. ele.capacity_text(capacitor.capacity, capacitor.storage) .. "]"
"tooltip[0,0;1,2.5;"..
minetest.colorize("#c60303", "Energy Storage\n")..
minetest.colorize("#0399c6", ele.capacity_text(capacitor.capacity, capacitor.storage))..
minetest.colorize("#565656", "\nPower Used / Generated: " .. usage .. " " .. ele.unit) .. "]"
end

View File

@ -1,11 +1,17 @@
local easycrafting = minetest.settings:get("elepower_easy_crafting") == "true"
local ingot = "elepower_dynamics:viridisium_ingot"
if easycrafting then
ingot = "elepower_dynamics:electrum_ingot"
end
-- Receiver
minetest.register_craft({
output = "elepower_wireless:matter_receiver",
recipe = {
{"elepower_dynamics:wound_silver_coil", "elepower_dynamics:soc", "elepower_dynamics:wound_silver_coil"},
{"elepower_dynamics:electrum_gear", "default:steelblock", "elepower_dynamics:electrum_gear"},
{"elepower_dynamics:xycrone_lump", "elepower_dynamics:viridisium_ingot", "elepower_dynamics:xycrone_lump"},
{"elepower_dynamics:xycrone_lump", ingot, "elepower_dynamics:xycrone_lump"},
}
})
@ -15,7 +21,7 @@ minetest.register_craft({
recipe = {
{"elepower_dynamics:wound_silver_coil", "elepower_dynamics:soc", "elepower_dynamics:wound_silver_coil"},
{"elepower_dynamics:xycrone_lump", "default:steelblock", "elepower_dynamics:xycrone_lump"},
{"elepower_dynamics:electrum_gear", "elepower_dynamics:viridisium_ingot", "elepower_dynamics:electrum_gear"},
{"elepower_dynamics:electrum_gear", ingot, "elepower_dynamics:electrum_gear"},
}
})
@ -25,7 +31,7 @@ minetest.register_craft({
recipe = {
{"elepower_dynamics:wound_silver_coil", "elepower_dynamics:soc", "elepower_dynamics:wound_silver_coil"},
{"elepower_dynamics:wound_copper_coil", "default:steelblock", "elepower_dynamics:wound_copper_coil"},
{"elepower_dynamics:electrum_gear", "elepower_dynamics:viridisium_ingot", "elepower_dynamics:electrum_gear"},
{"elepower_dynamics:electrum_gear", ingot, "elepower_dynamics:electrum_gear"},
}
})

5
settingtypes.txt Normal file
View File

@ -0,0 +1,5 @@
[Crafting]
# Enable easier crafting recipes for Elepower
# Removes viridisium (which is fairly rare) as a component.
elepower_easy_crafting (Easy Crafting Recipes) bool false