Jump to content

"Nil value" ?


SpiderPig
 Share

Recommended Posts

I'm learning lua but keep getting error messages with functions like "SetPosition", "Translate" and "Move"....

What am I doing wrong here?

 

require("scripts/class")

local class=CreateClass(...)

function class:CreateObject(model)
       local object=self.super:CreateObject(model)

       function object:UpdateMatrix()
           object:Translate(Vec3(1),1)
end

end


Link to comment
Share on other sites

uh. you are moving the object every time the matrix is updated? looks like a you are creating an infinite loop...

 

as for the error, use 'object.model' or just 'model' when using Entity commands as the 'object' itself is not an entity...

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Yes, I want to move the object every time it updates, am I right in assuming that the "UpdateMatrix" function is automatically called?

 

As for the error - I tried;

 

function object:UpdateMatrix()
 object.model:Translate(Vec3(1),1)
end

 

but now I get another error 'Failed to open file "C:/Leadwerks Engine SDK/error in error handling" '.

 

It seems to only have a problem inside the "UpdateMatrix" function itself....

Link to comment
Share on other sites

what exactly are you trying to accomplish? just constant movement? then just use the 'object:Update()' function... i would assume the error is from you creating an infinite loop that calls itself from inside its own function... you would have the same problem if you did the same with any other function that called itself from inside itself... like using 'object.model:SetKey("name","killerclown")' inside the 'object:SetKey(key,value)' function...

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

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...