DreamWeave-MP / CoreScripts

The serverside Lua scripts used to implement core functionality in S3MP.
MIT License
0 stars 1 forks source link

Implement scriptID for customEventHooks #26

Closed HotaruBlaze closed 11 months ago

HotaruBlaze commented 1 year ago

This allows you to easily remove and load active scripts via its scriptID without restarting.

When registering an handler/validator, you can optionally receive an scriptID, tied to your filename. This can be used to remove the event from tes3mp's event table This also adds a "OnScriptUnload" event that's triggered before we unload that scripts functions



This currently has a dedicated command for unloading due to their being an issue around /load and the filepath not matching what tes3mp is currently using, tho after figuring out this blocking issue, we should be able to implement it correctly into /load This is fixed now

/load           = .\\/server/scripts/custom/chatUtils.lua
server loading  = .\server\scripts\custom/chatUtils.lua
magicaldave commented 1 year ago

Alright, so we've tested this functionality on two debug servers now. It seems to work. Let's please get a list in here of what this MR is missing or cannot do so we can approach completing it.

HotaruBlaze commented 1 year ago

The only real issue is the paths don't work between tes3mp loading it via require and via /load, because the paths don't match, it'll load the script twice

HotaruBlaze commented 1 year ago

I added a checklist of the main issues I'm aware of, not gonna address the debug issue until that comes about as that's gonna end up requiring us to add another wrapper or changing how scripts are loaded.

HotaruBlaze commented 1 year ago

Don't merge this yet, theirs a bug I'm currently diagnosing

HotaruBlaze commented 1 year ago

Fixed it, it was a bug from when we removed the lookup table from customEventHooks.generateScriptID() and made it always generate a new scriptID with the fixed seed logic.

HotaruBlaze commented 1 year ago

We need to add an OnScriptLoad validator and handler, as well as move this logic into eventHandler.

This is now blocked until its added, as many scripts depend on OnServerInit or OnServerPostInit and theirs currently no way for the script itself to know it was loaded.