dhutchison Posted February 6, 2010 Share Posted February 6, 2010 For each of the models I am using in LeadWerks (e.g., object.gmf), I have created an accompanying .lua file (e.g., object.lua) with the following code: require("scripts/class") local class=CreateClass(...) When I open the Properties Inspector for a model in the editor, I need to manually set the Collision to "Prop". What line(s) I should add to the code above, so I don't have to set this up manually each time? Thanks. Quote Link to comment Share on other sites More sharing options...
macklebee Posted February 6, 2010 Share Posted February 6, 2010 require("scripts/class") local class=CreateClass(...) function class:CreateObject(model) local object=self.super:CreateObject(model) object.model:SetKey("collisiontype","1") end 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...
macklebee Posted February 6, 2010 Share Posted February 6, 2010 or just use those two lines like you have them and then make an INI text file for each of your models standard settings that would be found inside the class script/property dialog: collisiontype = "1" mass = "10.0" etc... etc... and then if you create a new instance of the object in a new scene it will automatically load these values. 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...
dhutchison Posted February 6, 2010 Author Share Posted February 6, 2010 Thanks. Works really well... Quote Link to comment Share on other sites More sharing options...
Josh Posted February 6, 2010 Share Posted February 6, 2010 or... require("scripts/class") local class=CreateClass(...) function class:CreateObject(model) local object=self.super:CreateObject(model) object.model:SetCollisionType(COLLISION_PROP) end Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Michael Betke Posted February 6, 2010 Share Posted February 6, 2010 So I can use a .ini file or set the parameters with object.model:SetKey("collisiontype","1") for other property settings too? Quote Pure3d Visualizations Germany - digital essences AAA 3D Model Shop specialized on nature and environments Link to comment Share on other sites More sharing options...
macklebee Posted February 7, 2010 Share Posted February 7, 2010 yes 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...
Rekindled Phoenix Posted May 10, 2010 Share Posted May 10, 2010 When I add a copy of my stone model into my scene, the lua script (Josh posted) runs and I get the attached pic... I originally used an INI file, and physics in the editor didn't work. Any suggestions? Quote Link to comment Share on other sites More sharing options...
Soamp Posted May 10, 2010 Share Posted May 10, 2010 When I add a copy of my stone model into my scene, the lua script (Josh posted) runs and I get the attached pic... I originally used an INI file, and physics in the editor didn't work. Any suggestions? Hi, Did you run that from script editor screen? (with F5 or Run) Quote Link to comment Share on other sites More sharing options...
Rekindled Phoenix Posted May 10, 2010 Share Posted May 10, 2010 Yes, I ran that code using the editor. The code also seems to be automatically run when I add the object into the world. I still am a n00b at Lua, what do I do to solve this problem? Quote Link to comment Share on other sites More sharing options...
macklebee Posted May 11, 2010 Share Posted May 11, 2010 Yes, I ran that code using the editor. The code also seems to be automatically run when I add the object into the world. I still am a n00b at Lua, what do I do to solve this problem? Do not run object scripts. Only save object scripts then add the object into the world. You can run gamescripts like driver.lua or fpscontroller.lua in the editor. Or you can run standalone scripts like example1.lua from the Script Editor located in the SDK root directory. and by the way, my way is better than Josh's example because it actually sets the properties dialog as well as setting the collision type. 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...
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.