Skip to content

Conversation

@TFSMads
Copy link
Contributor

@TFSMads TFSMads commented Oct 22, 2025

Problem

functions appearing before on unload event is unloaded before event is called.

Solution

When unloading a script unload event is moved to front of list so that it is triggered before unloading of functions.

Testing Completed

I have tested it on version 1.21.10.

Supporting Information


Completes: #8233
Related: none

@TFSMads TFSMads requested review from a team as code owners October 22, 2025 15:09
@TFSMads TFSMads requested review from APickledWalrus and Absolutionism and removed request for a team October 22, 2025 15:09
@skriptlang-automation skriptlang-automation bot added the needs reviews A PR that needs additional reviews label Oct 22, 2025
Copy link
Member

@APickledWalrus APickledWalrus left a comment

Choose a reason for hiding this comment

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

Rather than hardcoding this comparator in, I think an alternative option would be to unload based on Structure priority (in reverse order to loading)

@skriptlang-automation skriptlang-automation bot removed the needs reviews A PR that needs additional reviews label Oct 23, 2025
@sovdeeth sovdeeth added the bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. label Oct 23, 2025
@sovdeeth sovdeeth linked an issue Oct 23, 2025 that may be closed by this pull request
1 task
@sovdeeth sovdeeth moved this to In Review in 2.13 Releases Oct 23, 2025
Copy link
Member

@APickledWalrus APickledWalrus left a comment

Choose a reason for hiding this comment

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

I believe this won't work if the function is in a different script from the unload event structure. This needs to be reworked so that all structures across all unloading scripts are sorted together (similar to how it is done in the loading phase).

@TFSMads
Copy link
Contributor Author

TFSMads commented Nov 2, 2025

All structures across multiple scripts should now be unloaded in reverse order based on priority,

Testing completed

unloada.sk

function a():
	add 1 to {test-unload}

on unload:
	clear {test-unload}
	a()
	b()
	c()
	d()
	if {test-unload} is 4:
		broadcast "test-unload is 4"
	else:
		broadcast "test-unload is not 4 as expected"
	
function b():
	add 1 to {test-unload}

unloadb.sk

function c():
	add 1 to {test-unload}

on unload:
	clear {test-unload}
	a()
	b()
	c()
	d()
	if {test-unload} is 4:
		broadcast "test-unload is 4"
	else:
		broadcast "test-unload is not 4 as expected"
	
function d():
	add 1 to {test-unload}
image

All functions from both scripts are available in unload event.

Copy link
Member

@APickledWalrus APickledWalrus left a comment

Choose a reason for hiding this comment

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

I think this is almost ready, great work!

@github-project-automation github-project-automation bot moved this from In Review to Awaiting Merge in 2.13 Releases Dec 2, 2025
@skriptlang-automation skriptlang-automation bot added the patch-ready A PR/issue that has been approved and is ready to be merged/closed for the next patch version. label Dec 2, 2025
@sovdeeth sovdeeth merged commit 8cb697a into SkriptLang:dev/patch Dec 2, 2025
5 checks passed
@skriptlang-automation skriptlang-automation bot added the completed The issue has been fully resolved and the change will be in the next Skript update. label Dec 2, 2025
@github-project-automation github-project-automation bot moved this from Awaiting Merge to Done - Awaiting Release in 2.13 Releases Dec 2, 2025
@skriptlang-automation skriptlang-automation bot removed the patch-ready A PR/issue that has been approved and is ready to be merged/closed for the next patch version. label Dec 2, 2025
@sovdeeth sovdeeth moved this from Done - Awaiting Release to Done - Released in 2.13 Releases Dec 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. completed The issue has been fully resolved and the change will be in the next Skript update.

Projects

Status: Done - Released

Development

Successfully merging this pull request may close these issues.

on unload is called after functions are unloaded

4 participants