fumanshoo Posted February 1, 2013 Share Posted February 1, 2013 So I have no idea how to use the "self" command and I think this is a nice chance to figure it out. In the editor, I have the default directional light. If I add a line of code to the light saying: [/size] self.light:Turn(Vec3(AppSpeed()*0.5,AppSpeed()*0,AppSpeed()*0)) should my directional light turn? I don't have much time today to research things, so I thought I might ask you guys... Quote Link to comment Share on other sites More sharing options...
Road Kill Kenny Posted February 1, 2013 Share Posted February 1, 2013 Yes it should Quote STS - Scarlet Thread Studios AKA: Engineer Ken Fact: Game Development is hard... very bloody hard.. If you are not prepared to accept that.. Please give up now! Link to comment Share on other sites More sharing options...
fumanshoo Posted February 1, 2013 Author Share Posted February 1, 2013 In that case, I think a better question is where to put it. I have put it in what I thought would be the right spot, but I came up with an error message. I am having a hard time just copying and pasting that line in the directional light's code because it seems as though I need to start a whole new function, but I have no idea how to do that even after looking at the directional light's code a few times... Quote Link to comment Share on other sites More sharing options...
macklebee Posted February 1, 2013 Share Posted February 1, 2013 Well you would have to use it in one of the default object functions that get called upon every flip, like update. The current default directional light script only has the object functions for SetKey and GetKey, so you would have to add that yourself. As for 'self' in this instance, it is the same as saying object and you would use it inside an object function. function object:Update() self.light:Turn(Vec3(AppSpeed()*0.5,0,0)) end 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...
fumanshoo Posted February 1, 2013 Author Share Posted February 1, 2013 I got lost when you said SetKey and GetKey and add that yourself Are you saying that I have to add something like "require(Update)" in order for Updates to work? and I also do not fully understand SetKey or GetKey. I don't think I need to know it yet in order to get through a simple day/night cycle, so no need to tell me unless I need it... Thanks for the response though. I just learned something new and useful Quote Link to comment Share on other sites More sharing options...
Road Kill Kenny Posted February 1, 2013 Share Posted February 1, 2013 Wait are you coding this straight with LUA or are you scripting a Day/Night object that you place into the scene? Have you gone through Aggror's LUA tutorials. They are basically an exact copy of Josh's C++ tutorials except for LUA. Quote STS - Scarlet Thread Studios AKA: Engineer Ken Fact: Game Development is hard... very bloody hard.. If you are not prepared to accept that.. Please give up now! Link to comment Share on other sites More sharing options...
fumanshoo Posted February 1, 2013 Author Share Posted February 1, 2013 What I am trying to do is place the default directional light into the scene and then make it rotate. As if it were a day/night simulation. I could always parent it to a pivot later, but for now, I just want to keep it simple. I just went onto Aggror's channel and realized I missed a few and I will check them out when I have more time... I am not very fond of scripting in the Editor... I might as well just do it straight from Lua... Quote Link to comment Share on other sites More sharing options...
fumanshoo Posted February 1, 2013 Author Share Posted February 1, 2013 So in that case, I guess it would be wise to do it straight with Lua. What I have is: directional = CreateDirectionalLight() directional:SetRotation(Vec3(45,45,45,)) TurnEntity(directional, (Vec3, AppSpeed()*.5,0,0))) I don't see why this isn't working... Quote Link to comment Share on other sites More sharing options...
DarthRaff Posted February 1, 2013 Share Posted February 1, 2013 Hello, Just copy what Macklebee Say in the directional light script inside " function class:CreateObject(model) " right after the function "GetKey" and save Quote Link to comment Share on other sites More sharing options...
fumanshoo Posted February 1, 2013 Author Share Posted February 1, 2013 oh wow, thanks. I think I get how that works now... 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.