SuperTux / supertux

SuperTux source code
https://supertux.org
GNU General Public License v3.0
2.49k stars 470 forks source link

Run init-script only once after a sector has loaded #3011

Open tobbi opened 1 month ago

tobbi commented 1 month ago

Fixes #698

Narre commented 1 month ago

This is a great option to have, especially for infinitely looping scripts that are only meant to trigger once, such as a loop that randomises the time between lightning strikes, however, I think there remains the need for scripts that are triggered every time on sector entry (such as my STAGE project, that needs to check for changes made in other sectors when a sector is entered). I have a few possible solutions in mind.

tobbi commented 1 month ago

Basically you want an option that you can check to specify whether it's run every time. I think I need to also reset the flag when the sector is reset.

tobbi commented 1 month ago

Discussion question: Should I keep the default of "run every time" for backward compatibility reasons, but make an option of "run only once".

Can I get some input on this?

@Narre @tylerandari13 @Vankata453

Vankata453 commented 1 month ago

Yeah, I believe a script to run only on sector initialization should be a separate option.

Narre commented 1 month ago

I agree, with both options available, the default should be the old behaviour to avoid needlessly breaking older levels.

tobbi commented 1 month ago

This is ready for review. I haven't tested the actual behaviour but to quote "I, Robot": "My logic is undeniable". https://www.youtube.com/watch?v=LH-G8c3TUac

tylerandari13 commented 1 month ago

Every time you load a sector it replaces all the instances with new instances. Is this also gone with this PR or is that untouched?

tobbi commented 1 month ago

Every time you load a sector it replaces all the instances with new instances. Is this also gone with this PR or is that untouched?

What do you mean by "instances" in this case?

tylerandari13 commented 1 month ago

Every time you load a sector it replaces all the instances with new instances. Is this also gone with this PR or is that untouched?

What do you mean by "instances" in this case?

Basically the exposed objects. (theyre referred to as instances by Squirrel)