tts-community / tts-community-bug-tracker

Community maintained list of Tabletop Simulator bugs.
2 stars 0 forks source link

onObjectDestroy or onDestroy triggers by game exit #26

Open AufderWelt opened 4 years ago

AufderWelt commented 4 years ago

Describe the bug the lua onObjectDestroy (dying_object) functions triggers by exiting the game, which causes error messages, that the object reference passed to lua onObjectDestroy (dying_object) is not valid

To Reproduce Steps to reproduce the behavior:

function onObjectDestroy(dying_object)
  log("1")
end

open a single player table, add one object, add the code to global and save the game.

  1. leave the game
  2. load the saved game
  3. repeat steps 1&2 until error is shown sometimes an error messages is shown, that the object reference is invalid. i have also seen, that the table object is passed sometimes as dying_object

Expected behavior the function should not be triggered by exiting the game. it makes no sense

Tabletop Simulator Info:

Known workarounds Not Known

Link To TTS Post https://forums.tabletopsimulator.com/showthread.php?8929-onObjectDestroy-or-onDestroy-triggers-by-game-exit

darrellanderson commented 4 years ago

Here's a (not ideal) workaround I've been using. I haven't found a way to suppress the error (including pcall):

function onObjectDestroy(dying_object)
  if not _broken then
    _broken = true
    doActualBody()
    _broken = false
  end
end

When it does break, _broken is left set to true so future calls don't do anything. In my case I was getting hundreds of errors on exit, so I can live with just one now.