Instead of having slot1, slot2, etc. to represent capacity, you can *create a variable at 8, then decrease it when the players get an item and increase it when they lose an item. If it’s zero, forbid the players to get items. I think that’s much simpler and can achieve the same thing if you change the way inventory lists items.
` will keep indentation.
1) One thing I'd recommend is not having labels and variables as the same thing. I don't think it will ever cause problems, but it can be very confusing to bug check.
2) On this line: `*set buying "Potion_of_Healing"` you're using a capital letter. Case matters.
3) As a general recommendation, as DSeg mentioned, I'd say it's far easier to track items as individuals, rather than having slots they can fit into.
4) I think the lines you're referring to (`*if selling = potion_of_healing`) you need `*if selling = "potion_of_healing"`.
@Magma There were various problems with it (three main ones) but the following will at least work now.
However, there’s still a basic overall design flaw in that if allowing multiple items of the same name you will need to separately identify “slots” from “item name”, at least where the final part of the sale is concerned. At present, if you buy 3 potions and attempt to sell the third one, it will sell the first one, because you’re basing the ‘selling’ condition on item name, not actual slot#, and item 1 (potion) was the same as item 3 (potion), so it will always sell the first identically-named item it finds.
It’s not game-breaking, it will just look odd to the player, but it’s an easy fix if you think about (and treat) “slots” and “item name” as two different things.
*label start
*choice
#Check inventory
*gosub inv
*goto start
#Buy potion of Healing
*set buying "Potion_of_Healing"
*set price 10
*gosub buy
*goto start
#Buy Expensive Ring
*set buying "expensive_ring"
*set price 100
*gosub buy
*goto start
#Sell Item
*gosub sell
*goto start
*label inv
Currently in Inventory:
Slot 1: Holding ${slot1}
*line_break
Slot 2: Holding ${slot2}
*line_break
Slot 3: Holding ${slot3}
*line_break
Slot 4: Holding ${slot4}
*line_break
Slot 5: Holding ${slot5}
*line_break
Slot 6: Holding ${slot6}
*line_break
Slot 7: Holding ${slot7}
*line_break
Slot 8: Holding ${slot8}
*line_break
*return
*label buy
*if slot1 = "nothing"
*if money >= price
*set slot1 buying
*set money - price
*return
*else
You don't have enough money for this.
*return.
*elseif slot2 = "nothing"
*if money >= price
*set slot2 buying
*set money - price
*return
*else
You don't have enough money for this.
*return.
*elseif slot3 = "nothing"
*if money >= price
*set slot3 buying
*set money - price
*return
*else
You don't have enough money for this.
*return.
*elseif slot4 = "nothing"
*if money >= price
*set slot4 buying
*set money - price
*return
*else
You don't have enough money for this.
*return.
*elseif slot5 = "nothing"
*if money >= price
*set slot5 buying
*set money - price
*return
*else
You don't have enough money for this.
*return.
*elseif slot6 = "nothing"
*if money >= price
*set slot6 buying
*set money - price
*return
*else
You don't have enough money for this.
*return.
*elseif slot7 = "nothing"
*if money >= price
*set slot7 buying
*set money - price
*return
*else
You don't have enough money for this.
*return.
*elseif slot8 = "nothing"
*if money >= price
*set slot8 buying
*set money - price
*return
*else
You don't have enough money for this.
*return.
*else
You have no space in your inventory for this item.
*return
*label sell
You can try to sell any of these itens:
*line_break
*if slot1 != "nothing"
*line_break
${slot1}
*line_break
*goto s2s
*else
*goto s2s
*label s2s
*line_break
*if slot2 != "nothing"
${slot2}
*line_break
*goto s3s
*else
*goto s3s
*label s3s
*if slot3 != "nothing"
*line_break
${slot3}
*line_break
*goto s4s
*else
*goto s4s
*label s4s
*if slot4 != "nothing"
*line_break
${slot4}
*line_break
*goto s5s
*else
*goto s5s
*label s5s
*if slot5 != "nothing"
*line_break
${slot5}
*line_break
*goto s6s
*else
*goto s6s
*label s6s
*if slot6 != "nothing"
*line_break
${slot6}
*line_break
*goto s7s
*else
*goto s7s
*label s7s
*if slot7 != "nothing"
*line_break
${slot7}
*line_break
*goto s8s
*else
*goto s8s
*label s8s
*if slot8 != "nothing"
${slot8}
*goto sell01
*else
*goto sell01
*label sell01
*choice
*if (slot1 != "nothing")
# ${slot1}
*set selling slot1
*gosub sellprice
You are offered ${sellprice} silvers for ${slot1}
*return
*if (slot2 != "nothing")
# ${slot2}
*set selling slot2
*gosub sellprice
You are offered ${sellprice} silvers for ${slot2}
*return
*if (slot3 != "nothing")
# ${slot3}
*set selling slot3
*gosub sellprice
You are offered ${sellprice} silvers for ${slot3}
*return
*if (slot4 != "nothing")
# ${slot4}
*set selling slot4
*gosub sellprice
You are offered ${sellprice} silvers for ${slot4}
*return
*if (slot5 != "nothing")
# ${slot5}
*set selling slot5
*gosub sellprice
You are offered ${sellprice} silvers for ${slot5}
*return
*if (slot6 != "nothing")
# ${slot6}
*set selling slot6
*gosub sellprice
You are offered ${sellprice} silvers for ${slot6}
*return
*if (slot7 != "nothing")
# ${slot7}
*set selling slot7
*gosub sellprice
You are offered ${sellprice} silvers for ${slot7}
*return
*if (slot8 != "nothing")
# ${slot8}
*set selling slot8
*gosub sellprice
You are offered ${sellprice} silvers for ${slot8}
*return
#Do not sell anything.
*return
*label sellprice
*if selling = "Potion_of_Healing"
*set sellprice 5
*goto sellprice2
*elseif selling = "expensive_ring"
*set sellprice 90
*goto sellprice2
*else
Error
*finish
*label sellprice2
You are offered ${sellprice} silvers for ${slot1}
*choice
#Sell the item
*set money + sellprice
*if selling = slot1
*set slot1 "nothing"
*goto sellprice3
*elseif selling = slot2
*set slot2 "nothing"
*return
*elseif selling = slot3
*set slot3 "nothing"
*return
*elseif selling = slot4
*set slot4 "nothing"
*return
*elseif selling = slot5
*set slot5 "nothing"
*return
*elseif selling = slot6
*set slot6 "nothing"
*return
*elseif selling = slot7
*set slot7 "nothing"
*return
*elseif selling = slot8
*set slot8 "nothing"
*return
*else
ERROR
*finish
#Do not sell the item
*return
*label sellprice3
*return
is completely unneccessary. I forgot to delete it when I copied the buying list to speed up the process. And I believe that is a breaking bug. Might give you an error about indentation and even if you corrected the indentation, it would stop you from selling the ring if your inventory was full.