+---+ +---+
| 1 | #### 3 |
+-#-+ # +---+
# +-#-+
#### 2 ####
+-#-+ #
# #
######jaynabonne wrote:I can probably offer some specific coding options, but I wanted to get clear the mechanics first.
I had at one point considered adding a "back" option to my room movement. I wanted the player to be oriented and going back would take you back to the room you were just in. Here was the problem (and why I gave it up): what happens if you do it twice?
Let's say you have three rooms in a row, west to east. You start in the west-most room. You go east once and east again, so that now you're in the east-most room. You have come in from the west, so you're facing east. Now you type "back".
1) What is your orientation? (Did you step backwards into the previous room, so you're still facing east, or did you turn around to go back into the previous room, so you now face west?)
2) If you are in the rightmost room and hit back, you will be in the center room. If you hit back again, do you go back to the right most room (since you were just there), or do you go back to the left most room - a bit like a web browser's "back" button?
I suppose the questions are related in some ways. If "back" is relative to your orientation, then it sort of makes sense. If "back" means you step backwards but don't change orientation, then back twice would take you all the way back to the west room. If "back" means you turn around and go back, then back twice would return you to the east room, since you keep turning around.
In the interest of consistency, how you implement "back" has implications for "left" and "right" - do you sidestep or turn in that direction? If "left" and "right" cause you to turn in that direction, then it seems "back" should as well (so after "back", you'd be facing the other direction, and hitting back repeatedly would cause you to move back and forth between two rooms.)
Another possible way to design this: left and right just cause an orientation change (you spin left or right, but stay in the same room). Then the only way to move is forward or back. In fact, you could eliminate back altogether in that case. To go back, you turn left or right twice to turn around. That would allow the player to always know their orientation since it wouldn't change unless they changed it. It is a different approach, though.
HegemonKhan wrote:I'm not sure what you want (it would take me too long to map, lol pun, everything you want in your posts), but as for the movement:
just have multiple (separate) verbs~commands:
go_or_move_back, walk_or_strafe_backwards, go_or_move_forward, go_or_move_left, go_or_move_right, walk_or_strafe_left, walk_or_strafe_right
go_or_move = you turn (orient yourself) in that direction and then go in that direction
walk_or_strafe = you just go in that direction without turning (your orientation doesn't change at all)
* Err... my usage of "go", "move", and "walk" aren't placed very well... switch them around as needed to make more sense
* Not sure how you would code in the orientation though... (maybe JaynneBonnie can figure it out).... lololololol
-------------
for the "hansel and gretzel dropping seeds", you could have them be directional (drop left_arrow_tile, drop right_arrow_tile, etc etc etc), but that would probably completely eliminate the challenge of the maze, lol.
------------
P.S.
there's a fun old school board game called, ~ the A-Maze-Ing Labryinth
jaynabonne wrote:That makes sense. Thanks for the clarification.
And now, at the risk of sounding thick again, what are your questions exactly?
jaynabonne wrote:1) Knowing which way the player has come into a room. You can either override the "go" command to save the exit navigated (I've done it - it's a single line addition to the function), or you can set an "onchanged" script for the player's parent attribute, see what the old and new room values are, and work out what has been traversed.
jaynabonne wrote:2) Changing the exit names to be relative to the player's orientation. Some sort of "on enter" script which checks the data set by 1) and appropriately modifies the exit names. If you do that, then you should be able to navigate the exits without additional code, and the "You can go" text will be right.
jaynabonne wrote:3) Managing the multiple tiles. Since you want to be able to refer to the tile object, even to the extent of not being able to take it, the tiles must be separate objects. So you can either have 20 different tile objects, each uniquely numbered, or you can have a "prototype" tile object that you clone and assign a new index to when needed.
jaynabonne wrote:As far as one tile per entrance or one per room - I think (given my limited experience and thoughts about this) that one per room should be sufficient to enable tracking things (the player will need a map), and it's less complex than trying to manage up to four tiles, both for the player and the game. Just my take...
jaynabonne wrote:By the way, I have some code I can dig up that changes the compass directions to "F", "L" and "R". It could easily be expanded to include a "B".
<exit0 type="object">otherroom</exit0>
<exitdir0 type="int">2</exitdir0>
<exit1 type="object">otherroom</exit1>
<exitdir1 type="int">1</exitdir1>
<exit2 type="object">otherroom</exit2>
<exitdir2 type="int">1</exitdir2>
<exit3 type="object">otherroom</exit3>
<exitdir3 type="int">0</exitdir3>ChangeRoom(game.pov.dir)ChangeRoom((game.pov.dir+1)%4)ChangeRoom((game.pov.dir+2)%4)ChangeRoom((game.pov.dir+3)%4)room = game.pov.parent
if (HasAttribute(room, "exit" + dir)) {
newroom = GetAttribute(room, "exit" + dir)
// Set new player direction.
game.pov.dir = GetInt(room, "exitdir" + dir)
if (newroom = room) {
// Same room. Force room description dump, etc
OnRoomEnter(room)
} else {
// New room. Just move.
game.pov.parent = newroom
}
} else {
msg("You can't go that way.")
}jaynabonne wrote:It's funny how I miss the subtle ramifications of things. The diagram hadn't even registered properly. Given my new understanding, my first option to you won't work, as modifying the "go" command would just record the "exiting" exit, not the "entering" one. And you can't make inference from that.
jaynabonne wrote:More to the point, even "changedparent" won't work, because as far as I know, that only fires if the value has actually changed. Which has even larger ramifications, as Quest uses a "changedparent" script to handle "enter room" scripts. In other words, if you try to move to the same room, basically, nothing happens. No events fired, nothing. It's like you didn't move. I haven't tried it, but that's what I think will happen, based on the code.
Given the unusual requirements that you have, I'd be tempted to forget exits altogether and use some other data structure. I could flesh that out a bit if you'd like, but basically I could see each room having four attributes, one for each room that the player can move to. I haven't worked out how to handle the entry direction, though, but I'm sure it can be done.
The other way to do it would be if somehow you could have "hidden" rooms that manage the bends. So if you have a room that has a north exit that re-enters from the west, then you could have an intermediary room that you go north to which would then have an exit heading east into the target room - and the intermediate room would need to automatically "forward" the player somehow on to the target room and also not print anything. I don't know if it's easy to do or not, but it could work, in theory. :)
jaynabonne wrote:Ok, more thoughts, along the first lines...
You could number the four directions: N = 0, E = 1, S = 2, W = 3. (North, East, South and West actually have no relevance, but just to help you visualize.) Order is important, as to turn right, you add 1 (mod 4) and to turn left you subtract 1 (mod 4). [or you add 3, mod 4, if mod returns negative results,].
jaynabonne wrote:The each room could have up to four main target attributes:<exit0 type="object">otherroom</exit0>
<exitdir0 type="int">2</exitdir0>
<exit1 type="object">otherroom</exit1>
<exitdir1 type="int">1</exitdir1>
<exit2 type="object">otherroom</exit2>
<exitdir2 type="int">1</exitdir2>
<exit3 type="object">otherroom</exit3>
<exitdir3 type="int">0</exitdir3>
Only the exits you actually need would show up in each room. The number X in "exitX" is the exit direction. The value in the "exitdirX" attribute is the new (entry) direction.
The player/pov would have a "dir" attribute (or orientation or whatever you want to call it). To go forward, you'd do:ChangeRoom(game.pov.dir)
To go right:ChangeRoom((game.pov.dir+1)%4)
To go back:ChangeRoom((game.pov.dir+2)%4)
To go left:ChangeRoom((game.pov.dir+3)%4)
And ChangeRoom would be a function taking a "dir" parameter, with something like:room = game.pov.parent
if (HasAttribute(room, "exit" + dir)) {
newroom = GetAttribute(room, "exit" + dir)
// Set new player direction.
game.pov.dir = GetInt(room, "exitdir" + dir)
if (newroom = room) {
// Same room. Force room description dump, etc
OnRoomEnter(room)
} else {
// New room. Just move.
game.pov.parent = newroom
}
} else {
msg("You can't go that way.")
}
set flag current.room="00"set flag previous.room=current.room
set flag current.room="n"jaynabonne wrote:You need to dump out the exits yourself, if you want the player to know (and not bumping blindly into walls). It may seem complicated. Perhaps there is a better way to do it. I'll think some more.
jaynabonne wrote:As far as tiles, I had originally thought of just marking the room with the tile number. Then you'd have to have the description dump out "You can see a tile with the number XXX on it." And that would work. But... people might try "x tile" or "take tile". You would not want it to spew out "I can't see that." So if you don't want objects in each room, then perhaps you could have custom commands in each room (use a base type to keep your sanity!) with commands for "x tile" and "take tile" that print out the messages you want.
jaynabonne wrote:Ok, I'll stop for now. Sorry for such a dump above. I hope it makes some sense.
I think I grasp it, changing to values makes sense, as does the adding and subtracting, and I can see how that works for determining which exit has been taken. But I am struggling to see how that sets up the orientation of the player when they enter the new room.
<object name="room1">
<!-- south exit (dir 2) landing in eastern direction (dir 1) in room 2-->
<exit2>room2</exit2>
<exitdir2>1</exitdir2>
</object>
<object name="room2">
<!-- north exit (dir 0) landing in eastern direction (dir 1) in room 3-->
<exit0>room3</exit0>
<exitdir0>1</exitdir0>
<!-- east exit (dir 1) landing in northern direction (dir 0) in room 2-->
<exit1>room2</exit1>
<exitdir1>0</exitdir1>
<!-- south exit (dir 2) landing in western direction (dir 3) in room 2-->
<exit2>room2</exit2>
<exitdir2>3</exitdir2>
<!-- west exit (dir 3) landing in northern direction (dir 0) in room 1-->
<exit3>room1</exit3>
<exitdir3>0</exitdir3>
</object>
<object name="room3">
<!-- west exit (dir 3) landing in southern direction (dir 2) in room 2-->
<exit3>room2</exit3>
<exitdir3>2</exitdir3>
</object> <function name="HasExit" parameters="dir" type="boolean">
dir = (game.pov.dir + dir) % 4
return (HasAttribute(game.pov.parent, "exit"+dir)
</function>
// Then in your description code.
exitlist = NewList()
if (HasExit(0)) {
list add(exitlist, "forward")
}
if (HasExit(1)) {
list add(exitlist, "right")
}
if (HasExit(2)) {
list add(exitlist, "back")
}
if (HasExit(3)) {
list add(exitlist, "left")
}
// Then generate the string from it
// Stolen from the Quest core's FormatExitList function
s = "You can go "
count = 0
length = ListCount(exitlist)
foreach (exit, exitlist) {
s = s + exit
count = count + 1
if (count = length-1) {
s = s + " or "
} else {
s = s + ", "
}
}
s = s + "."
msg(s)jaynabonne wrote:[sinp]
Please note that all this code I'm handing you is untested!
jaynabonne wrote:Since I feel I've led you down this garden path, here is a complete workup of what we have discussed (attached). You'll see there are no exits, just custom commands and attributes to connect things together.
Note that this code works, which means I fixed the errors in what I have given you so far (there were several). I also left the room names in so that you don't get too disoriented!
Edit: I put some "Debug" logging in so you can see the room/dirs. for each move.
You are in a Bottom of mineshaft.
You can go up or south.
You are stood at the bottom of the mineshaft. A ladder leads up and a dark passage leads south.
> south
You are in a T-Junction.
You can see a Number 1.
You can go right, back or left.
> back
You are in a Bottom of mineshaft.
You can go up or south.
You are stood at the bottom of the mineshaft. A ladder leads up and a dark passage leads south.
> s
You are in a T-Junction.
You can see a Number 1.
You can go forward, back or left.
jaynabonne wrote:It seems downright confounding (in a good way). I'm glad you have the rooms numbered for now. I think the chalk will be essential. Given that the player will know they have chalk, you might want to consider "use chalk" to be one of your verb choices.
I ran into one odd thing, but it might just be a bug. This is my initial sequence after going down:You are in a Bottom of mineshaft.
You can go up or south.
You are stood at the bottom of the mineshaft. A ladder leads up and a dark passage leads south.
> south
You are in a T-Junction.
You can see a Number 1.
You can go right, back or left.
> back
You are in a Bottom of mineshaft.
You can go up or south.
You are stood at the bottom of the mineshaft. A ladder leads up and a dark passage leads south.
> s
You are in a T-Junction.
You can see a Number 1.
You can go forward, back or left.
It seems odd to me that the first time I come in, it shows "You can go right, back or left." and the second time from the same direction (an anchor point!), I get "You can go forward, back or left." Things are hard enough... lol
Looks good, though!