Skip to content
This repository has been archived by the owner on Apr 8, 2021. It is now read-only.

onObjectDestroy or onDestroy triggers by game exit #26

Open
AufderWelt opened this issue Jun 24, 2020 · 1 comment
Open

onObjectDestroy or onDestroy triggers by game exit #26

AufderWelt opened this issue Jun 24, 2020 · 1 comment
Labels
bug Something isn't working lua Lua scripting

Comments

@AufderWelt
Copy link

AufderWelt commented Jun 24, 2020

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:

  • OS: Windows
  • Version 12.4.3

Known workarounds
Not Known

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

@dore0062 dore0062 added bug Something isn't working lua Lua scripting labels Jun 26, 2020
@darrellanderson
Copy link

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working lua Lua scripting
Projects
None yet
Development

No branches or pull requests

3 participants