Jump to content

default values in Lua menu


AggrorJorn
 Share

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

  • Upvote 1

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

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.

Link to comment
Share on other sites

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

  • Upvote 1

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

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 ;)

Link to comment
Share on other sites

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.

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