PythonCode Posted July 16 Share Posted July 16 in Lua, camera:SetFov(##) crashes the engine. in Lua, this Split command crashes the game engine. local sarr = s:Split(",") Quote Link to comment Share on other sites More sharing options...
PythonCode Posted July 16 Author Share Posted July 16 Also something is just not right with lua tables and arrays, I purchased an O'Rileys lua book to learn lua with and this example comes striaght out of the book for lua 5.4 and it errors in the Ultra engine. N = 10 M = 10 mt = {} -- create the matrix for i=1,N do for j=1,M do mt[i*M + j] = 0 end end Quote Link to comment Share on other sites More sharing options...
PythonCode Posted July 16 Author Share Posted July 16 To simplify the problem either further; this example fails. This should not fail, it's the easiest of 2-dim tables/arrays that lua has to offer. p = {} for t = 1 , 10 do p[t] = {} end p[1][1] = 1 Quote Link to comment Share on other sites More sharing options...
PythonCode Posted July 16 Author Share Posted July 16 I've noticed that adding Local to the p = {} seems to have corrected it, plus Split(variable, dilmeter) works.. so only thing I could not get working is SetFov() Quote Link to comment Share on other sites More sharing options...
Josh Posted July 16 Share Posted July 16 2 hours ago, PythonCode said: in Lua, camera:SetFov(##) crashes the engine. in Lua, this Split command crashes the game engine. local sarr = s:Split(",") The correct syntax for the command in Lua is like this: s = "1, 2, 3" sarr = Split(s, ",") I added these a while back, but the docs need some updating. Let me see about that. BTW, the console in the editor is a convenient way to test Lua code. Just make sure that any variables you set are not local, or they will get collected right after the code executes. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted July 16 Share Posted July 16 It seems that Camera:SetFov is working correctly. I tried this in the console: > cam = CreateCamera(nil) > cam:SetFov(90) > cam userdata > a = cam.SetFov > a function Perhaps the camera variable is nil or the argument for the angle is not a number? Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
PythonCode Posted July 16 Author Share Posted July 16 Hmmm debug gives me this: cam:Turn(55,0,0) cam:SetFov(90) sol: runtime error: C:/Ultra/Defense/Source/MapLoad.lua:36: attempt to call a nil value (method 'SetFov') stack traceback: C:/Ultra/Defense/Source/MapLoad.lua:36: in function 'base.MapLoad' Quote Link to comment Share on other sites More sharing options...
Josh Posted July 16 Share Posted July 16 Maybe the "cam" variable is an entity, and has to be cast to a camera? cam = Camera(entity) Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted July 17 Share Posted July 17 On 7/16/2024 at 8:08 AM, PythonCode said: Also something is just not right with lua tables and arrays, I purchased an O'Rileys lua book to learn lua with and this example comes striaght out of the book for lua 5.4 and it errors in the Ultra engine. N = 10 M = 10 mt = {} for i=1,N do for j=1,M do mt[i*M + j] = 0 end end On 7/16/2024 at 8:10 AM, PythonCode said: To simplify the problem either further; this example fails. This should not fail, it's the easiest of 2-dim tables/arrays that lua has to offer. p = {} for t = 1 , 10 do p[t] = {} end p[1][1] = 1 I ran both of these examples in the editor console (after removing the comment in the first one) and they ran without any trouble. You can just copy and paste them into a single line, hit enter, and they work fine. If you paste this into the editor console it will print out '1': p = {} for t = 1, 10 do p[t] = {} end p[1][1] = 1 Print(p[1][1]) Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted July 18 Share Posted July 18 Lua string documentation has been updated. It will take a couple hours for the docs system to recache the new pages: https://github.com/UltraEngine/Documentation/blob/master/Lua/Strings.md Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Solution Josh Posted October 28 Solution Share Posted October 28 I believe this is all resolved. Please let me know if there are any problems. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.