AggrorJorn Posted July 25, 2010 Share Posted July 25, 2010 In this topic DaveLee requested some help with a rotating light. I created a simple rotating light with a small menu and everything is working fine except for one thing: when you drag the rotating light in to the scene, it doesn't rotate immediately. Although it has a default value set to it. As it is now, you have to go to the lua menu and press 'Apply' first before the light starts to rotate. Does anybody know how the light can use this rotation value directly from the start? It is a small thing, but it bothers me a lot. Here is the light: Rotating light.zip Quote Link to comment Share on other sites More sharing options...
Rick Posted July 25, 2010 Share Posted July 25, 2010 You are using the lua variable rotationSpeed in Update(), but aren't setting it to a value until SetKey is called. You do object.model:SetKey("rotationspeed","0,1,0"), but that's not setting the lua variable rotationspeed, that's setting the model key variable, which is a different variable. According to your description even though you are using object.model:SetKey() doesn't call your lua classes SetKey method. below object.model:SetKey("rotationspeed","0,1,0"), set rotationspeed to 1. Quote Link to comment Share on other sites More sharing options...
macklebee Posted July 25, 2010 Share Posted July 25, 2010 add this to your GetKey function and it will work just fine. elseif key=="rotationspeed" then return self.rotationspeed edit-- i have no idea what rick is talking about... 1 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...
Rick Posted July 25, 2010 Share Posted July 25, 2010 I'm just saying put object.rotationspeed = 1.0 under object.model:SetKey("rotationspeed","0,1,0") and it should work [edit] or not Quote Link to comment Share on other sites More sharing options...
macklebee Posted July 25, 2010 Share Posted July 25, 2010 or just do it smartly and actually add the variable check return value to the GetKey function... 1 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...
Rick Posted July 25, 2010 Share Posted July 25, 2010 seriously, your pot shots are getting old. but yes that way works best. you just don't have to be mean about it. [edit] and sorry, vec3 not 1. didn't see what you had there aggro Aggro, not that I want to convince you of a style, but the way you have it with object.model:SetKey("rotationspeed","0,1,0") is really just a longer way where you could set it directly with object.rotationspeed = Vec3(0, 1, 0) just inside the CreateObject class. Just a thought. Quote Link to comment Share on other sites More sharing options...
macklebee Posted July 26, 2010 Share Posted July 26, 2010 just responding to your comments... i truly had no idea what you are talking about... 1) the lua rotationspeed variable you are talking about is the model key rotationspeed 2) what class SetKey method are you referring to? the one in class.lua? he does call it but that has nothing to do with his problem 1 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...
Rick Posted July 26, 2010 Share Posted July 26, 2010 just responding to your comments... i truly had no idea what you are talking about... Yeah, as I loaded his model I realize I was wrong in my first statement. I always just assigned my variables directly after CreateObject instead of using SetKey, since it was just another layer to do the same thing. That would have worked, but you had a good catch in that when he changed values from the properties window he would have ran into issues. Quote Link to comment Share on other sites More sharing options...
macklebee Posted July 26, 2010 Share Posted July 26, 2010 well, actually for him to get the properties display to update correctly with a Vec3 variable then he needs to do this: change this: object.model:SetKey("rotationspeed","0,1,0") to this: object.rotationspeed = Vec3(0,1,0) and do this for the GetKey check/return value: elseif key=="rotationspeed" then return self.rotationspeed.x..","..self.rotationspeed.y..","..self.rotationspeed.z 1 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...
Rick Posted July 26, 2010 Share Posted July 26, 2010 Is there a Vec3ToString function? Seems that would be handy to save some typing. [edit] Looks like there is. So he could use that to save some keystrokes I guess. [edit1] So I would think the fastest way (not much faster but less overhead) would be to directly set your default values to your object variables right after CreateObject instead of using SetKey(), but yeah either would work. You just would have caught this bug later when you tried to update from the properties window Aggro Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted August 1, 2010 Author Share Posted August 1, 2010 I thought that I made a reply to this topic, but apparently something went wrong. Thanks for the help guys! The rotating light is fully functional. Just to verify: SetKey is used to set values in the Lua menu. GetKey is used to update the values that are inserted into the lua menu. 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.