ID:514755
 
ok! basically i got my shop working but items wont stack!!! if someone could help me would be great...

these are the obj codes
obj
var
Gprice=0
Sprice=0
Cprice=0
Amount=1

proc/price()
if(usr.C < 0)
usr.S-=1
usr.C+=100
if(usr.S < 0)
usr.G-=1
usr.S+=100
if(usr.G ==0 )
view() <<"you need more gold!"


obj/weapon/

sword
desc = "+5 power"
icon = 'sword.dmi'
Gprice=0
Sprice=5
Cprice=3
var

Aug=5


verb
get()
set src in oview()
loc = usr
suffix=desc
drop()
set src in usr
loc = usr.loc

equip()
if(usr.EquippedWeapon==0)
src.name="sword"
usr.EquippedWeapon=1
usr.pow +=src.Aug
usr.Rage()
view()<< "equipped [src.name]"

unequip()
if(usr.EquippedWeapon==1)
src.name="sword"
usr.EquippedWeapon=0
usr.pow -=src.Aug
view()<<"unequipped [src.name]"

ok so this is the shop code(not finished till stack works)
mob/shopkeeper

weapon_shop
icon = 'shop.dmi'
var/list/Inventory=list()
old_town_man
Inventory=list(new/obj/weapon/sword,new/obj/armor/)
verb/Shop()
set src in oview(1)
while(1) //Create an infinite loop
switch(alert("What would you like to do?","Shopping","Buy","Sell","Cancel"))
if("Cancel") return
if("Buy")
var/obj/O=input("What item would you like to buy?","Buying")as null|anything in Inventory
if(!O) continue //If O is null, restart the loop
if(istype(O,/obj/weapon)) //If O is of the /obj/weapon type
var/Quantity=input("How many would you like to buy?","Buying [O.name],[O.Gprice]G,[O.Sprice]S,[O.Cprice]")as null|num
Quantity=round(abs(Quantity)) //Make sure Quantity is positive whole number.
if(!Quantity||usr.G<O.Gprice*Quantity) continue //If Quantity is null OR the player does not have enough money, restart the loop
O.price()
usr.G-=O.Gprice*Quantity
O.price()
usr.S-=O.Sprice*Quantity
O.price()
usr.C-=O.Cprice*Quantity
O.price()
var/obj/N=locate(O.type) in usr.contents //Try to find an object that has the same type as O in the player's contents.
if(N) //If it exists...
N.Amount+=Quantity //Add the amount to the existing item.
else //If it doesn't...
N=new O.type //Create a new obj with the type of B.
N.Amount=Quantity //Add the amount to the new item.
usr.contents+=N //Add it to the player's contents.
usr<<"Old Man: Thank you!"
return //End the loop.


and in my stats i have the following inventory: statpanel("inventory",usr.contents)...so if you can help thank you and if you need more just ask ill add but this is what seemed significant

It doesn't look like you've done anything stack related so far? Are you looking for someone to help you create a stacking system, or provide advice on how to make one?
well help would be great but ill go for advice. im just not sure how to go about it from here. and the shop code was modified from a forum post i found so i thought that the last part
                 var/obj/N=locate(O.type) in usr.contents  //Try to find an object that has the same type as O in the player's contents.
if(N) //If it exists...
N.Amount+=Quantity //Add the amount to the existing item.
else //If it doesn't...
N=new O.type //Create a new obj with the type of O.
N.Amount=Quantity //Add the amount to the new item.
usr.contents+=N //Add it to the player's contents.
usr<<"Old Man: Thank you!"
return //End the loop.

was for that very purpose but i guesse i still have a lot to learn :S