Bully-Board
Bully Modding Section => Modding Questions/Help => Topic started by: RBS ID on January 20, 2022, 07:23:36 PM
-
Does anyone know, what is Coroutine?
-
It's simply a thread, provided by Lua in order to do multithreading.
In Bully, we have CreateThread function that works pretty much like coroutine (https://www.lua.org/pil/9.html). But, CreateThread function does not provide any information about status of the thread itself, so we don't know exactly as if the thread is already dead or not. Unless you made a continuous running function or inconstant variable that changes every run in the loop just to check the thread status.
On the other hand, coroutine has coroutine.status function which returns a state of coroutine (unlike CreateThread). But, coroutine function does not run independently as CreateThread function does, which means you also need a bigger space to operate that thing.
However, this explanation is just a simple logic comparation between CreateThread and Coroutines. I personally use coroutine function just for making infinite loop of "potential crash infinite loop", so it can restart once it crashed. What if i was pretty sure it won't crash? then i would prefer to use CreateThread instead.
-
Are coroutine based functions available in the game?
-
Are coroutine based functions available in the game?
Yes, they are.
If you curious about any function existence, you can just check it by the game.
if IsButtonBeingPressed(3, 0) then
TextPrintString(tostring(type(coroutine.create)), 4, 1)
end