Skip to content

Commit

Permalink
Wrap messages in a pcall
Browse files Browse the repository at this point in the history
  • Loading branch information
britzl committed Feb 16, 2018
1 parent 6569234 commit 28c5690
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions in/cursor.script
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,14 @@ function init(self)
end

local function notify_event(self, game_object_id, message_id)
msg.post(game_object_id, message_id)
if self.notify_own_gameobject then
msg.post(".", message_id, { id = game_object_id })
end
-- pcall to catch errors when posting to a game object that might have been deleted
-- typically a cursor_out message that is generated when the game object is deleted
pcall(function()
if self.notify_own_gameobject then
msg.post(".", message_id, { id = game_object_id })
end
msg.post(game_object_id, message_id)
end)
end

function update(self, dt)
Expand Down

0 comments on commit 28c5690

Please sign in to comment.