Can only list visible exits

xordevoreaux
I'm creating an ability in my game for people to find their way from one dark room to another by FEEL AROUND.

I couldn't get it to work by traversing across the ScopeExitsForRoom(player.parent), and couldn't figure out why.
So, I added something that prints out ListCount(ScopeExitsForRoom(player.parent)) when I type FEEL AROUND, and lo and behold, it's only returning a count of visible exits.

When I was in a dark room, ListCount(ScopeExitsForRoom(player.parent)) = 0
When I light the room up with a candle, ListCount(ScopeExitsForRoom(player.parent)) = 1 (there is one exit to the room).

I was trying to make it so when the player typed FEEL AROUND, that it would list the exits (and do some other, unrelated things).

Why would we as game creators not have available the ability to manipulate / expose all exits to the player, just because they're not visible?

jaynabonne
You do. You have several possibilities (I assume you're seeking a solution and not just asking a "why" question):

1) Make the exit a weak light source. That keeps it visible even in the dark room. (That may not work for you, as then the exits would probably show up in a default room description, though I haven't tried it, so I can't say for sure.)

2) Copy the ScopeExitsForRoom function into your game and make it do what you wish (ignore darkness state). However, other code uses ScopeExitsForRoom, including (probably) the room description code, which means you might have the same problem as in case 1.

3) Copy the ScopeExitsForRoom function into your game, rename it to something else so only you are using it, and then change it to not pay attention to darkness.

With Quest, game creators have the ability to do change much of what the core code does by copying it into their games and modifying it. Or there can be even more power in writing your own code - the object model is exposed for you to manipulate as you wish.

(To answer your question of "why": the "scope" functions generally have to do with the higher level concept of what the player is directly able to manipulate in the current situation, and they tie into much of how the engine works. Given your scenario above, I'm sure you're quite happy that exits are excluded from the current room description when dark, for example. The function you're looking for - getting all exits for a room regardless of current state - is a valid need, but it's not a "Scope" type function. And given it doesn't exist in the core code, it probably has not been asked for before. So you can make your own!)

jaynabonne
Here is a simple copy/modify of ScopeExitsForRoom that ignores darkness:

  <function name="MyScopeExitsForRoom" type="objectlist" parameters="room">
<![CDATA[
result = NewObjectList()
foreach (exit, AllExits()) {
if (exit.parent = room) {
if (exit.visible) {
list add(result, exit)
}
}
}
return (result)
]]>
</function>


Note I renamed the function so the core code won't use it, but you can call it directly. You can also remove the "visible" check if you want to list invisible exits in the room as well.

xordevoreaux
Thank you, the function that you extracted and adapted worked as desired. What you did is definitely a step up from what I'm capable of on my own at the moment.

xordevoreaux
Here is the result, where the "gloomy" room is the dark room. Again, thank you.

You are in a room.

> test
You have been moved to the testing center.

You are in a Testing Center.
The room is gloomy.

> feel candle
The candle feels ordinary.

> feel south
You make your way south, feeling your way.

You are in a Testing Center, South Room.
You can go north.

> n

You are in a Testing Center.
The room is gloomy.

> feel around
You feel your way around in the dark and find a way out leading:
south

> feel south
You make your way south, feeling your way.

You are in a Testing Center, South Room.
You can go north.

> n

You are in a Testing Center.
The room is gloomy.

HegemonKhan
here's a guide on using lists and dictionaries, if you're interested:

viewtopic.php?f=18&t=5137

if you need any help with anything, let me know, and I'll help you.

jaynabonne
xordevoreaux wrote:Thank you, the function that you extracted and adapted worked as desired.


Great! I'm glad it worked for you. :)

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

Support

Forums