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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting idea...
technic/machines/creative.lua
Outdated
|
||
minetest.register_lbm({ | ||
nodenames = {"technic:switching_station","technic:power_monitor"}, | ||
name = "technic:update_infotext", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
run_at_every_load
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It only needs to run once when switching from non-creative to creative. Since the LBM is not registered in non-creative, the first load after switching to creative will always run it. After that, it won't run again and that's fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creative mode is just an option which can be switched on and off as many times as world owner desires.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, and the LBM runs once each time it is switched on. I have confirmed that it works as intended even when repeatedly switching back and forth.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the documentation:
run_at_every_load = false,
-- Whether to run the LBM's action every time a block gets loaded,
-- and not just for blocks that were saved last time before LBMs were
-- introduced to the world.
So you seem to rely on undocumented behavior. minetest/minetest#7660
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is how LBMs were explained to me when they were first introduced, but I'll go ahead and add this. I suppose it can always be removed later if the docs are improved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would suit better IMO is minetest/minetest#5303, but that is not in MT yet (PR#5653).
technic/machines/init.lua
Outdated
@@ -13,3 +13,8 @@ dofile(path.."/supply_converter.lua") | |||
|
|||
dofile(path.."/other/init.lua") | |||
|
|||
if technic.config:get_bool("enable_creative_mode") then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should also check whether server itself runs in the creative mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? I don't see why it shouldn't be possible to mix and match as the server owner desires.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or rename the option to creative_mode
, as it forces that, not merely allows.
possible to mix and match
That is always possible as technic
is free.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, option name changed.
technic/machines/creative.lua
Outdated
chance = 1, | ||
action = function(pos,node) | ||
local meta = minetest.get_meta(pos) | ||
local pos1 = {x=pos.x,y=pos.y-1,z=pos.z} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comma must be followed by whitespace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That line was actually copy/pasted from existing switching station code, but I'll go ahead and change that in a moment.
This does not change the default behavior, but if "creative_mode" is set to true in technic.conf, this completely disables power distribution and causes the following to happen, regardless of whether there is a switching station connected: * Switching Stations and Power Monitors become inert * Generators placed on top of a suitable cable will run (consume fuel if applicable, update infotext, and so on) * Batteries placed on top of a suitable cable will charge at maximum speed and remain fully charged * Machines that consume energy and are placed on top of a suitable cable will run normally, regardless of whether any power is present * Power distribution logic will not run and networks will not be calculated
Defaults to true, but if set to false skips registering everything that produces energy. Intended for use in conjunction with creative mode but will work regardless.
This also now includes an "enable_producers" option, added by request. See the bottom of the first post for more information on this. |
People who use technic in creative mode want to test whether their circuit idea might work. I don't see any benefits in adding a creative_mode setting, also because the machine outputs can be obtained by the creative inventory. |
We've actually managed to achieve what we were trying to do (lag reduction, mostly) by other means, so I'm closing this. I'll leave my repository with this code up for a while in case there's any interest in it. |
This does not change the default behavior, but if "creative_mode" is set to true in technic.conf, this completely disables power distribution and causes the following to happen, regardless of whether there is a switching station connected:
This also includes an "enable_producers" option, added at the request of a server owner (I'd be open to a better name for this one). The default is true, but if set to false it skips registering all generator/producer nodes. It is intended for use in conjunction with creative mode but will work, albeit somewhat pointlessly, regardless.