Skip to content
New issue

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

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

Already on GitHub? # to your account

[ENHANCEMENT + BUGFIX] small script event/module overhaul #4172

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

cyn0x8
Copy link
Contributor

@cyn0x8 cyn0x8 commented Feb 18, 2025

Does this PR close any issues? If so, link them below.

fixes #4167
fixes #3928

Briefly describe the issue(s) fixed.

after messing with modules a lot, ive come up with a few changes id like implemented!

this pr makes some additions and changes to certain script events, primarily relating to modules and playstate

  • module onDestroy now calls in reverse module priority order (its reverse so that modules dependent on others have the callback first)
  • module onCreate is now called whenever the module is created, including after a mod reload
  • modules use new IGlobalScriptedClass template (extends IPlayStateScriptedClass and IStateChangingScriptedClass) for the following:
    • new module onGameInit(event:ScriptEvent) callback for what is the current onCreate behavior, that is only called only when the game first starts
    • new module onGameClose(event:GameCloseScriptEvent) callback for whenever the game closes
    • new event type GameCloseScriptEvent extends ScriptEvent that holds the exit code
  • PlayState no longer calls onDestroy in modules (only module destruction will)
  • IPlayStateScriptedClass now has:
    • onPlayStateCreate(event:ScriptEvent) - helper event, called near the end of PlayState.instance.create() right before the countdown starts
    • onPlayStateClose(event:ScriptEvent) - helper event, called before PlayState does cleanup
  • module onCreate will be called regardless of active (onDestroy currently does this)

Warning

this has breaking changes!!
existing modules should:

  • change onCreate to onGameInit
  • check for active in onCreate if any code depends on it not running when inactive
  • move onDestroy code that deals with PlayState destruction to onPlayStateClose

Include any relevant screenshots or videos.

8mb.video-NRT-8aGTNnTB.mp4

@github-actions github-actions bot added status: pending triage Awaiting review. pr: haxe PR modifies game code. size: large A large pull request with more than 100 changes. labels Feb 18, 2025
@AbnormalPoof AbnormalPoof added type: enhancement Involves an enhancement or new feature. topic: mods Related to the creation or use of mods. labels Feb 18, 2025
@cyn0x8 cyn0x8 changed the title [ENHANCEMENT + BUGFIX] small script event overhaul [ENHANCEMENT + BUGFIX] small script event/module overhaul Feb 25, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
pr: haxe PR modifies game code. size: large A large pull request with more than 100 changes. status: pending triage Awaiting review. topic: mods Related to the creation or use of mods. type: enhancement Involves an enhancement or new feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants