WohlSoft / LunaLua

LunaLua - LunaDLL with Lua, is a free extension mod for SMBX 1.3 game engine, core of the X2 project.
https://codehaus.moe/
GNU General Public License v3.0
33 stars 12 forks source link

Add Misc.getLoadingFinished #38

Closed MrDoubleA232 closed 2 years ago

MrDoubleA232 commented 2 years ago

Adds a function to detect if the load screen is done loading, and is only continuing due to Misc.setLoadScreenTimeout. Requires a change to loadscreen.lua, and works similarly to Misc.setLoadScreenTimeout (in that it uses a global lua variable).

Example use case is a load screen with an animation when it finishes loading to transition to the level, like so:

if Misc.getLoadingFinished() then
    loadingFinishedTimer = loadingFinishedTimer + 1
end

if loadingFinishedTimer <= loadingExitDuration then
    Misc.setLoadScreenTimeout(30)
else
    Misc.setLoadScreenTimeout(0)
end

... Or writing to a file with loadscreen-side data for the level:

if Misc.getLoadingFinished() then
    local f = io.open(episodePath.. "myFile.txt","w")

    f:write(tostring(myTimer))
    f:close()
end