Killing Variables

kewldude606
Is there a way to delete variables from memory? I wish to know because I'm making a card game, so I have variables set up in an array like this:
H[2]="Two of Hearts"
H[3]="Three of Hearts"
...
S[5]="Five of Spades"
S[12]="Queen of Spades"
...

But this is a lot of variables, so I would like to make a procedure that creates all the variables, and another procedure that deletes them all.
Is this possible?

Chuck
My first humble thought (very humble since I'm an ASL newbie) would be to assign each card to a flag. Flags can be easily turned off and on. Yes, that's a lot of flags for a card deck. Maybe you need the versatility of variables for your cards. On the other hand, flags may be simpler.

Chuck

Alex
There's no way of deleting variables at the moment - but you shouldn't really need to. Even if you have a lot of variables you don't really need, they shouldn't cause any problems.

I think Im Dead
Um, another idea would be, and this depends on the card game you are making, would be to only have variables for the cards in play. This seems like the route to me if you were making a poker or blackjack game. I guess reguardless you could set it up something like this...



command <draw> {
set numeric <cardsinhand; 0>
for each object in <inventory> set numeric <cardsinhand; %cardsinhand% + 1>
set numeric <carddraw; $rand(1;13)$>
set numeric <suitdraw; $rand(1;4)$>
for each object in <inventory> if not <%suitdraw%-%carddraw%> then {
for each object in <opponent-inventory> if not <%suitdraw%-%carddraw%> give <%suitedraw%-%carddraw%>
}
}
else exec <draw>


Or something like that, gotta go. Screaming BABIES!!!!

kewldude606
Alex wrote:There's no way of deleting variables at the moment - but you shouldn't really need to. Even if you have a lot of variables you don't really need, they shouldn't cause any problems.


My computer is shi-really bad, and the less RAM a program uses, the better. But, once you think about it, if there are 52 cards in the deck, that's 52 variables...52*17(max string for each variable)=884 bytes=.8k=1k(FAT32)
So that isn't too much memory...

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums