Problem with "delete button"
Quentin Long
cubist at aol.com
Mon Dec 19 13:58:59 EST 2016
sez pink <nabble at mad.pink>:
> I'm developing a turned based game, on each turn, new buttons get added to
> the board, and it some buttons will get removed. There in lies the problem,
> Livecode keeps crashing when I hit the "delete button xxx" command.
>
> So, the only work around I've come up with is to make the buttons invisible,
> however this means as the game goes on that there are going to be hundreds
> of invisible buttons cluttering the board.
Assuming that button-deletion continues to be a problem, one possible workaround would be to figure out the maximum number of buttons that can ever be on the board at any one time; give the game-board that many buttons to start with; and re-assign button-characteristics (visibility, icons, position, etc) "on the fly" as needed.
If you need to deal with specific characteristics of a button on the board, you may want to use indirection. I of course don't know any of the details of your game, but let's consider the case of a game that involves a 10-by-10 grid, with buttons appearing and disappearing on the grid-positions during the course of the game. You could have a global variable whose name is "Grid-1-1", and every time you move a button into the 1,1 space on the grid, put the name of that button into the Grid-1-1 variable. If/when you need to fuss with specific properties of the button at (grid-space 1,1), you should be able to do things like this:
set the [name of property] of button Grid-1-1 to [value]
put the [name of property] of button Grid-1-1 into [name of variable]
Since the string "Grid-1-1" is a variable, and the value of that variable is the name of a button, LiveCode should interpret "button Grid-1-1" as a reference to the button whose name is stored in the variable "Grid-1-1". You'll want to be careful about quote-marks in your code, of course. A variable name in quote-marks will be interpreted as a literal string, which is not what you want.
Hope this helps…
"Bewitched" + "Charlie's Angels" - Charlie = "At Arm's Length"
Read the webcomic at [ http://www.atarmslength.net ]!
If you like "At Arm's Length", support it at [ http://www.patreon.com/DarkwingDude ].
More information about the use-livecode
mailing list