Results 1 to 8 of 8

Thread: [BUG] onObjectDropped appears to be single-instance causing glitches

  1. #1

    [BUG] onObjectDropped appears to be single-instance causing glitches


    I am using the onObjectDropped() function in the Global script to handle when my players drop an object (in my case, cards in the game). I have a zone that if the card is dropped in it, it calls my MoveToDiscard() function which moves the card to the player's discard zone (a convenience), using obj.setPositionSmooth() and obj.setRotationSmooth().

    However, if a player drops one card on the zone to move it to their discard, and then drops a second card before the first has finished moving, the second card also gets pulled to the discard zone and rotated, even though the second card was not being dropped in the triggering zone!

    I added a print statement printing the card name of the card triggering the MoveToDiscard() function, and it only prints a single name of the first card.

    I also tried changing the parameter passed to the MoveToDiscard function from dropped_object that is supplied to onObjectDropped(), to the guid, in the hopes that doing so would make a separate instance and not trigger the double-move. However, this didn't work, leading me to suspect that the onObjectDropped() function must therefore be a single instance/thread, including any variables created in that routine, and dropping the second card before the first has finished its move somehow causes the moves to execute again erroneously on the second card.

  2. #2
    I've just realised - I may be able to work around this by using a coroutine. Will try that (tomorrow) and get back to this post.

  3. #3
    Join Date
    Sep 2016
    I think it would really help if you could come up with some simplified sample code that we can run and easily reproduce the issue. The circumstances of your issue are very specific, and it's too difficult to understand what's really causing the issue.

  4. #4
    I tried the coroutine - both native Lua coroutine and Tabletop Simulator's startLuaCoroutine() version. I may not have got it quite right but I managed to get the native version working but it still had the same problem.

    So I have recreated my issue in a stand-alone version. I have attached the save here:

    And there is a video of the problem below. The video shows the problem when pulling the card off the deck, but I just tried and it also has a problem when you just pick up and drop one of the other cards before the first card has finished moving.

  5. #5
    Join Date
    Sep 2016
    Thank you for isolating the problem, it will really help the devs figure out the cause. This does indeed appear to be a bug.

    I wonder if maybe it's caused by the first card getting destroyed when it lands on the destination deck. I tried several times to reproduce the issue when there was no deck at the destination, but I couldn't. It's interesting that MoveToDiscard never gets called for the cards that bug.

  6. #6
    Ah thanks - your thought about it being down to the card object getting destroyed when it joins the deck is a good inspiration. I suspect you're not far off the mark!

    Lets see what the devs have to say.

  7. #7
    Here's the code used to save people time:

    function onObjectDropped(player_color, dropped_object)
        for i, obj in pairs(getObjectFromGUID('e35111').getObjects()) do
    function MoveToDiscard(obj)
        if obj == nil then return end
        obj.setRotationSmooth({0,180,0}, false, false)
        obj.setPositionSmooth({22,2,-14}, false, false)
        print(obj.getGUID()..' moved to discard')

  8. #8
    Thanks Mark

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts