ID:155293
 
Well I'm curious is there any way that I could edit this

switch(input("Welcome to my shop,what would you like to buy?") in list ("Healing powder : 50","Cobweb : 100","Healing leaf : 200","Water of life : 400"))


And make it so that I use some sort of a list. What I actually wanna do is to have it show some basic items to buy and that later on you can unlock some and that they just appear there, Is that possible? (And I know I could make it with a bajilion "If" statements but is there any easier way? like just using a list for it all and add the unlocked stuff to it?)
To have the list expand, you could have a player variable which adds whatever is in it to the list (Which you would have to modify as the person levels up)

mob
var
list
ExtraItems = list("Potion","Rock","Stick")


This way has a lot of overhead and makes the assumption that all shops will sell the same items (if it did not make that assumption, then the extra item list may have to be split into many extra item lists to account for individual shops. I won't put that code here, but if you want it, I can.)

Another way is to have the NPC run a check on the person's level and add items accordingly.

mob
NPC
verb
Interact()
set src in oview(usr,1) Usable only if the person is beside the NPC
var/list/L = list(new /obj/Item1, new /obj/Item2, new /object/Item3) // Base list of what to buy. (These will have to be paths in this example)
if(usr.level >= 4) // If the person meets the level reqs
L += new /obj/Item4 // You can add it many different ways, this is pretty simple though
var/obj/X = input("BUY SOMETHING!") in L
if(usr.gold < X.price) // If they don't have enough
// Don't let em buy it
else
// Buy it code


The reason paths are necessary in this example is because I am relying on the object's variables that are coded in. It is possible to pre-define these lists as a global list (if you desire)

I would go with this way. If there is a better way, someone else will have to explain it.