ID:148358
 
In my game, you can lift up bushes and pots (like in zelda). When you lift them, it puts the item in your inventory, and takes it out when you put it down. Here's the code for that:

Bush
icon = 'mapobj.dmi'
icon_state = "bush"
name = "bush"
density = 1
verb
Lift()
set src in oview(1)
for(src in get_step(usr, usr.dir))
if(usr.holding == 0)
usr.icon_state = "bush"
src.getitem()
src.loc = usr
src.verbs+=/obj/Light/Bush/proc/Put_Down
usr.verbs-=/mob/verb/Attack
usr.holding = 1
else
usr << "You are already holding something!"
proc
Put_Down()
set src in usr
var/mob/player/P
usr.icon_state = null
src.loc = usr.loc
if(usr.dir == SOUTH)
step(src,SOUTH)
flick("bushbreak",src)
if(usr.dir == NORTH)
step(src,NORTH)
flick("bushbreak",src)
if(usr.dir == EAST)
step(src,EAST)
flick("bushbreak",src)
if(usr.dir == WEST)
step(src,WEST)
flick("bushbreak",src)
sleep(5)
src.verbs+=/obj/Light/Bush/verb/Lift
src.verbs-=/obj/Light/Bush/proc/Put_Down
usr.holding = 0
del(src)

That works fine, but because i'm using the character handling library, if you quit while you still have the bush lifted, it will stay in your inventory when you log back in. holding will still = 1 so you can't lift anything else, but the Put Down command won't show up so you can't put the bush down. I've tried during Login() and Logout() to write code to drop the item by checking if(holding == 1) but i can't get it to either add the Put Down command or just del the item, i just get compilation errors and runtime errors.
No put usr in procs. Ungh.

Lummox JR
In response to Lummox JR
Funny you speak!

Yah Lummox I used to have a lot of problems with usr in my procs. When you told me not to a while ago I've been getting less logic errors than ever before!
In response to Unowuero
Unowuero wrote:
Funny you speak!

His caveman voice when talking about misuse of usr, Lummox JR often uses. </yodaish>

Yah Lummox I used to have a lot of problems with usr in my procs. When you told me not to a while ago I've been getting less logic errors than ever before!

Remember, kids: UsrIsEvil. Except when it's not. =)
In response to Lummox JR
is this better?

Bush
icon = 'mapobj.dmi'
icon_state = "bush"
name = "bush"
density = 1
verb
Cut()
var/mob/player/P = usr
set src in oview(1)
for(src in get_step(P, P.dir))
flick("attack",P)
flick("bushbreak",src)
sleep(5)
src.getitem()
del(src)
return
break
Lift()
var/mob/player/P = usr
set src in oview(1)
for(src in get_step(P, P.dir))
if(P.holding == 0)
P.icon_state = "bush"
src.getitem()
src.loc = usr
src.verbs+=/obj/Light/Bush/proc/Put_Down
P.verbs-=/mob/verb/Attack
P.holding = 1
else
P << "You are already holding something!"
proc
Put_Down()
var/mob/player/P = usr
set src in usr // says P is not a valid src setting
P.icon_state = null
src.loc = P.loc
if(P.dir == SOUTH)
step(src,SOUTH)
flick("bushbreak",src)
if(P.dir == NORTH)
step(src,NORTH)
flick("bushbreak",src)
if(P.dir == EAST)
step(src,EAST)
flick("bushbreak",src)
if(P.dir == WEST)
step(src,WEST)
flick("bushbreak",src)
sleep(5)
src.verbs+=/obj/Light/Bush/verb/Lift
src.verbs-=/obj/Light/Bush/proc/Put_Down
P.holding = 0
del(src)
if(P.canattack == 1)
P.verbs+=/mob/verb/Attack

still does not solve my problem though. i'd appreciate it if instead of mocking me for my mistakes, you would help me. sorry if i've been away from BYOND and i'm a bit rusty, but a little help would be nice.
In response to Shizuka
actually, it's alright to use usr in verbs and such, but not in mob/proc, use arguments instead, or src.
In response to Goku72
ok thanks, i wasn't sure if it was ok to use usr in verbs that aren't the usr's mob.
fixed it myself.