Re: TIB: List-Q


[Prev][Next][Index][Thread]

Re: TIB: List-Q




SWISH 97 wrote:
> 
> Hey, i was told that i need to make a list to have the items thing in my game
> were people can buy items and if they have it it shows up on the screen but if
> they dont it doesn't, can someone explain to me(us all) how to make a
> list?-thanx-Frank

On the 83 it's like this. Say you have ten possible items, so you'd 
make the list with eight elements.
:8->dim(L1
:Fill(0,L1
You now have a L1 that looks like this
{0,0,0,0,0,0,0,0}
Now, the person picks an item to buy. You subtract the money and check 
the balance, just like all that stuff before. You should note in all 
those earlier postings that there was an If/Then/Else Statement. IF 
the person CAN buy the item that they picked, then you need to 
increase that element by however many they bought. For instance, say 
that the user decided to buy 5 of the second item - whatever that may 
be. You would then increase the 2nd element in the list by five:
:L1(2)+5->L1(2
The whole thing MIGHT look something like this.

:8->dim(L1
:Fill(0,L1
:If U-(the cost of the item that was picked) >= 0
:Then
:U-(cost of the item)->U
:L1( (whatever the number of the item that was picked) ) + (however 
many were bought) -> L1( (whatever number item was picked) 
:Else
:Disp "YOU CAN'T AFFORD THAT
:End

One thing that is kind of important, I think, is the way it checks the 
money. Notice that the check to see if the balance is positive or 
negative is done BEFORE the amount of money is changed. One might be 
tempted to do this (I'm assuming that the total cost of the item is 5)
:U-5->U
:If U >= 0
:Then
:......
:Else
:Disp "YOU CAN'T AFFORD THAT
:End

The problem with this is, the money is subtracted regardless of 
whether or not the person has enough money. This will make a big 
difference if there is the possibility to get OUT OF debt. Think about 
it. Say the person's balance is -5 and they try to buy something that 
costs 5. Obviously they can't, and the calc will say that they can't. 
However U, the variable that represents that person's money, will go 
down ANOTHER five. Now their balance will be -10, even though they 
didn't actually buy anything. Just something you might want to be 
careful about.

Jody Snider
jody1@alaska.net


References: