Pants Posted November 8, 2010 Share Posted November 8, 2010 Just starting to learn LUA scripting, thanks to Aggrors tutorials. Is it possible to pick an object and have the object execute a function? Can I camera pick a door, and have the door run it's own object:open() method? And if so, how? I know this can be done using SendMessage and ReceiveMessage, but I need to pass more variables than those will allow (lua types, to be specific). Thanks. Quote DualCore E6500 @ 2.9GHz / 3GB / GForce GTX 460 / XPSP3 Link to comment Share on other sites More sharing options...
macklebee Posted November 8, 2010 Share Posted November 8, 2010 Look at how the switch and underground_fanblades scripts work. Also open up the tunnels.sbx file and you will see an example of them working. 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...
Pants Posted November 8, 2010 Author Share Posted November 8, 2010 Look at how the switch and underground_fanblades scripts work. Also open up the tunnels.sbx file and you will see an example of them working. As far as I can tell, this example uses messages.. Quote DualCore E6500 @ 2.9GHz / 3GB / GForce GTX 460 / XPSP3 Link to comment Share on other sites More sharing options...
Soamp Posted November 8, 2010 Share Posted November 8, 2010 As far as I can tell, this example uses messages.. Hi, you can use something like this require("scripts/utilities") ... local pick=CameraPick(fw.main.camera,Vec3(GraphicsWidth()/2,GraphicsHeight()/2,2.0),0,0) if pick then local pickedmodel=GetMeshModel(pick.entity) objecttable[pickedmodel]:open() end Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted November 8, 2010 Share Posted November 8, 2010 I am working on tutorials that cover objects scripts. One of the topics is sending messages and camera picking. What kind of parameters do you want to add to your function? Quote Link to comment Share on other sites More sharing options...
Pants Posted November 9, 2010 Author Share Posted November 9, 2010 Thanks Soamp, that works perfectly! I'm not sure how the objecttable works, but I'm sure I'll learn. Aggror, the door:open() was an example just to illustrate my problem. To be specific, if my player character is punching another character, so I need to pick the enemy, and have it run a GetHit() function, the parameter passed needs to be a Lua type holding my character object's rpg-style skill variables, like player.attribute_strength, player.skill_unarmed, and so forth. The problem I was having is that you can not pass lua types as the extra parameter in SendMessage, all it allows is the message, delay, and an extra string. The solution Soamp suggested is exactly what I needed, thanks again. Quote DualCore E6500 @ 2.9GHz / 3GB / GForce GTX 460 / XPSP3 Link to comment Share on other sites More sharing options...
macklebee Posted November 9, 2010 Share Posted November 9, 2010 Thanks Soamp, that works perfectly! I'm not sure how the objecttable works, but I'm sure I'll learn. sorry for the misdirect, I didn't understand exactly what you were trying to accomplish... but in any case, you should probably read Getting Started with Lua... specifically page 10 concerning Classes and Objects. 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.