Jump to content

Turnf and Custom Property


Pancakes
 Share

Recommended Posts

Hello I have a custom property to simply get an object to turn. Can I get a quick rundown on what I've done wrong? Thanks

 


require("scripts/class")


local class=CreateClass(...)

function class:InitDialog(grid)
local group
self.super:InitDialog(grid)
group=grid:FindGroup ("Behavior")
group:AddProperty ("TurnSpeed", PROPERTY_FLOAT)
end



function class:CreateObject(model)
       local object=self.super:CreateObject(model)



function object:SetKey(key,value)
if key=="TurnSpeed" then
	object:Turnf(value,0,0,0)
	object:Render()
	end
end




end

Core I5 2.67 / 16GB RAM / GTX 670

Zbrush/ Blender / Photoshop CS6 / Renoise / Genetica / Leadwerks 3

Link to comment
Share on other sites

try this:

require("scripts/class")
require("Scripts/math/vector")
local class=CreateClass(...)

function class:InitDialog(grid)
       self.super:InitDialog(grid)
       local group = grid:AddGroup("behavior")
       group:AddProperty ("turnspeed", PROPERTY_VEC3)
group:Expand(1)
end

function class:CreateObject(model)
       local object=self.super:CreateObject(model)

object.model:SetKey("turnspeed","1,1,1")

function object:SetKey(key,value)
	if key=="turnspeed" then
		self.turnspeed = StringToVec3(value)
	else
                       return self.super:SetKey(key,value)
               end
               return 1
       end

function object:Render()
	self.model:Turn(self.turnspeed,1)
end
end

  • 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

Thanks a lot. It would have taken me a week to figure that out on my own.

 

Looking at what you did I think I understand it. However when I copied your script and saved it, the in-editor property group was disabled for some reason. So I changed the property portion of the code back to the way I had it (basically copying Josh) and now it works perfectly.

 

Here is the code right now.

 

require("scripts/class")
require("Scripts/math/vector")
local class=CreateClass(...)

function class:InitDialog(grid)
         local group
       self.super:InitDialog(grid)
       group=grid:FindGroup ("behavior")
       group:AddProperty ("TurnSpeed", PROPERTY_VEC3)
end

function class:CreateObject(model)
       local object=self.super:CreateObject(model)

       object.model:SetKey("turnspeed","1,1,1")

       function object:SetKey(key,value)
               if key=="turnspeed" then
                       self.turnspeed = StringToVec3(value)
               else
                       return self.super:SetKey(key,value)
               end
               return 1
       end

       function object:Render()
               self.model:Turn(self.turnspeed,1)
       end
end

 

Thanks a lot! That's a really big help for me. I remember StringToVec3 from CryEngine Flowgraphs Lua has it too :lol:

Core I5 2.67 / 16GB RAM / GTX 670

Zbrush/ Blender / Photoshop CS6 / Renoise / Genetica / Leadwerks 3

Link to comment
Share on other sites

Thanks a lot! That's a really big help for me. I remember StringToVec3 from CryEngine Flowgraphs Lua has it too

 

StringToVec3() isn't a lua function. Lua is just a language, what you are mostly using here is a library that Josh created from the Lua language. That's an important distinction because it can help you understand how things work.

 

They keywords like function, if, then, end, do, etc. and the ability to make variables and such is the Lua language. Using those one can make a library that is specific to their needs (in this case the LE engine).

 

I just remember someone posting this Lua example script he had and he couldn't figure out why it wasn't working. It's because they weren't understanding the difference between Lua the language and a library made with Lua.

  • Upvote 1
Link to comment
Share on other sites

Thanks a lot. It would have taken me a week to figure that out on my own.

 

Looking at what you did I think I understand it. However when I copied your script and saved it, the in-editor property group was disabled for some reason. So I changed the property portion of the code back to the way I had it (basically copying Josh) and now it works perfectly.

 

 

Thanks a lot! That's a really big help for me. I remember StringToVec3 from CryEngine Flowgraphs Lua has it too :lol:

 

ah... yeah cuz i wasn't paying attention and just copied some code from some of my scripts into it without checking the variable names... group vs group1... edited the code above to reflect the change

 

still think this line should be

group = grid:AddGroup("behavior")

 

 

and the Strings to Vec's are defined in the math/vector.lua file...

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

Thanks again guys. With this lesson I will be able to do very simple cause and effect relationships between entities that have custom properties in them. Once I do some more reading on Lua that is.

Core I5 2.67 / 16GB RAM / GTX 670

Zbrush/ Blender / Photoshop CS6 / Renoise / Genetica / Leadwerks 3

Link to comment
Share on other sites

  • 1 month later...

physics fle?

 

Let's see I just used it on a bunch of hallway and room skeletons to test on, and it was weird - like a first person platformer. But I installed over this direcotry when I was trying to update so I think the script files are gone

Core I5 2.67 / 16GB RAM / GTX 670

Zbrush/ Blender / Photoshop CS6 / Renoise / Genetica / Leadwerks 3

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