ID:177506
 
Hi how can i turn this
obj
shopguy
icon = 'bloke.dmi'
density = 1
usr << "yo whatcha wanna buy??"
//into a shop??
//i think i use sumthing like this =
item = input(Buy what??) in list('sword')
if(item == "sword")
new/obj/sword in usr.items
//or whatever the built in var is...
^i know that wont work but can sumone help??^
Spoon wrote:
Hi how can i turn this
obj
shopguy
icon = 'bloke.dmi'
density = 1
usr << "yo whatcha wanna buy??"
//into a shop??
//i think i use sumthing like this =
item = input(Buy what??) in list('sword')
if(item == "sword")
new/obj/sword in usr.items
//or whatever the built in var is...
^i know that wont work but can sumone help??^

Well, first you have to add a verb.
obj
  shopguy
    icon = 'bloke.dmi'
    density = 1
    verb
        Talk()  //Or anything you like
        usr << "yo whatcha wanna buy??"

Then you put what you would like to sell.
   var/item = input("Buy what","Shop") in list("Sword - 100 Gold","Nothing")  //You don't have to put var/ if you already declared the var item.
        if(item = "Sword - 100 Gold")
          usr.gold -= 100
          usr.contents += new /obj/sword //Make sure you make one if you havn't already.
          usr << "Here you go. Have a nice day!"
        if(item = "Nothing")
          usr << "Take your time"

The complete code:
obj
  shopguy
    icon = 'bloke.dmi'
    density = 1
    verb
        Talk()  //Or anything you like
        usr << "yo whatcha wanna buy??"
        var/item = input("Buy what","Shop") in list("Sword - 100 Gold","Nothing")  //You don't have to put var/ if you already declared the var item.
        if(item = "Sword - 100 Gold")
          usr.gold -= 100
          usr.contents += new /obj/sword //Make sure you make one if you havn't already.
          usr << "Here you go. Have a nice day!"
        if(item = "Nothing")
          usr << "Take your time"

Just copy and paste the code if you like. Every two spaces is a tab. If you highlight four spaces, press tab two times etc.

DiZzyBonne