System.Debug.println( "Testing!" )
tbl = { 1, 2, 3; }
System.Debug.println( "Table constructed" )
for k in tbl do
System.Debug.println( "YAY" )
end
System.Debug.println( "Done!" )
Output:
Testing!
Table constructed
The VM seems to be dying at the for loop, complaining about trying to call a nil value. Why? Even excluding the rest of the code and leaving the table constructor and the for loop, the same thing happens!
🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
Lua - for loop
Having some problems with Lua. I''m running Lua 5.0, with some of my own extensions built in (core language remains the same - C API has been extended in places, my own libraries are naturally scattered throughout), but seem to be having all sorts of trouble with the following code:
The actual error, courtesy of lua_pcall:
Lua_Display_Init: 0
Lua_Input_Init: 0
Lua_Debug_Init: 0
Testing!
Table constructed
[string "test/scripts/display.lua"]:7: attempt to call a nil value
Lua_Display_Init: 0
Lua_Input_Init: 0
Lua_Debug_Init: 0
Testing!
Table constructed
[string "test/scripts/display.lua"]:7: attempt to call a nil value
Solved.
Strangely, even core constructs like the generic for loop (not the numeric version, tho) rely on libraries that are not core to the lua interpreter - the Lua base library must also be loaded.
Although this makes sense, it strikes me as odd that the language''s generic for loop is broken without this library - and it''s not noted in the documentation as far as I can see.
Oh well. Fixed now.
Strangely, even core constructs like the generic for loop (not the numeric version, tho) rely on libraries that are not core to the lua interpreter - the Lua base library must also be loaded.
Although this makes sense, it strikes me as odd that the language''s generic for loop is broken without this library - and it''s not noted in the documentation as far as I can see.
Oh well. Fixed now.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement