obj/hotel_bed/var/being_used = 0
obj
hotel_bed
icon = 'land_objects.dmi'
icon_state = "bedtop"
Enter()
var/current_loc //this
being_used = 0 //should all be tested with another person
var/sleep = input(usr,"What would you like to do?","Hotel") in list ("Sleep","Nothing")
if(src.being_used) //Is it already being used?
usr << "This bed is already in use."
return
else
if(sleep == "Sleep")
if(usr.health == usr.maxHealth)
usr << "Why would you want to sleep, you're at full health."
return
else
current_loc = usr.loc
usr.loc = src
src.being_used = 1 //Already occupied
usr.movement = 0 //Can't move
sleep(10)
usr.sight |= BLIND //take away sight while sleeping
usr << sound('BOFHOUSE.mid',repeat=1)
usr << "You begin to sleep."
while(usr.health < usr.maxHealth)
sleep(20) //should be a variable like "rest_time" or something interactive with the user
usr.health += rand(2,7) //should be a variable that the user gets better over time
if(usr.health > usr.maxHealth)
usr.health = usr.maxHealth
usr << sound(0)
usr << "<font color =red>You're all rested up and are now at full health.</font>"
usr.sight &= ~BLIND //give sight back after sleeping
usr.movement = 1 //Can move again
src.being_used = 0 //No longer being occupied
usr.loc = current_loc
else
return
Problem description:
As you can see, I tried to override the Enter() proc with something so you can enter the bed and get prompted to sleep and all of the things below. The problem is that once you try to enter the bed, none of this works. The Enter() proc is totally ignored. Anyone have a clue why this isn't working properly? I haven't programmed DM in about a year but I came back to it and tried this, it's not working and it looks like it should be.
Your issue here is that you never actually move into the hotel_bed obj... or any obj at all (unless if you do something in your code to allow it). You are moving into the turf. Instead, you should define your own analogue to the Entered() proc... Stepped_On(atom/movable/M), which is called from turf/Entered() for all of the atom/movables in its contents.
For completeness, I've included Stepped_Off(), which is an analogue to Exited(). Step_On() and Step_Off() as analogues to Enter() and Exit() are also possible, though would require a bit more work and you don't seem to need them.
Now, another important issue: usr is very very very very wrong in any proc relating to movement. There is an argument to all of these procs (except Move(), in which case you can just use src) that you should be using instead. usr means something totally different than "the player I am thinking of right now," so avoid it where possible.
You'll just want to change Enter() to Stepped_On(mob/M) and you'll be set. Here's what it should look like
Remember to change all instances of usr to M. Additionally, the current_loc variable is redundant: you can just use src.loc for the location of the bed.