Global Picking
-- this should be placed in App.lua
-- this will call a function Script:Picked(pickinfo) in any script attached to an entity telling you that the attached entity was picked
function App:HandlePicking()
   -- look for mouse picks and fire a function in the attached script if one exists
   if self.window:MouseHit(1) == true then

          local pickinfo = PickInfo()
          local p = self.window:GetMousePosition()
          if self.camera:Pick(p.x, p.y, pickinfo, 0.5, true) == true then
                 if pickinfo ~= nil then

                        if pickinfo.entity.script ~= nil then

                           if pickinfo.entity.script.Picked ~= nil then

                                  pickinfo.entity.script:Picked(pickinfo)
                           end
                        end
                 end
          end
   end
end
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License