I found a solution!
LUA has a function loadstring() that can load a string as a block, check its syntax and returns a usable global function of that new block. And if the syntax is invalid, an error is returned.
So you can then run that function with an assert() function.
This simply runs a function that returns 0, using a string parameter
Then this is what I did in MMF2:
And in the LUA script:
- (Lua object) : Call Function "runstring" with "return missionlist.total" with 1 return
- (Counter) : Set Counter to LuaValRet("(Lua object), 0")
So in the end, the Counter gets the numerical value found in the table missionlist at the key total :cool:
runstring = function(str)
This even makes it possible to add or modify objects in the loaded LUA script at the MMF runtime. Pretty awesome find!
The only problem though is that if LUA returns a bool value (true, false) it makes MMF crash. I think this is because the LUA extension only supports numbers and strings.