Item_Seller
icon_state="Item Seller"
verb
Shop()
set src in oview(1)
var/list/ItemList=list("Restore"=300,"Beam"=500,"torch"=50,"Nothing"=0) //The item name and price
var/Item2Buy=input("What can I get for you today?","Item Seller") as anything in ItemList //they pick an item
var/Price=ItemList[Item2Buy] //this gets the price based on the list
if(Price) //if it has no price you cant buy it!
if(usr.Gold<Price)
usr<<"You need [ItemList[Item2Buy]] gold! You only have [usr.Gold]!"
else
usr<<"You Buy a [Item2Buy]"
var/obj/NewItem="/obj/[Item2Buy]" //note: this only sells items of the obj/Items/ path
NewItem=new NewItem //creates the actual object
usr.contents+=NewItem//add it to both their contents and Items list
usr.Gold-=Price
usr<<"Item Seller: Come again!"
obj
var
ammount
oname
proc
add_item(var/obj/item,var/mob/player)
obj
verb
get()
set src in oview(1)
usr<<"You picked up an [src]"
var/counter=0
switch(src.oname)
if("torch")
for(var/obj/Items/torch/O in usr.contents)
counter+=1
if(counter<=0)
Move(usr)
else
for(var/obj/Items/torch/O in usr.contents)
O.ammount+=src.ammount
O.name= "[O.oname] ([O.ammount])"
del(src)
if("Restore")
for(var/obj/Items/Scrolls/Restore/O in usr.contents)
counter+=1
if(counter<=0)
Move(usr)
else
for(var/obj/Items/Scrolls/Restore/O in usr.contents)
O.ammount+=src.ammount
O.name= "[O.oname] ([O.ammount])"
del(src)
if("Beam")
for(var/obj/Items/Scrolls/Beam/O in usr.contents)
counter+=1
if(counter<=0)
Move(usr)
else
for(var/obj/Items/Scrolls/Beam/O in usr.contents)
O.ammount+=src.ammount
O.name= "[O.oname] ([O.ammount])"
del(src)
bj
Items
torch
icon='torch.dmi'
icon_state="Unlit"
luminosity=0
ammount=1
oname="torch"
verb/light()
set src in usr
icon_state="Lit"
luminosity=2
usr.see_in_dark=3
usr<<"You light the [src]"
sleep(900)
usr.see_in_dark=1
var/give=1
if(src.ammount>=1)
usr<<"[src] is used up"
src.ammount-=give
src.name="[src.oname] ([src.ammount])"
if(src.ammount<=0) // if you have less then one torch delete stack
del(src)
Scrolls
Restore //20hp/mp
name="Restore Scroll"
icon='scroll.dmi'
icon_state="Healing1"
ammount=1
oname="Restore"
verb/cast()
set src in usr
if(usr.BasicSkillUse(src))
view()<<sound('restore.wav',volume=20)
usr.HP+=20
if(usr.HP>=usr.MaxHP) usr.HP=usr.MaxHP
usr<<"You gain 20 Health and Mana from the [src]!"
if(usr.BasicSkillUse(src))
usr.MP+=20
if(usr.MP>=usr.MaxMP) usr.MP=usr.MaxMP
var/give=1
if(src.ammount>=1)
usr<<"[src] is used up"
src.ammount-=give
src.name="[src.oname] ([src.ammount])"
if(src.ammount<=0)
del(src)
Problem description:Can anybody plz help me to fix this code to let my
item seller npc sell me multiple items and stack them?
runtime error: Cannot create objects of type null.
proc name: Shop (/mob/NPCs/Item_Seller/verb/Shop)
source file: NPCs.dm,67
usr: Bordakius (/mob)
src: Item Seller (/mob/NPCs/Item_Seller)
call stack:
Item Seller (/mob/NPCs/Item_Seller): Shop()
You Buy a Beam
this is what happens when i try to buy any of the items from the seller, it doesnt give me the item and i get the following error.
heres all the code for it all :) any help/code fix's greatly appreciated!!! :D