ID:818676
 
Keywords: chest, gain, stuff, trouble
(See the best response by The Motto.)
Code:
obj
Gold_Chest
name = "Golden - Chest"
icon = 'Objects.dmi'
verb
Drop()
src.loc=locate(usr.x,usr.y-1,usr.z)
Grab()
set src in oview(1)
src.loc = usr
usr<<"You opened a [src]!"


Problem description: How would I code in that if I were to click the chest, I would gain gold. I've tried this but errors pop up. And I dont know how to create a proc for it.

obj
Gold_Chest
name = "Golden - Chest"
icon = 'Objects.dmi'
verb
Drop()
src.loc=locate(usr.x,usr.y-1,usr.z)
Grab()
set src in oview(1)
src.loc = usr
usr<<"<font color=gold>You opened a [src]!"
var/tmp/goldadd = rand(10-55)
usr.gold += goldadd


obj
Gold_Chest//should be tabbed properly
name = "Golden - Chest"
icon = 'Objects.dmi'
verb
Drop()
src.loc=locate(usr.x,usr.y-1,usr.z)
Grab()
set src in oview(1)
src.loc = usr
usr<<"<font color=gold>You opened a [src]!"
var/tmp/goldadd = rand(10-55)//Same here should be tabbed properly
usr.gold += goldadd
Click() // when it is being clicked
src.Grab()//run verb you created Grab
return..()//the return with its default behaviour it need to do


Here are the tips
1.Tab your work properly or you will get error 'error: inconsistent indentation'
2.Always use Dream Makers help file which can be accessed by pressing F1
Best response
You need to use the Click() proc here's an example
obj
Gold_Chest
name = "Golden - Chest"
icon = 'Objects.dmi'
Click()
src.loc = usr
usr<<"<font color=gold>You opened a [src]!"
var/tmp/goldadd = rand(10-55)
usr.gold += goldadd

if you dont understand what i did ask.
In response to Lord Kakarot
I do believe he doesn't want the grab proc to be active and in grab it has set src in oview ( i know ur just giving him an example) just what that line to set hidden = 1 if he wants the verb itself to be inactive
In response to The Motto
The Motto wrote:
I do believe he doesn't want the grab proc to be active and in grab it has set src in oview ( i know ur just giving him an example) just what that line to set hidden = 1 if he wants the verb itself to be inactive

Well its late where i live and i was as half sleep so i just helped his as quickest way i could.
Edit: You are making same mistake as he is (not tabbing properly) when he copies the code to try he will end up getting errors on inconsistent indentation
In response to The Motto
EDIT: Fixed , thanks for help.
Its better to use this
usr.gold += rand(10, 55)

Fixed.
What was the problem
Quite easy, I felt stupid when I fixed it.