ID:146465
 
Code:
//dropping gold
obj/gold/var/amount = 0

obj/gold
icon = 'gold-bag.dmi'

mob
verb
drop_gold()
var/amount_to_drop = input(usr,"How much gold do you wish to drop?","Gold to Drop?",usr.gold) as num
amount_to_drop = round(amount_to_drop)
if(amount_to_drop > usr.gold)
usr << "You don't even have that much gold to drop."
return
if(amount_to_drop < 1)
usr << "You can not drop less than 1 gold."
return
else
var/obj/gold/bagofgold = new(usr.loc)
bagofgold.amount = amount_to_drop
usr.gold -= amount_to_drop
usr << "You drop [amount_to_drop] gold."
//getting gold
obj
verb
get()
set src in usr.loc
if(!amount_to_drop)
usr.Move(src)
usr.has_items += 1
usr << "You get [src.name]."


drop()
if(src.usage == "Equip")
usr << "This item is equip right now, remove it first"
return
if(src.usage == "None")
if(src.equip_types == "Weapon")
set src in usr.contents
src.loc = usr.loc
usr << "You drop [src.name]."
usr.has_items -= 1
if(src.equip_types == "Armor")
set src in usr.contents
src.loc = usr.loc
usr << "You drop [src.name]."
usr.has_items -= 1
obj
gold
get()
set src in usr.loc
usr.gold += amount_to_drop
usr << "You get [amount_to_drop] gold."
del(src)


Problem description:Ok now, I need to access the variable amount_to_drop from the drop_gold() verb in order to pick the (right amount of) gold up, but how. What the heck, this is pissing me off.
amount_of_gold is a local variable to the verb drop_gold. It can't be called aside from in that verb after it's declaration.

On the other hand, you can access the object's variable.

obj
gold
get()
set src in usr.loc
usr.gold += src.amount
usr << "You get [src.amount] gold."
del(src)
In response to SSJ2GohanDBGT
It is still not working, even though I'm now accessing the bagofgold.amount as src.amount, it is not working. Once again, here is the code.
//dropping gold
obj/gold/var/amount = 0

obj/gold
icon = 'gold-bag.dmi'

mob
verb
drop_gold()
var/amount_to_drop = input(usr,"How much gold do you wish to drop?","Gold to Drop?",usr.gold) as num
amount_to_drop = round(amount_to_drop)
if(amount_to_drop > usr.gold)
usr << "You don't even have that much gold to drop."
return
if(amount_to_drop < 1)
usr << "You can not drop less than 1 gold."
return
else
var/obj/gold/bagofgold = new(usr.loc)
bagofgold.amount = amount_to_drop
usr.gold -= amount_to_drop
usr << "You drop [amount_to_drop] gold."
//getting gold
obj
verb
get()
set src in usr.loc
if(!src.amount)
usr.Move(src)
usr.has_items += 1
usr << "You get [src.name]."


drop()
if(src.usage == "Equip")
usr << "This item is equip right now, remove it first"
return
if(src.usage == "None")
if(src.equip_types == "Weapon")
set src in usr.contents
src.loc = usr.loc
usr << "You drop [src.name]."
usr.has_items -= 1
if(src.equip_types == "Armor")
set src in usr.contents
src.loc = usr.loc
usr << "You drop [src.name]."
usr.has_items -= 1
obj
gold
get()
set src in usr.loc
usr.gold += src.amount
usr << "You get [src.amount] gold."
del(src)

Either I access the amount or not, it is not helping.