mob/var/list/Vault = list("Cancel")
obj/Vault
icon = 'Random.dmi'
icon_state = "Vault"
density = 1
verb/Vault(mob/player/M)
set src in view(1)
flick("Vault flick",src)
icon_state = "Vault open"
switch(input("What Shall You Do?","Storage") in list("Withdraw Item","Deposit Item","View contents","Cancel"))
if("Withdraw Item")
var/obj/item/W = input("What do you want to withdraw?","Withdraw Item") in M.Vault
if(W == "Cancel")
flick("Vault close",src)
src.icon_state = "Vault"
return
var/AS = input("You have [W.count] [W]. How many do you wish to deposit?","How many?") as num
if(AS == 0)
flick("Vault close",src)
src.icon_state = "Vault"
return
if(W.count < AS)
M << "You don't have that many stored!"
flick("Vault close",src)
src.icon_state = "Vault"
return
var/obj/item/L = locate(W) in M.contents
if(L)
L.count += AS
W.count -= AS
if(W.count == 0)
M.Vault -= W
L.suffix = "[L.count]"
M << "You withdrew [AS] [L]!"
else
var/obj/item/O = W
O.count = AS
O.suffix = "[O.count]"
O.loc = M
M << "You withdrew [AS] [O]!"
flick("Vault close",src)
src.icon_state = "Vault"
if("Deposit Item")
if(M.contents == null)
M << "You have nothing to deposit!"
flick("Vault close",src)
src.icon_state = "Vault"
return
else
var/obj/item/D = input("What do you want to deposit?","Deposit") in M.contents
switch(alert("[D] is the item you chose. Are you sure this is what you want to deposit?","Deposit [D]?","Yes","No"))
if("Yes")
var/AS = input("How many would you like to deposit?","How many?") as num
if(AS == 0)
flick("Vault close",src)
src.icon_state = "Vault"
return
if(D.count < AS)
M << "You don't have that many!"
flick("Vault close",src)
src.icon_state = "Vault"
return
var/obj/item/L = locate(D) in M.Vault
if(L)
L.count += AS
D.count -= AS
if(D.count == 0)
del D
L.suffix = "[L.count]"
else
M.Vault += D
del D
flick("Vault close",src)
src.icon_state = "Vault"
if("No")
flick("Vault close",src)
src.icon_state = "Vault"
return
if("Cancel")
flick("Vault close",src)
src.icon_state = "Vault"
return
if("View contents")
var/list/L = list()
for(var/obj/item/O in M.Vault)
L += O
switch(alert("These are the items in your vault, [L]","Items","Done"))
if("Done")
flick("Vault close",src)
src.icon_state = "Vault"
return
Problem description:
As you can see, I making an item storage code here and I've run across some problems.
1. It doesn't show you what's in your vault.
2.You can't withdraw items. This is why.
runtime error: Cannot read null.count
proc name: Vault (/obj/Vault/verb/Vault)
source file: Turfs.dm,3247
usr: Pyrodragon (/mob/player/GM/Admin/Pyro_Dragons)
src: Vault (/obj/Vault)
call stack:
Vault (/obj/Vault): Vault(Pyrodragon (/mob/player/GM/Admin/Pyro_Dragons))
3.I don't know if the deposit part is working right.
Thanks for the help.
You don't need to use mob/player/M here. usr is acceptable.