Jump to content

Fov and Split


PythonCode
 Share

Go to solution Solved by Josh,

Recommended Posts

  • PythonCode changed the title to Fov and Split

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

 

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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.

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

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?

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

Maybe the "cam" variable is an entity, and has to be cast to a camera?

cam = Camera(entity)

 

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

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])

 

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

  • 3 months later...

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...