struggling with a bed and a chair

bowlfreak_not
I have a room with a bed object and a chair object. I've managed to move the player to the chair or the bed on command. Then the user types 'stand up'... So I think I have come up with two choices, 1. create a command that tests if the player is 'in' something - I don't know how to do that and react accordingly, or 2. create a function and pass in true if the player is in the bed or on the chair or false if the player types stand up from somewhere else. Is this even close to being the correct way of looking at the problem or am I completely off-base? Thank you.

XanMag
Can the player do anything from the bed and chair or is it just for realism?

adammadam
you could just set a flag on the player when the player is moved to the bed and call it "in bed" or something, then when they get back out of the bed unset the flag. Same for the chair or anything else. Then with your stand up command you can have it say different things depending on what flag is set e.g. if the bed flag is set "you get out of bed and stand up again.." (unset player flag "in bed").. that kind of thing.

The Pixie
The problem with moving the player to the chair is that if she then drops something, the item will be inside the chair, rather than inside the room. There are ways to handle that, but I think it is generally easier to do it adammadam's way, and have a flag on the player that remembers whether or not she is currently sat down, and another for in bed.

bowlfreak_not
Oh, thank you, I hadn't thought about dropping objects, but if the player were to drop an object while in bed I think I would want it to stay on the bed, or in the bed object... I think... but not the chair, that would be weird. So if I set flags instead, do I then have to add a check to the exit room script, (I haven't really look at this yet, so I apologize), or whatever it is called to see if my flags are set, in case the player tries to leave the room without first standing up?

XanMag, yes, I think there would be some things the player might need to accomplish while in the chair or bed, (for instance, going to sleep). I'm not sure really because I'm still learning the language and playing around with what's possible and the best way to do things.

adammadam
yeah if the player does anything like leave the room, you can have it as if the player flag is set to in bed, "you get out of bed and leave the room" unset flag in bed. That way the player can type to leave the room, but you remove the flag that they're in bed as well, so wherever they go and the next time they enter the room, they arent still flagged as in bed! Theres many things to consider like for example if youre in bed and type "get in chair" you'd want it as if player has flag in bed "you get out of bed and sit in the chair" (unset flag in bed, set flag in chair) that kind of thing. You just need to consider that if the player does anything that causes them to leave the bed or chair, make sure to unset the flag that theyre in it. Then for things like sleeping, you could have it like if player has flag in bed.. you go to sleep.. else you get in to bed (set flag in bed) and go to sleep.. or "you need to get in bed first" (if you prefer it that way).

XanMag
I posted a code below that is similar to something that I did in another game. Ignore all of the other stuff that is in there. It was for other tests!

<object name="A">
<inherit name="editor_room" />
<description type="string"></description>
<usedefaultprefix type="boolean">false</usedefaultprefix>
<enter type="script">
if (RandomChance(50)) {
MoveObjectHere (Ned)
if (ListContains(ScopeVisible(), Ned)) {
msg ("You are in Room A with Ned.")
}
else {
msg ("You are in Room A by yourself.")
}
}
</enter>
<onexit type="script">
MoveObject (Ned, Dead Room)
</onexit>
<exit alias="north" to="D">
<inherit name="northdirection" />
</exit>
<exit alias="south" to="B">
<inherit name="southdirection" />
</exit>
<object name="backpack">
<inherit name="editor_object" />
<inherit name="container_open" />
<look>It is a backpack.</look>
<alt type="stringlist">
<value>pack</value>
<value>bag</value>
</alt>
<take />
<feature_container />
<listchildren />
</object>
<object name="apple">
<inherit name="editor_object" />
<look>It's a red apple.</look>
<take />
</object>
<object name="HKs head">
<inherit name="editor_object" />
<alias>HK's head</alias>
<look>It is the ugliest thing you have every seen. lol</look>
<take />
</object>
<object name="bed">
<lie type="script">
msg ("You climb into bed.")
MoveObject (Fred, bed)
</lie>
<geton type="script">
msg ("You climb into bed.")
MoveObject (Fred, bed)
</geton>
<look>It's a bed.</look>
<description>You are lying in a bed in room A.</description>
<command name="bed dir cmd">
<pattern>n;s;e;w;ne;nw;sw;se;u;d</pattern>
<script>
msg ("Shouldn't you get out of bed first?")
</script>
</command>
<command name="exit bed ccmd">
<pattern>get up;get out of bed;get off bed</pattern>
<script>
msg ("You crawl out of bed.")
MoveObject (Fred, A)
</script>
</command>
</object>
<verb>
<property>geton</property>
<pattern>get on</pattern>
<defaultexpression>"You can't get on " + object.article + "."</defaultexpression>
</verb>
<object name="banana">
<inherit name="editor_object" />
<look>It's a yellow banana.</look>
<take />
</object>
</object>


What I did was that I added an object called bed. In the GUI editor there is an option to change it to a room/object, which I did. Under the object tab, I gave it a description as I would if I looked at it from the bedroom (room A). Under the room tab, I simply put down the description of the room as if I were lying on the bed.

To get into bed, I added a verb to the bed - "lie down on" (etc) and a "get on" verb. In the script for each, I put 'move player 'Fred'' to bed. I added a command to the 'bed' room object/room and typed the following under the 'command pattern' box: w;e;s;n;ne;nw;se;sw;u;d

I added a script that printed this message "Shouldn't you get out of bed first?" You could add a command and replace the cardinal directions with "sleep" and a script for whatever you want to happen.

I added another command to the 'bed' object/room and typed the following under the 'command pattern' box: get out of off;get off bed;stand up (or whatever other cmd you think is appropriate) and then added a script to 'move player Fred' to room A.

HegemonKhan
I would use String Attributes or String List Attributes:

if you only want~need a single Value at a time, use a String Attribute:

player.locomotion_state = "standing"
player.locomotion_state = "sitting"
player.locomotion_state = "laying down"
player.locomotion_state = "jumping"
player.locomotion_state = "squating" // or: = "crouching"
player.locomotion_state = "falling"
player.locomotion_state = "floating"
player.locomotion_state = "flying"
player.locomotion_state = "swimming"
player.locomotion_state = "climbing"
player.locomotion_state = "crawling"
player.locomotion_state = "sneaking"
player.locomotion_state = "running"
player.locomotion_state = "walking"
player.locomotion_state = "hanging"
player.locomotion_state = "sliding"
player.locomotion_state = "gliding"
etc etc etc


and then use the 'if' Script checking, for example:

player.locomotion_state = "standing"

'chair' Object's 'sit' Verb:

if (player.locomotion_state = "sitting") {
msg ("You are already sitting down, silly.")
} else if (player.locomotion_state = "standing") {
msg ("You sit down in the chair.")
player.locomotion_state = "sitting"
}

'chair' Object's 'get up' Verb:

if (player.locomotion_state = "sitting") {
msg ("You get up from the chair.")
player.locomotion_state = "standing"
} else if (player.locomotion_state = "standing") {
msg ("You've already up out of the chair, standing up.")
}

'bed' Object's 'drop' Verb:

if (player.locomotion_state = "sitting" or player.locomotion_state = "laying down") {
hat.parent = bed
msg ("You drop your hat onto the bed.")
} else if (player.locomotion_state = "standing")
hat.parent = bedroom
msg ("You drop your hat on the floor of your bedroom, next to your bed.")
}


------

somewhat similiar with String List Attributes, except you can have multiple states (Values) at the same time, and also with working with String List Attributes, you'd add~remove the Values as needed, as opposed to changing them as you do with String Attributes (and only being limited to one Value at a time, whereas String List Attributes can have multiple Values at a time).

bowlfreak_not
Actually, I was trying it with an attribute set to "sitting", etc, just like you suggested but I got funky results for my text output. When I tried it XanMag's way I got the same weird output. So I'm doing something wrong.... probably many things. At the moment, I've got a mixture of the two going and i'm trying to trace through the library functions.

Thank you so much. Both these examples really helped me a lot. Now I have to figure out why my code calls the script of both verbs attached to the object.

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums