Pancakes Posted March 23, 2010 Share Posted March 23, 2010 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 Quote Core I5 2.67 / 16GB RAM / GTX 670 Zbrush/ Blender / Photoshop CS6 / Renoise / Genetica / Leadwerks 3 Link to comment Share on other sites More sharing options...
macklebee Posted March 23, 2010 Share Posted March 23, 2010 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 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...
Pancakes Posted March 24, 2010 Author Share Posted March 24, 2010 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 Quote Core I5 2.67 / 16GB RAM / GTX 670 Zbrush/ Blender / Photoshop CS6 / Renoise / Genetica / Leadwerks 3 Link to comment Share on other sites More sharing options...
Rick Posted March 24, 2010 Share Posted March 24, 2010 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. 1 Quote Link to comment Share on other sites More sharing options...
macklebee Posted March 24, 2010 Share Posted March 24, 2010 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 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... 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...
Pancakes Posted March 24, 2010 Author Share Posted March 24, 2010 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. Quote Core I5 2.67 / 16GB RAM / GTX 670 Zbrush/ Blender / Photoshop CS6 / Renoise / Genetica / Leadwerks 3 Link to comment Share on other sites More sharing options...
AggrorJorn Posted May 11, 2010 Share Posted May 11, 2010 What kind of physics fle is your object pancakes? I've been struggling all day to get this waterwheel rotating but no luck. This code is the most easiest approach I have seen. I also tried the fanblades code and that workes, but I want this code to work first. Quote Link to comment Share on other sites More sharing options...
Pancakes Posted May 15, 2010 Author Share Posted May 15, 2010 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 Quote Core I5 2.67 / 16GB RAM / GTX 670 Zbrush/ Blender / Photoshop CS6 / Renoise / Genetica / Leadwerks 3 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.