Jump to content

Simplistic Day/Night


fumanshoo
 Share

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

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

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 :D

Link to comment
Share on other sites

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.

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

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

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