I put together a small lua package that contains a few things that could be useful for a lua coder: https://github.com/asarium/FSOLuaUtilsContents:require package loader
The package contains a loader implementation so you can use require
with modules that exist within the file system of FSO (that also includes VP files).
There is not much more to know about it except that when the loader has been initialized the variable cfileRequireInitialized
is set to true
. You can use that to delay the usage of require until the loaders have been initialized.Coroutine manager
You can now use coroutines within FSO to execute code distributed over multiple frames (if you don't know what coroutines are you can read this tutorial
To use coroutines you first have to require
the 'fsoCoroutine' module (fsoCoroutine = require("fsoCoroutine")
The currently available function in that module are:
- startCoroutine(function): Calling this with a function argument will create a new coroutine and return it. From that point on the coroutine will be resumed every frame until it is done.
- waitUntil(function): This function will yield the coroutine until the given function returns true. The argument can be any function but this package contains some functions that handle most use-cases.
- secondsPassed(timeDiff): Returns a function that returns false until the given amount of seconds have passed based on the mission time of FSO. This function should be used with waitUntil() (see the example for a usage example).
local fc = require("fsoCoroutine")