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

Add "creative mode" option #437

wants to merge 2 commits into from

Conversation

cheapie
Copy link
Contributor

@cheapie cheapie commented Aug 18, 2018

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

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.

Copy link
Contributor

@numberZero numberZero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting idea...


minetest.register_lbm({
nodenames = {"technic:switching_station","technic:power_monitor"},
name = "technic:update_infotext",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

run_at_every_load?

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

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).

@@ -13,3 +13,8 @@ dofile(path.."/supply_converter.lua")

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

if technic.config:get_bool("enable_creative_mode") then
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, option name changed.

chance = 1,
action = function(pos,node)
local meta = minetest.get_meta(pos)
local pos1 = {x=pos.x,y=pos.y-1,z=pos.z}
Copy link
Contributor

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.

Copy link
Contributor Author

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.

cheapie added 2 commits August 19, 2018 16:05
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.
@cheapie
Copy link
Contributor Author

cheapie commented Aug 19, 2018

This also now includes an "enable_producers" option, added by request. See the bottom of the first post for more information on this.

@SmallJoker
Copy link
Member

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.

@cheapie
Copy link
Contributor Author

cheapie commented Aug 25, 2018

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.

@cheapie cheapie closed this Aug 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants