Results 1 to 2 of 2

Thread: Dynamic button oddities

  1. #1

    Dynamic button oddities

    Hello - so I am a bit confused about the way buttons work. Not their scripting or anything, but their internal indexing and storage. I have an options menu thing that creates and removes buttons dynamically, and I've noticed it's a bit difficult to get the correct index for the buttons you wish to remove. So I built a table system to store each buttons index as I create them, however, that showed me a few other oddities in the button system. For one, if I create a group of buttons, create another group of buttons, then remove the first buttons, the index of the newer buttons change, however they seem to change with the newest taking up the space of the now empty indexes. Another thing I've noticed is it seems like the buttons are all indexed client side - because I'll see as the host things will look fine, but if I join a game in progress, even though the buttons look alright for those who were there for the initial load, for the new joiners when a button is edited it'll change the wrong ones. If anyone knows exactly how buttons are dealt with or maybe knows a good method for dynamically dealing with them, that'd be great!

  2. #2
    Join Date
    May 2016
    Posts
    1,072
    If you make 5 buttons, delete the first one and add a new one, the new one's index should be "4" (since there are 4 buttons currently with the indexes 0, 1, 2, 3.) Lua HATES empty indexes in an array style table and I was fairly sure it closed that gap right away.

    And yes, there are some visual bugs with buttons if you use remove button. Sometimes the clients continue to see them.

    My personal solution tends to hinge around me clearing all the buttons, which doesn't seem to have the sync issue. If that isn't reasonable to do, then I will EDIT them instead, giving them a label of "" and a height/width of 0. So the button is still there, it retains the same index, and can be brought back simply by replacing its label, height and width.

    This also fixes a lot of issues where you would have to dynamically locate a button index. I personally hate that lol

Similar Threads

  1. Dynamic Lighting/Shadow for RPGs
    By georgatos7 in forum General Discussion
    Replies: 11
    Last Post: 06-09-2018, 02:10 AM
  2. Replies: 3
    Last Post: 06-10-2017, 08:30 PM
  3. Way to get button pressed?
    By allencoded in forum Scripting
    Replies: 10
    Last Post: 06-05-2016, 07:19 AM
  4. BUG: On Button Position
    By Flolania in forum Scripting
    Replies: 0
    Last Post: 05-17-2016, 04:20 PM
  5. Replies: 0
    Last Post: 10-07-2015, 03:56 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
  •