Hi Leo,
hmm, I do not see a possibility to solve this with variables!
BUT this a very good candidate for custom properties!
Hint:
Custom properties are a bit hard to understand at first, but then you don't want to miss them anymore!
A custom property is almost the same as the "build-in" props (like "witdh", "height" etc.) or a variable,
BUT:
1. we can name them any way we want, as long as we don't use reserved words
2. we can put into them whatever we want, just like a variable!
3. they are tied to a specific object (stack/card/button/field/player etc...)
4. they get saved with the stack they reside in automatically! UNLIKE variables
5. Each object can have an unlimited number of custom properties!
Assigning is easy:
...
set the cWelcomeString of fld "my field or yours" to "Hello sailor!"
## I got used to name my custom properties with a starting c
...
Accessing is, too:
...
answer the cWelcomeString of fld ""my field or yours"
## Please note the "THE"!
...
Another advantage is that you can name the custom props of different object with the same name,
and that is exactly what we need in your case!
Here we go:
The script that counts TTL down, NO need for globals anymore!
Code: Select all
on deleteTime
## First get the custom property:
put the cTTL of me into TTL
## Maybe this object was not yet used
if TTL = empty then
put 4 into TTL
else
## We can count down
put TTL - 1 into TTL
end if
## Now we need to "wriute" the modified custom property back to the objct
set the cTTL of me to TTL
send "deleteTime" to me in 1 second
end deleteTime
Now the other handler:
Code: Select all
...
repeat with x = the number of controls in group "groupe" down to 1 // buttons are in a group
put the cTTL of control x of group "groupe" into current_TTL // NO MORE fail line
if current_TTL <= 0 then
delete control x of group "groupe"
end if
end repeat
...
OK, try this and report back to us!
Best
Klaus