Viewing object in another room
MerchantToo
06 Feb 2012, 10:13Hi,
I've been at this great program for a few days now, and I can't quite figure out how to make viewing things in another room possible - although I can, but I'm not yet satisfied with the result - maybe there is a better solution to the one I've tried:
Situation is the player is on the bridge of a spaceship. There is a "view port" object, and an exit "out" which is look only. When the player types "look at view port" or "look out", I get a little text description and then it runs a function I have defined, DescribeOutsideObjects, which currently takes an object as parameter. That parameter is the room that has been defined for the deck on the outside of the bridge (in space). I set it up like this because there will be lots of viewports, and I can for each view port just pass in the room (and maybe later rooms) that can be seen from a particular view port. The code looks like this:
So what my problem? Well I'm using the FormatObjectList function to display the contents of the room outside the ship, but the objects it displays have hyerlinks to verbs/commands which I don't want displayed. I couldn't find a suitable call to do this, and I didn't want to rewrite a whole function that deals with the syntax of a variable number of objects to describe them as text. The upshot is of course, the hyperlink appear, and are clicked upon, the automatic response of the system is "I can't see that", because of course the object isn't in the room.
That's not all of course, because I want to figure out how to intercept the "look at" for objects that are visible through viewports to give a different message than is given when the object is in the same room.
I'm probably digging myself into a hole, so any guidance would be appreciated. I kind of assumed when I saw the "make look direction only" toggle that there might already be a mechanism to sort this out, but haven't found that on the forum or wiki yet. Thanks.
I've been at this great program for a few days now, and I can't quite figure out how to make viewing things in another room possible - although I can, but I'm not yet satisfied with the result - maybe there is a better solution to the one I've tried:
Situation is the player is on the bridge of a spaceship. There is a "view port" object, and an exit "out" which is look only. When the player types "look at view port" or "look out", I get a little text description and then it runs a function I have defined, DescribeOutsideObjects, which currently takes an object as parameter. That parameter is the room that has been defined for the deck on the outside of the bridge (in space). I set it up like this because there will be lots of viewports, and I can for each view port just pass in the room (and maybe later rooms) that can be seen from a particular view port. The code looks like this:
<function name="DescribeOutsideObjects" parameters="Room">
if (ListCount(ScopeVisibleNotHeldNotSceneryForRoom(Room)) = 0) {
msg ("Nothing much going on outside, stars dont twickle in space.")
}
else {
msg (FormatObjectList("You can see", Room, "and", " on the hull of the ship", false))
}
</function>
So what my problem? Well I'm using the FormatObjectList function to display the contents of the room outside the ship, but the objects it displays have hyerlinks to verbs/commands which I don't want displayed. I couldn't find a suitable call to do this, and I didn't want to rewrite a whole function that deals with the syntax of a variable number of objects to describe them as text. The upshot is of course, the hyperlink appear, and are clicked upon, the automatic response of the system is "I can't see that", because of course the object isn't in the room.
That's not all of course, because I want to figure out how to intercept the "look at" for objects that are visible through viewports to give a different message than is given when the object is in the same room.
I'm probably digging myself into a hole, so any guidance would be appreciated. I kind of assumed when I saw the "make look direction only" toggle that there might already be a mechanism to sort this out, but haven't found that on the forum or wiki yet. Thanks.

Pertex
06 Feb 2012, 16:24Try this:
Your second problem could be solved, if you add scenery object to the room with the same alias of the objects outside the room. So if you "look at" an object, which seems to be outside it displays the text of the insideobject.
<function name="DescribeOutsideObjects" parameters="Room">
if (ListCount(ScopeVisibleNotHeldNotSceneryForRoom(Room)) = 0) {
msg ("Nothing much going on outside, stars dont twickle in space.")
}
else {
game.enablehyperlinks=false
msg (FormatObjectList("You can see", Room, "and", " on the hull of the ship", false))
game.enablehyperlinks=true
}
</function>
Your second problem could be solved, if you add scenery object to the room with the same alias of the objects outside the room. So if you "look at" an object, which seems to be outside it displays the text of the insideobject.
MerchantToo
06 Feb 2012, 21:01Thanks, yes that's what I was looking for. Will have to think about your other suggestion some more, because the main objects that will be seen (or not) through the view ports are little green Martians and the like, which can move across the hull of the ship. Maybe I should write a script which moves such a scenery object into the room you're in, and I suppose it should do that every time an action is performed for animation purposes. Seems a bit over the top, still wondering if there's a more elegant way of doing something like this.
MerchantToo
07 Feb 2012, 23:03OK, having thought about what you said some more I implemented the following: For each object that can be seen through a view port, I added an attribute FarView which points to a scenery object with the same alias. To that object I can add a different description, and now in fact I don't need to turn off the hyperlinks because when the hyperlink "look at" is chosen, because the scenery object has been moved into the current room, the description given is the one I want.
Thanks for the help so far, Just wondering now if there's a better method for only choosing the objects with the FarView attribute than the one I've shown here above?
<function name="DescribeOutsideObjects" parameters="Room">
if (ListCount(ScopeVisibleNotHeldNotSceneryForRoom(Room)) = 0) {
msg ("Nothing much going on outside, stars don't twickle in space.")
}
else {
msg (FormatObjectList("You can see", Room, "and", " on the hull of the ship", false))
foreach (obj, AllObjects()) {
if (HasAttribute(obj, "FarView")) {
if (obj.parent = Room) {
MoveObject (obj.FarView, player.parent)
}
else {
MoveObject (obj.FarView, EmptyVoid)
}
}
}
}
</function>
Thanks for the help so far, Just wondering now if there's a better method for only choosing the objects with the FarView attribute than the one I've shown here above?

Pertex
08 Feb 2012, 07:27This look good to me. You could of course create an objectlist at gamestart with all objects with the attrib FarView in it and use this list in your loop
MerchantToo
08 Feb 2012, 23:13Another great suggestion, and it just goes to show how rusty I am when it took me ages to figure out that I needed to declare a global variable in the start script to implement this.
Thanks again.
<start type="script">
game.FarViewObjects = NewObjectList()
foreach (obj, AllObjects()) {
if (HasAttribute(obj, "FarView")) {
list add (game.FarViewObjects, obj)
}
}
</start>
Thanks again.