mob/var/shop = list()
mob
verb
Shop()
var/item = input("Select an item you would like to add to shop.","Shop") in src.contents
var/price = input("How much would you like to sell [item] for?","Shop") as num
shop += item
shop += price
var/A
for(item in shop)
A ++
world << "Item: [shop[A]], Price: [shop[A+1]]"
A ++
Problem description:
K well It keeps on telling me that list index is out of bounds when I run the program and do the verb.. The reason probably being that it refers to shop[3] the second time it loops in the for statement . Even though it gives me this error it displays what I want it to.
I dunno why it wont let me refer to shop[3] since im adding stuff to the list that would make the list bigger then 3. Also when i tried declaring the list as mob/var/shop[20]. When it got to the for loop it displayed "Item: , Price: " 19 times before it showed the actual item and price.
Any help would be greatly appreciated.
Solution: Use an associative list. Ditch the A var entirely.
Lummox JR