Simple Myst-Like Application
Klaus Major
klaus at major-k.de
Thu Aug 24 11:18:52 EDT 2006
Hi Graeme
> Gordon,
>
> So what I do is:
>
> In the Stack script I put:
>
> global gUserpoints
well, almost :-)
In each handler you have to declare the global before you use ist:
on openStack
global gUserpoints
put 0 into gUserpoints
end openStack
>
> Then on the top of every Card script:
> global gUserpoints.
Not necessary, see above
> And if it is a point awarding card:
>
> global gUserpoints
> add 10 to gUserpoints
Yes.
> And if its a point awarding button
on mouseDown
global gUserpoints
add 10 to gUserpoints
end mouseDown
> Then I have a field at the bottom of the screen where the score
> adds up, so I set the contents of that field to gUserpoints? Would
> you know how to do this? Also in the last example, how could I
> make it work only ONE time, so that the user won't click on it
> again and get 20,30,40 pts....and so on.
Simply manage a global "inventory" list, too, where you store the
names of all cards
(If i get it right, you can only get ponts on cards? Anyway, the
principle will be the same.)
that can "give" points and have been cklicked.
Of course you will have to give meaningful and unique names to your
cards then!
Then you can check each time before you add points.
Don't worry the chekcing will be almost immediately, even for very
long lists ;-)
To use your examples above:
on openStack
global gUserpoints
put 0 into gUserpoints
global inventorylist
put empty into inventorylist
end openStack
...
on mouseDown
## Why not use mouseUP?
##That will give the user a chance to make up his mind! ,-)
global gUserpoints
global inventorylist
if the short name of this cd is not among the lines of
inventorylist then
put the short name of this cd & CR AFTER inventorylist
## build a RETURN delimted list of all point awarding cards to
check against!
add 10 to gUserpoints
else
beep ## or whatever. Optional!
end if
end mouseDown
Know what I mean?
Drop a line if you need more info/help!
> Thanks
>
> Graeme
Regards
Klaus Major
klaus at major-k.de
http://www.major-k.de
More information about the use-livecode
mailing list