How is lua executed? in row or simultan ?

Serp

King
Joined
Apr 1, 2015
Messages
661
What would be the print result of the following code?

Code:
test = 1

function Testfunc()
    Changevalue1()
    print(test)
end

function Changevalue1()
    test = 2
    Changevalue2()
end

function Changevalue2()
    test = 3
end

Testfunc()

If Lua is executed in row, the print result would be 3.
If not... I think no one would know the answer and it could be 1,2 or 3 by random :D

So anyone knows if it is in row or simultan?

edit
I ask, because it is important for my scripts and I can't imagine it is in row, since there are so many functions combinated and it has to be fast... I think in row it would be slow.
 
Lua scripts are parsed and run line-by-line, so that snippet will output 3 at the end. You can check for yourself these sorts of isolated Lua snippets in the Lua demo page to check logic and stuff.

I believe Lua in multiple contexts are run simultaneously, but this is from anecdotal evidence and my own observations with my TSL Serializer; I have no idea on a technical level if this is what Firaxis does or not.
 
Lua scripts are parsed and run line-by-line, so that snippet will output 3 at the end. You can check for yourself these sorts of isolated Lua snippets in the Lua demo page to check logic and stuff.

I believe Lua in multiple contexts are run simultaneously, but this is from anecdotal evidence and my own observations with my TSL Serializer; I have no idea on a technical level if this is what Firaxis does or not.
thanks :)

this lua demo website is really helpful! :)
 
Top Bottom