gordonramp Posted January 31, 2010 Share Posted January 31, 2010 I am looking at the idea of 'triggers'( initiating an event) but have no idea where to start. I assume some sort of collision code would be necessary followed by a pointing at the event. Like, the recording of 'Health'. I can't seem to find anything much about this on the Lua Forum. Any ideas? Quote AMD Athlon x2 7750 2.7ghz, 6gb ddr2 ram, Galaxy9800GT 1gig ddr2 video card, Windows 7,64. Link to comment Share on other sites More sharing options...
Canardia Posted January 31, 2010 Share Posted January 31, 2010 A trigger can be any kind of measurable thing. You could make a "trigger" so that when an entity (for example the player) is close enough to some other entity, then the entity would slowly turn towards the first entity. This would be really simple to code, somehow like (in pseudocode): If(EntityDistance(this,namedentity)<5) PointEntity(this,namedentity,3,0.01) End Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
cassius Posted February 1, 2010 Share Posted February 1, 2010 So far I have used EntityDistance for all triggers and all sort of objects, such as lights. Be nice to have some different and more precise way. Quote amd quad core 4 ghz / geforce 660 ti 2gb / win 10 Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++ Link to comment Share on other sites More sharing options...
Rick Posted February 1, 2010 Share Posted February 1, 2010 You are thinking of area triggers. Is it doable in lua but in my mind currently has limitations. The body must be defined in the model you bring in, in order to for you to be able to get a collision method called. There currently is no way to get a collision method called in lua for bodies that you make in lua code. Which sucks. Quote Link to comment Share on other sites More sharing options...
gordonramp Posted February 1, 2010 Author Share Posted February 1, 2010 Ok, I thought I would have a go at using 'EntityDistance'. Using Lumooja's pseudocode as a base.. I placed a metal door on a terrain in the editor. Then using the basic fps Lua code, put this in the main loop.. If(EntityDistance(fw.main.camera,metal01_1)<5) then PointEntity(fw.main.camera,metal01_1,3,0.01) end I gives me this error.. 'unexpected symbol near 'then'' I guess it's a simple Lua code error, any ideas why that might be? Quote AMD Athlon x2 7750 2.7ghz, 6gb ddr2 ram, Galaxy9800GT 1gig ddr2 video card, Windows 7,64. Link to comment Share on other sites More sharing options...
Niosop Posted February 1, 2010 Share Posted February 1, 2010 That's not how Lua does if statements Try: if EntityDistance(fw.main.camera, metal01_1) < 5 then PointEntity(fw.main.camera, metal01_1, 3, 0.01) end Quote Windows 7 x64 - Q6700 @ 2.66GHz - 4GB RAM - 8800 GTX ZBrush - Blender Link to comment Share on other sites More sharing options...
cassius Posted February 1, 2010 Share Posted February 1, 2010 Perhaps it should be the player rather than the camera as a parameter? Quote amd quad core 4 ghz / geforce 660 ti 2gb / win 10 Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++ Link to comment Share on other sites More sharing options...
gordonramp Posted February 1, 2010 Author Share Posted February 1, 2010 Your right, it runs without an error now (C++ coder), however the object does not turn to face the camera as requested. Maybe someone has a simple working example of 'trigger code' to share. Quote AMD Athlon x2 7750 2.7ghz, 6gb ddr2 ram, Galaxy9800GT 1gig ddr2 video card, Windows 7,64. Link to comment Share on other sites More sharing options...
gordonramp Posted February 1, 2010 Author Share Posted February 1, 2010 Cassius, if EntityDistance(controller, metal01_1) < 5 then PointEntity(controller, metal01_1, 3, 0.01) end Same result. Quote AMD Athlon x2 7750 2.7ghz, 6gb ddr2 ram, Galaxy9800GT 1gig ddr2 video card, Windows 7,64. Link to comment Share on other sites More sharing options...
macklebee Posted February 1, 2010 Share Posted February 1, 2010 are you using this in a gamescript or an entity script? I am asking because 'metal01_1' looks like the name of the entity and not actually an entity... i would put that code in an entity script for the metal01 gmf inside the object:Render() function... of course changing it from metal01_1 to object.model Also it should be: PointEntity(object.model,fw.main.camera,1, 0.01) the other way is trying to point the camera at the other entity 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...
gordonramp Posted February 1, 2010 Author Share Posted February 1, 2010 Yes, 'metal01_1 is the name of the door that comes with the LE. I've tried it in both the Game Loop and now in the class file. Quote AMD Athlon x2 7750 2.7ghz, 6gb ddr2 ram, Galaxy9800GT 1gig ddr2 video card, Windows 7,64. Link to comment Share on other sites More sharing options...
Niosop Posted February 1, 2010 Share Posted February 1, 2010 If it's the name of the door then it's not the actual door object. You'll need to get the actual object. Maybe FindChild on the scene might work. Quote Windows 7 x64 - Q6700 @ 2.66GHz - 4GB RAM - 8800 GTX ZBrush - Blender Link to comment Share on other sites More sharing options...
cassius Posted February 1, 2010 Share Posted February 1, 2010 I normaly reference the object by its name in its properties,which I usualy change if its not easy to remember. Quote amd quad core 4 ghz / geforce 660 ti 2gb / win 10 Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++ Link to comment Share on other sites More sharing options...
gordonramp Posted February 1, 2010 Author Share Posted February 1, 2010 Ok, I'll explore this... Update: Success.. require("scripts/class") local class=CreateClass(...) function class:CreateObject(model) local object=self.super:CreateObject(model) function object:Update() if EntityDistance(fw.main.camera, self.model) < 10 then PointEntity(self.model, fw.main.camera, 3, 0.01) end end end Thanks Quote AMD Athlon x2 7750 2.7ghz, 6gb ddr2 ram, Galaxy9800GT 1gig ddr2 video card, Windows 7,64. 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.