-
Notifications
You must be signed in to change notification settings - Fork 187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Suggestion] Implement 'on_hot_reload' function for mods #602
Comments
Anything executed at file scope of main.lua (i.e. anything not in a function) is executed immediately upon the loading or reloading of a mod. |
yeah so i guess this is only important in a dev environment. for example in my init function i will cache a load of info, and say i want to get the local player character but that info is not available on the main menu. so if i was to call the init outside of it is obviously nothing important but would be a nice QoL feature for me personally. |
A workaround: maybe you need
local function AfterInitGameStateHook()
-- TODO
end
-- The game has been initialised
local ModGameStart = ModRef:GetSharedVariable("ModGameStart")
if ModGameStart and type(ModGameStart) == "boolean" then
print("Mod hot-reloading.\n")
AfterInitGameStateHook()
else
print("First Start Game.\n")
-- Called after AGameModeBase::InitGameState
RegisterInitGameStatePostHook(function(GameState)
if ModRef:GetSharedVariable("ModGameStart") then
return
end
ModRef:SetSharedVariable("ModGameStart", true)
print("AfterInitGameStateHook\n")
AfterInitGameStateHook()
end)
end
|
for debugging purposes it would be nice to have an event that we could hook into to execute initialisation for example that would otherwise be called in
ServerAcknowledgePossession
which is my preferred initialisation event.The text was updated successfully, but these errors were encountered: