ID:139212
 
Code:
obj
shop
icon = 'Shop.dmi'
icon_state = "shop"
density = 1
verb
Buy()
set src in view(2)
input("What will you buy?") in list ("Stone Price=50","Wood Price=50","Zombie scroll Price=1000")
if ("Rock Price=10")
if (usr.Wealth >= 50)
new/obj/stone(usr)
usr.Wealth -= 50
usr << "You bought a stone!"
else
usr << "You dont have enough!"
if ("Wood Price=50");
if (usr.Wealth >= 50)
new/obj/wood(usr)
usr.Wealth -= 50
usr << "You bought a piece of wood!"
else
usr << "You dont have enough!"
if ("Zombie scroll Price=1000")
usr << "Out of stock try again later"


Problem description:I'm trying to make a shop i thought i had it going all by myself but i guess i was wrong and got snagged on what is probably something that's simple im not noticing but can someone point out why when i buy something it buys everything?

NOTICE:If you need ANY more info just tell me and come back in a few hours ill be monitoring this page to see if anyone can help and if i see anything ill post up the info

Please and thank you :D


Your conditionals are not checking the actual input. Try this.

switch(input("What will you buy?") in list("Gold","Silver","Butter","Eggs","Cancel"))

if("Gold")
// Do something here
if("Silver")
// Do something here
if("Butter")
// Do something here
if("Eggs")
// Do something here
if("Cancel")
// Please, come again!


Your if statements are checking whether strings ("Stone Price=10", "Wood Price=50") return true before executing the code below them, not whether the player selected stone over wood. Strings do return true, therefore the code is attempting to purchase every possible item for the player. To better understand how strings return true, execute this code:

if("Do strings return true?")
src <<"Yes! They do!"
else
src <<"No! They do not!"
In response to Rauta
Thanks lets see if i can get it to work :O


ill leave a message if it does/dosnt
In response to Shwb1
srry forgot to leave the message XD thanks it worked :D