Results 1 to 2 of 2

Thread: Comments on obscure bug removing/deleting object buttons

  1. #1

    Comments on obscure bug removing/deleting object buttons

    I've solved this but it took me several hours to find the problem, so I'm posting here as a reference.

    The TTS API documentation says of object.removeButton(n), "Removing an index instantly causes all other higher indexes to shift down 1." That's not quite true. Apparently that shift is done on the next frame. In order to delete all buttons, you need something like

    for i=0, buttonCount-1 do
        self.targetObject.removeButton(i) -- delete from first to last
    for i = buttonCount-1, 0, -1 do
        self.targetObject.removeButton(i)  -- delete from last to first element

    and not

    for i=0, buttonCount-1 do
        self.targetObject.removeButton(0)   -- delete first element n times
    If the array elements were immediately shifted to fill the removed slot, as they would be with an ordinary Lua array, the latter would work -- deleting the first element n times since the others will be shifted down to fill it. But this does not work.
    Last edited by MikeBlyth; 10-12-2019 at 10:46 PM.

  2. #2
    Thanks for the info. It does seem that a lot of TTS stuff updates on the next frame. UI XML changes also update on the next frame.

Similar Threads

  1. Replies: 10
    Last Post: 05-15-2018, 11:14 PM
  2. Creating or deleting hands by script?
    By Digital Awakening in forum Scripting
    Replies: 2
    Last Post: 02-19-2018, 04:03 AM
  3. [CRASHES] Crashes upon deleting a certain Infinity Bag
    By OysterBrains in forum Technical Support
    Replies: 1
    Last Post: 04-18-2017, 03:19 PM
  4. Replies: 2
    Last Post: 02-04-2017, 11:17 PM
  5. [Bug] Buttons display on wrong object for guests in server
    By Eskander in forum Scripting Bug Reports
    Replies: 5
    Last Post: 01-28-2017, 06:26 AM

Posting Permissions

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