Results 1 to 5 of 5

Thread: Strange error/bug with onObjectDrop

  1. #1

    Question Strange error/bug with onObjectDrop

    I have this very simple test function in global:

    function onObjectDrop(dropped, player_color)
      if dropped == nil then return end
      broadcastToAll("dropped guid: "..dropped.getGUID())
    When running the game, if I drag an object (any object -- tokens, cards, etc) around and drop it anywhere, it causes the error:

    Error - attempt to concatenate a nil value

    The error points to the line with broadcastToAll. It seems like getGUID is returning nil (I have also tried .tag and .getName() with the same result). The object exists in the game world, and it passes the first "dropped == nil" safety test, so why on earth is it falling down when I try and broadcast it's guid or tag or name?

    Anyone have any ideas what the cause is? Or potential fixes? Is it a bug in TTS?

  2. #2
    Join Date
    Sep 2017
    trouble is in the doc. onObjectDrop the parameters in the call are actually the reverse of the doc;
    function onObjectDrop(player_color, dropped)
    if dropped == nil then return end
    broadcastToAll("dropped guid: "..dropped.getGUID())
    will do the trick. One day soon Berserk Games developers will get to updating and correcting the doc. We players keep demanding more features though!
    Last edited by cche; 04-12-2020 at 04:23 PM.

  3. #3
    Thanks for your help cche. Not sure I would have ever found the problem without it.

  4. #4
    Join Date
    Sep 2017
    The key to finding such problems is to use logString() or log() these can show what you really are looking at.

  5. #5
    Thanks again - I'm still learning lua, and didn't know about logString/log - they are indeed very useful debugging tools.

Similar Threads

  1. Deselect Object onObjectDrop event
    By berserk3k in forum Scripting
    Replies: 6
    Last Post: 07-07-2018, 09:36 PM
  2. Strange problem in ATOM?
    By Tragic in forum Scripting
    Replies: 11
    Last Post: 05-29-2018, 01:47 PM
  3. Help with strange bug in my code!
    By Tragic in forum Scripting
    Replies: 1
    Last Post: 04-22-2018, 02:14 AM
  4. [SOLVED] Infinite bags are acting strange!!!
    By Tumba in forum Bug Reports
    Replies: 2
    Last Post: 06-09-2017, 04:20 PM
  5. Replies: 2
    Last Post: 05-17-2017, 09:51 PM

Tags for this Thread

Posting Permissions

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