Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "creative mode" option #437

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions technic/config.lua
Expand Up @@ -13,6 +13,8 @@ local defaults = {
enable_entity_radiation_damage = "true",
enable_longterm_radiation_damage = "true",
enable_nuclear_reactor_digiline_selfdestruct = "false",
creative_mode = "false",
enable_producers = "true",
}

for k, v in pairs(defaults) do
Expand Down
8 changes: 5 additions & 3 deletions technic/machines/HV/init.lua
Expand Up @@ -8,9 +8,11 @@ dofile(path.."/cables.lua")
dofile(path.."/battery_box.lua")

-- Generators
dofile(path.."/solar_array.lua")
dofile(path.."/nuclear_reactor.lua")
dofile(path.."/generator.lua")
if technic.config:get_bool("enable_producers") then
dofile(path.."/solar_array.lua")
dofile(path.."/nuclear_reactor.lua")
dofile(path.."/generator.lua")
end

-- Machines
dofile(path.."/quarry.lua")
Expand Down
12 changes: 7 additions & 5 deletions technic/machines/LV/init.lua
Expand Up @@ -8,11 +8,13 @@ dofile(path.."/cables.lua")
dofile(path.."/battery_box.lua")

-- Generators
dofile(path.."/solar_panel.lua")
dofile(path.."/solar_array.lua")
dofile(path.."/geothermal.lua")
dofile(path.."/water_mill.lua")
dofile(path.."/generator.lua")
if technic.config:get_bool("enable_producers") then
dofile(path.."/solar_panel.lua")
dofile(path.."/solar_array.lua")
dofile(path.."/geothermal.lua")
dofile(path.."/water_mill.lua")
dofile(path.."/generator.lua")
end

-- Machines
dofile(path.."/alloy_furnace.lua")
Expand Down
10 changes: 6 additions & 4 deletions technic/machines/MV/init.lua
Expand Up @@ -8,11 +8,13 @@ dofile(path.."/cables.lua")
dofile(path.."/battery_box.lua")

-- Generators
if technic.config:get_bool("enable_wind_mill") then
dofile(path.."/wind_mill.lua")
if technic.config:get_bool("enable_producers") then
if technic.config:get_bool("enable_wind_mill") then
dofile(path.."/wind_mill.lua")
end
dofile(path.."/generator.lua")
dofile(path.."/solar_array.lua")
end
dofile(path.."/generator.lua")
dofile(path.."/solar_array.lua")

-- Machines
dofile(path.."/alloy_furnace.lua")
Expand Down
41 changes: 41 additions & 0 deletions technic/machines/creative.lua
@@ -0,0 +1,41 @@
local S = technic.getter

minetest.register_abm({
nodenames = {"group:technic_lv", "group:technic_mv", "group:technic_hv"},
label = "Run Machines",
interval = 1,
chance = 1,
action = function(pos,node)
local meta = minetest.get_meta(pos)
local pos1 = {x=pos.x, y=pos.y-1, z=pos.z}
local tier = technic.get_cable_tier(minetest.get_node(pos1).name)
local meta = minetest.get_meta(pos)
if not tier then
meta:set_int("active", 0)
return
end
meta:set_int("active", 1)
meta:set_int("LV_EU_input", meta:get_int("LV_EU_demand"))
meta:set_int("MV_EU_input", meta:get_int("MV_EU_demand"))
meta:set_int("HV_EU_input", meta:get_int("HV_EU_demand"))
local nodedef = minetest.registered_nodes[node.name]
if nodedef and nodedef.technic_run then
nodedef.technic_run(pos, node)
end
end,
})

minetest.register_lbm({
nodenames = {"technic:switching_station", "technic:power_monitor"},
name = "technic:update_infotext",
label = "Update switching station / power monitor infotext",
run_at_every_load = true,
action = function(pos, node)
local meta = minetest.get_meta(pos)
if node.name == "technic:switching_station" then
meta:set_string("infotext", S("Switching Station"))
elseif node.name == "technic:power_monitor" then
meta:set_string("infotext", S("Power Monitor"))
end
end,
})
5 changes: 5 additions & 0 deletions technic/machines/init.lua
Expand Up @@ -13,3 +13,8 @@ dofile(path.."/supply_converter.lua")

dofile(path.."/other/init.lua")

if technic.config:get_bool("creative_mode") then
--The switching station does not handle running machines
--in this mode, so alternative means are used to do so.
dofile(path.."/creative.lua")
end
6 changes: 6 additions & 0 deletions technic/machines/power_monitor.lua
Expand Up @@ -35,6 +35,12 @@ minetest.register_node("technic:power_monitor",{
end,
})

if technic.config:get_bool("creative_mode") then
--Power distribution is not used in this mode,
--so the power monitor is inert and never needs to run.
return
end

minetest.register_abm({
nodenames = {"technic:power_monitor"},
label = "Machines: run power monitor",
Expand Down
7 changes: 7 additions & 0 deletions technic/machines/switching_station.lua
Expand Up @@ -88,6 +88,13 @@ minetest.register_node("technic:switching_station",{
},
})

if technic.config:get_bool("creative_mode") then
--Power distribution is not used in this mode,
--so the switching station is inert and none of the
--network processing is needed.
return
end

--------------------------------------------------
-- Functions to traverse the electrical network
--------------------------------------------------
Expand Down