ID:179206
 
Hey guys, im really at a the end of my tether with my sleeping code.

You see, the thing is im trying to make a simple 'sleeping' code which turns my characters icon into a bed for about 10 seconds, but when i made the icon change, they could still move around (thus the 'sleep walking' pun, lol) ... and... well... i became increasingly frustrated and deleted the code =(

If any of you guys can help, please do =)

Thanks a lot

Honzo
HonzoHattori wrote:
Hey guys, im really at a the end of my tether with my sleeping code.

You see, the thing is im trying to make a simple 'sleeping' code which turns my characters icon into a bed for about 10 seconds, but when i made the icon change, they could still move around (thus the 'sleep walking' pun, lol) ... and... well... i became increasingly frustrated and deleted the code =(

If any of you guys can help, please do =)

Thanks a lot

Honzo

You could try something like this:
mob/var/state
mob/verb/sleep(time as num)
var/original_icon
if(isnull(time)) time = 50 // if they chose 0 as time
if(time > 1000) time = 50 // if its over 100 seconds
if(time < 50) time = 50 // if its under 5 seconds
if(state != "standing")
src << "You must be standing to sleep!"
return 0

else
src << "You fall asleep, zzzzzzz"
original_icon = src.icon // store their icon
src.state = "sleeping" // change their 'state'
src.icon = 'bed.dmi' // change their icon
spawn(time) // spawn() for time
src.icon = original_icon // revert icon
src.state = "standing" // revert state
src << "Wakie wakie!"
return 1


mob/Move()
if(state=="sleeping") return 0 // if they are sleeping, dont let them move
else return ..() // else just go about as normal

Hope that helps.
Alathon
In response to Alathon
Thanks man, that really helped but i'm getting one error =(

it says:

error:invalid proc name: reserve word

on this line:

mob/verb/sleep(time as num)

I have never come accross an error like this before =-/

Can you see what's wrong?

thanks for the code again man, =-D

Honzo

In response to HonzoHattori
Take a look at the proc thats right before the verb, that might be causing the problem.

Alathon
In response to Alathon
Jeez =(

Sorry Alathon, but everything i write, just seems to build up the errors =(

Can you please teach me what I'm supposed to do?

i wrote:

proc
sleep

Before the sleep verb.

I'm just confused now :(

Please help

Honzo
In response to HonzoHattori
Hrm, i cant find out what im doing wrong :(

I'm sure some o' you kewl coders know whats wrong =)

Please help :-P

I can't continue my game until i have a resting place for the players =(

Honzo
In response to HonzoHattori
sleep() is a pre-defined proc that DM uses, and you're not allowed to override it, change /mob/proc/sleep() to /mob/proc/sleeping().