SpiderPig Posted September 16, 2011 Share Posted September 16, 2011 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 Quote Link to comment Share on other sites More sharing options...
macklebee Posted September 16, 2011 Share Posted September 16, 2011 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... Quote 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 More sharing options...
SpiderPig Posted September 16, 2011 Author Share Posted September 16, 2011 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.... Quote Link to comment Share on other sites More sharing options...
macklebee Posted September 16, 2011 Share Posted September 16, 2011 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... Quote 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 More sharing options...
SpiderPig Posted September 16, 2011 Author Share Posted September 16, 2011 I'm just trying to get constant movement of the object - so it seems I wasn't using the right function... my newness to lua is the problem here Many thanks macklebee! Quote 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.