Just a general question is LiveCode capable of creating global variables on the fly.
Simple example
A game you have turns, as players take turns you add 1 to a global gTurnNumber
Could you get gTurnNumber and get LC to create a new global while program running that gTurnWinner1, gTurnWinner2,
gTurnWinner3 that are created as game progresses?
Dynamic variable creation
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: Dynamic variable creation
Hi Jordy,
this is possible, but not really straightforward and probably not worth the effort!
Use a (global) ARRAY instead:
...
## Then you can do something like this:
add 1 to myGlobalGameArray["player1"]["turn"]
...
Get the picture?
Best
Klaus
this is possible, but not really straightforward and probably not worth the effort!
Use a (global) ARRAY instead:
...
## Then you can do something like this:
add 1 to myGlobalGameArray["player1"]["turn"]
...
Get the picture?
Best
Klaus
Re: Dynamic variable creation
I have so much fun.
What Klaus means is that you would have to take a few minutes and examine the following handler in a button:
LC can, er, "do" anything, but what I just did is old-fashioned.
Craig Newman
What Klaus means is that you would have to take a few minutes and examine the following handler in a button:
Code: Select all
on mouseUp
repeat with y = 1 to 3
do "put" && y && "into newGlobal" & y
put newGlobal & y & comma after header
end repeat
put "global" && header into globalHeader
set the newGlobalScript of me to globalHeader & return & return & the script of me
answer the newGlobalScript of me
end mouseUp
Craig Newman