Hello, I want to implement onExtensionLoaded and onExtensionUnloaded to create and then clean-up scene objects. Unfortunately, I just cannot seem to get onExtensionLoaded and onExtensionUnloaded to be called. Pressing Ctrl + L doesn't seem to help in this case either. I've added logging statements into both of them, but I am not seeing them in the console. Oddly enough, the onVehicleSpawned and onVehicleDestroyed are called as expected. This is causing TSStatic objects that were created during onVehicleSpawned to stay in the scenewhen they are supposed to be cleaned up by onExtensionUnloaded when I press Ctrl + L to reload GELUA. I've also tried onInit, but that doesn't seem to be called either. Here is a very cut-down version of my code: Code: -- lua/ge/extensions/<redacted>/main.lua local M = {} local mName = "myExtension" local function onExtensionUnloaded() log("I", mName, "Extension unloading") -- Clean up end local function onExtensionLoaded() log("I", mName, "Extension initializing") -- Do stuff end local function onVehicleSpawned(vehicleId) log("I", mName, "Vehicle loaded") -- This works end local function onVehicleDestroyed(vehicleId) log("I", mName, "Vehicle destroyed") -- This works end M.onVehicleSpawned = onVehicleSpawned M.onVehicleDestroyed = onVehicleDestroyed M.onExtensionUnloaded = onExtensionUnloaded M.onExtensionLoaded = onExtensionLoaded return M I also have included a modScript.lua file with the following included: Code: -- scripts/<redacted>/modScript.lua setExtensionUnloadMode("<redacted>_main", "manual") --- Post updated --- @stenyak Oh yeah forgot to mention you so you're notified.
Checked it, it works. I don't know why onExtensionLoaded is not called for you. --- Post updated --- modScript.lua files are executed when a mod is loaded, the setExtensionUnloadMode function adds the script to the table of extensions that will be loaded after all mods.
Here's what I figured manually ... -- occurs at start of game (main menu) as well as CTRL-L reload - not when map/level loaded local function onInit() -- occurs when map/level loaded; not after reload CTRL-L - check for state == 2 local function onWorldReadyState(state) -- occurs at start of game (main menu) as well as CTRL-L reload - not when map/level loaded local function onExtensionLoaded() Also I believe those function events are only called on the main mod lua file, not any loaded via require().