ID:177172
 
obj
locker
icon = 'locker.dmi'
var/obj/locker = l
var
phaser = 10
communicator = 10
verb/Get_Phaser()
if(l.phaser >=1)
new /obj/phaser (usr)

could someone please take a look at this and tell me why it doesnt work. im trying to have the get phaser verb add a phaser to the usr inventory
Well...

l isn't defined, so l.phaser won't do anything. I assume you mean src.phaser, an in, the phaser var for the locker. In which case, it's still redundant, since you're not decrementing the phaser var.

ver/verb/Get_Phaser() doesn't work. Everything below and including verb/Get_Phaser() needs to be unindented one.

You need a "set src in oview(1)" at the start of the verb, so that you can use it without having it in your contents.
In response to Garthor
Garthor wrote:
Well...

l isn't defined, so l.phaser won't do anything. I assume you mean src.phaser, an in, the phaser var for the locker. In which case, it's still redundant, since you're not decrementing the phaser var.


Then the real question will be how to define it.
In response to Treasurecat
Treasurecat wrote:
Then the real question will be how to define it.

Or not. You don't NEED to define it, because you don't need to use it. Forget l, use src like Garthor said.

<code>obj locker icon = 'locker.dmi' var phaser = 10 communicator = 10 verb/Get_Phaser() if(src.phaser > 0) new /obj/phaser(usr) //Make a phaser in the usr's inventory src.phaser-- //Decrement number of phasers </code>
That should work.
In response to Crispy
...once you put set src in oview(1) in the verb.
In response to Garthor
Hehe, yep. Slipped my mind for a second. :)

Isn't it strange that whenever one of us helps someone in Newbie Central, the other almost always has something to add or correct? We're like a newbie helping team. :P
In response to Crispy
More like a couple of guys with too much free time.
In response to Garthor
Yep, lol. Although mostly I'm just reading the entire forum because I don't like to miss anything, and I think "might as well help this guy" :P