Rick Posted July 30, 2011 Share Posted July 30, 2011 Doesn't the pick object have an x, y, z value in Lua? pick = CameraPick(camera, Vec3(MouseX(), MouseY(), 1000), 0, 0) if pick~=nil then if pick.entity~=nil then Notify("x="..pick.x.." z="..pick.z) -- this errors out saying it's not valid end end Quote Link to comment Share on other sites More sharing options...
Canardia Posted July 30, 2011 Share Posted July 30, 2011 The pick class should be the first parameter to CameraPick, because CameraPick returns an int saying if anything was picked or not. 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...
Rick Posted July 30, 2011 Author Share Posted July 30, 2011 The fps script that comes with Leadwerks has pick=CameraPick(camera,Vec3(GraphicsWidth()/2,GraphicsHeight()/2,2.0),0,0) Adding pick to the first param gives me access violation and kills the editor. Note this is in the Lua forum Quote Link to comment Share on other sites More sharing options...
Canardia Posted July 30, 2011 Share Posted July 30, 2011 The pick class in Lua has 5 subclasses (entity, surface, triangle, position, normal), so you need to use pick.position.x. 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...
Rick Posted July 30, 2011 Author Share Posted July 30, 2011 Bah, thanks. Dang Josh and his inconsistency. Thanks Quote Link to comment Share on other sites More sharing options...
Rick Posted July 30, 2011 Author Share Posted July 30, 2011 Any idea why I have to left click twice in the editor to get this code to run? Even that Notify("Inside click") won't run unless I click twice. if MouseHit(1)==1 then Notify("Inside click") pick = CameraPick(camera, Vec3(MouseX(), MouseY(), 1000), 0, 0) if pick~=nil then if pick.entity~=nil then Notify("x="..pick.position.x.." z="..pick.position.z) end end end Quote Link to comment Share on other sites More sharing options...
Rekindled Phoenix Posted July 30, 2011 Share Posted July 30, 2011 I've seen other applications call FlushMouse() before checking their mouse events. Maybe giving that a try before checking your MouseHit()? Quote 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.