ID:261728
 
Thats right, i have sleeping problems, wait. Okay, the code under is a sleep proc. But when i call the proc, it doesn't work. Can somebody help me make it work?


mob
player/proc/Sleep()
var/obj/house/bed/A
if(src in get_step(A,src.dir))
src.loc = A.loc
Unknown Person wrote:
Thats right, i have sleeping problems, wait. Okay, the code under is a sleep proc. But when i call the proc, it doesn't work. Can somebody help me make it work?


mob
player/proc/Sleep()
var/obj/house/bed/A
if(src in get_step(A,src.dir))
src.loc = A.loc

Yes! You didn't use usr in a proc! Heh heh heh.

I think your problem resides in the if(). I don't think it can be used that way. I think you would need to do;
if(A.loc == get_step(src,src.dir))


~>Volte
In response to Volte
It gives me this runtime error at this line.

if(A.loc == get_step(src,src.dir))

runtime error: Cannot read null.loc
proc name: Sleep (/mob/player/proc/Sleep)
source file: Main.dm,50
usr: Dragon Lord (/mob/player)
src: Dragon Lord (/mob/player)
call stack:
Dragon Lord (/mob/player): Sleep(Dragon Lord (/mob/player))
Dragon Lord (/mob/player): Center()
In response to Unknown Person
Unknown Person wrote:
It gives me this runtime error at this line.

if(A.loc == get_step(src,src.dir))

runtime error: Cannot read null.loc
proc name: Sleep (/mob/player/proc/Sleep)
source file: Main.dm,50
usr: Dragon Lord (/mob/player)
src: Dragon Lord (/mob/player)
call stack:
Dragon Lord (/mob/player): Sleep(Dragon Lord (/mob/player))
Dragon Lord (/mob/player): Center()

Geh. Silly me.
mob/proc/Sleep()
for(var/obj/bed/B in get_step(src,src.dir))
src.loc = B.loc
break


Try that.

~>Volte
In response to Volte
Volte wrote:
Geh. Silly me.
mob/proc/Sleep()
for(var/obj/bed/B in get_step(src,src.dir))
src.loc = B.loc
break

Wouldn't locate() be more direct than using a for() loop?

Lummox JR
In response to Lummox JR
Lummox JR wrote:
Volte wrote:
Geh. Silly me.
mob/proc/Sleep()
> for(var/obj/bed/B in get_step(src,src.dir))
> src.loc = B.loc
> break

Wouldn't locate() be more direct than using a for() loop?

Lummox JR
if(locate(/obj/bed) in get_step(src,src.dir))


There. :)

~>Volte
In response to Volte
Even better...

<code>mob player/proc/Sleep() var/obj/house/bed/A=locate() in get_step(src,dir) if(A) src.loc = A.loc</code>

That way, A actually has a value. =)