Script Template 2

OurJud
Here's another script template I would like to own.

A room with two objects and all the permutations therein. A reminder that I don't use auto-lists so have no choice but to script this manually.

I need the script to cater for the room containing both objects, containing either objects, and containing no objects. I also need to allow for the objects being dropped back in that room.

As before I'll try and blunder my own way through it, but it will no doubt be a poor attempt with lots of redundancies and unneeded code.

So:

1. You are in the lounge. There's a glass table here on which sits a gun and a bunch of keys.

2. You are in the lounge. There's a glass table here on which sits a gun.

3. You are in the lounge. There's a glass table here on which sits a bunch of keys.

4. You are in the lounge. There's a glass table here.

You may be wondering why I can't just use the other script, with the shed and the axe, but because this has to incorporate two objects I'd still end up getting lost.

XanMag
Can you just make the glass table a surface object?

OurJud
I suppose, but would that mean I wouldn't have to script it all?

Problem is I manually describe my objects in the room description, so I'm not sure this would be the answer.

XanMag
Sounds like some confusing if/else if scripts checking for flags. Personally, I'd make one of those objects not droppable and would remove it after its served its purpose. That way you're only dealing with one flag.

Or, better yet, for me, not write those in the room description at all. If the player drops one of those objects in that room, script it so they place it on the tables surface.

If player is in [room with table] then move [keys] to parent table else move [keys] to current room.

But... I'm confused... How do you handle it if they drop the keys in any other room?? That object would be printed as there anyway? Right?

ChrisRT
Here's how I would do it, based on what you described:

Objects on table.jpg


Do you need to be able to drop the objects in the lounge and have them appear somewhere other than the table? If so, I could think about how to do that (I'm sure it's possible). Otherwise, XanMag's suggestion about moving the keys/gun back to the table when dropped is easy enough to implement:

Objects on table 2.jpg


You could repeat this as necessary so that you can drop the items in other rooms and have them appear in the descriptions. This worked for me, in any case - hopefully it answers your question?

OurJud
XanMag wrote:But... I'm confused... How do you handle it if they drop the keys in any other room?? That object would be printed as there anyway? Right?

Yes, dropping an object anywhere other than where it's originally described has always been a problem for the way I do things, but Chris may have solved that in his post above. I just need to get my head around this part and test run it.

Chris, not tested it yet, but you've understood what I want to achieve, and I've no doubt that first script will handle it all.

As for dropping objects in another room and having them added to the description for any given room, you may have to elaborate for me.

Are you saying that there's a way to have a room description be added to if I drop an object there. So that:

"You are in the hallway."

Could become something like:

"You are in the hallway. A bunch of keys lie on the floor."

?

I'm guessing I use the 'After dropping' function, and say:

if parent = (room name)
Print "A bunch of keys lie on the floor."

But how would I set that to a default for any given room?

I worry about the state of my mind. Seriously, I do. I've been using Quest for almost 18 months now, but rather than learning, I'm failing to understand even the basics. I'm actually going backwards in terms of my ability to do things.

XanMag
My guess, OurJud, is that you begin doing that once you've sat and stared into your monitor for far too long. It is ALWAYS happening to me!

In terms of your issue, I don't know why you don't use the add the object to a rooms description. I know it is probably less realistic, but it would save this enormous headache. Or, if you want to keep it the way you have it, perhaps you can alter the built-in code for the 'add object to room description'? It has to be alterable, right? I'm in no way suggesting I know how to do this or even the slightest idea on the possibility of it, but it has to be somewhere and you probably can access it, yes? You'll have to wait for a better coder to help out if you pursue that option.

Good luck!

ChrisRT
Using auto-generated descriptions would probably result in less of a headache, as XanMag says - especially if you have a lot of items involved. :P

In case you did want to pursue this line of scripting, though, I created a second 'Office' room with a desk, and then copied and pasted the first part of the script (attachment 1), replacing 'table' with 'desk', as well as adding a new expression to the drop script. Essentially, when you drop an item, the script checks where the player is, and then places the item accordingly:

Objects on table 3.jpg


Which means that you can do things like this. Of course, the more items there are, the more work it will be. (I'm not sure what you would do if you wanted three or more items in the same room - yikes.) The project I'm working on also doesn't use auto-generated descriptions, so I can sympathise with difficulties you might find with it - I've already found a few in mine. :?

Objects on table 4.jpg

OurJud
I just can't focus today.

I don't pretend to understand this 'drop' business, but it looks like far too much work.

I think I'll just stick to passing the responsibility over to the player. If they drop an object, then it's up to them to remember where if they want it back.

Just seems illogical to not have an object included in the description if it's there.

Like Xan says, if I can change the default: "You can see (object)" (or whatever the hell it says when you auto-list objects ) then I might go down that route.

ChrisRT
Sorry for taking up your time, in that case.

OurJud
And now you see my response as having your help thrown back in your face. Which it certainly wasn't.

You've solved my original question, which was to offer a script template that handled my needs, and for that I am very grateful.

This whole 'dropping objects in a different room' thing was spill-over from my OQ, and I was merely asking if this aspect could be done easily. Now that you've shown me a possible solution, it appears not.

I apologise if my reply came across as ungrateful.

HegemonKhan
if you just want to move a dropped Object back to it's original location:

// script examples:

check_and_return_dropped_object_to_original_location_function (silver_key)
check_and_return_dropped_object_to_original_location_function (gold_key)
check_and_return_dropped_object_to_original_location_function (skeleton_key)

// --------------------------------------

<function name="check_and_return_dropped_object_to_original_location_function" parameters="object_parameter">
if (not object_parameter.parent = game.pov) {
if (object_parameter.name = "silver_key") {
if (not object_parameter.parent = dungeon_room_5.coffin) {
object_parameter.parent = dungeon_room_5.coffin
}
} else if (object_parameter.name = "gold_key") {
if (not object_parameter.parent = castle_room_8.armor_statue) {
object_parameter.parent = castle_room_8.armor_statue
}
}
// etc 'else ifs' as needed
}
</function>


this code design can be much improved so you don't got a ton of 'else ifs' for all of your Objects (this would be for another post), but this is the basic concept design.

-----------

if you want your Rooms to adjust whether certain Objects have been in-game dropped-added to them by the player... that's a separate issue and post

OurJud
Thanks, HK.

Having the objects included in the description, after dropping them in the room from which they were originally taken, is not the problem here. It's getting them to appear in the description for rooms in which they were not originally located that's the troublesome part.

HegemonKhan
you need to iterate through a list of objects in the room, and check if they're contained in another list that has your selected default objects for~of that room, and if not, then do whatever you want with that new out-of-place object (such as to add~display it to your room's description), for example:

foreach (current_object_variable, ScopeVisibleNotHeldNotSceneryForRoom (game.pov.parent)) {
if (not (ListContains (game.pov.parent.default_objects_in_room_list, current_object_variable))) {
// something like this (syntax may not be correct but hopefully you get the idea, I'm too lazy at the moment to figure out the syntax needed):
game.pov.parent.description = game.pov.description + ". You notice {object:current_object_variable.name} out of the corner of your eye, spotting it for your first time, having missed it before."
}
}

OurJud
No, you're not understanding me.

Take a look at the two imaginary sequences of gameplay. The first one is how it is, the second is how I WANT it to be.

It's very important to remember here that I DO NOT use the auto-list objects feature, and would prefer to include any objects in my description, manually.

------------------------
CURRENTLY THIS IS HOW MY GAME PLAYS:

You are in the bedroom. There's a gun lying on the bed. The lounge is to the north.

> take gun
You pick it up.

> look
You are in the bedroom. The lounge is to the north.

> drop gun
You drop it.

> look
You are in the bedroom. There's a gun lying on the bed. The lounge is to the north.

> take gun
You pick it up.

> n
You are in the lounge.

> drop gun.
You drop it.

> look
You are in the lounge.

--------------------------
THIS IS HOW I WANT IT TO PLAY:

You are in the bedroom. There's a gun lying on the bed. The lounge is to the north.

> take gun
You pick it up.

> look
You are in the bedroom. The lounge is to the north.

> drop gun
You drop it.

> look
You are in the bedroom. There's a gun lying on the bed. The lounge is to the north.

> take gun
You pick it up.

> n
You are in the lounge.

> drop gun.
You drop it.

> look
You are in the lounge. There's a gun lying on the floor.

Forgewright
And you don't want to use the in room description tab in gun setup?

The Pixie
The way I would handle this is to turn the auto-list objects feature back on, but have each object flagged as scenery. Then have the room description check if the object is scenery.
You are in the bedroom. {if gun.scenery:There's a gun lying on the bed. }The lounge is to the north.

When the player picks the gun up, Quest will automatically turn scenery off for it, so the room description will no longer include it. When the player drops it, it will get included in the autodescriptions (this does include dropping it back in the lounge, so it will not be quite as you want; you could have a drop script that checks the room, and if it is the lounge resets the scenery flag).

OurJud
Forgewright, you'll have to elaborate before I can answer that.

TP, this seems like the solution with the least amount of work. What I'm wondering, though, is when you say it will not be quite what I want because the object will get auto-listed when dropped, could I just not leave the auto-list feature off and say:

You are in the lounge. {if gun.lounge:There's a gun lying on the floor. }

Where 'lounge' will be changed to whatever room I'm in?

Having said that, this isn't feasible either, as I'd have to include that rule in EVERY single room, and for EVERY single object I'm carrying.

All in all I think I either need to accept that objects will only be included in the descriptions for their original location, or turn auto-list on.

Pertex
Or you could use inroomdescriptions. Here is a small example

<!--Saved by Quest 5.6.5621.18142-->
<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="inroom">
<gameid>270c7386-0112-45d4-8af1-64bd1482dcb1</gameid>
<version>1.0</version>
<firstpublished>2016</firstpublished>
<attr name="autodescription_youcansee" type="int">0</attr>
<appendobjectdescription />
</game>
<object name="lounge">
<inherit name="editor_room" />
<description>A fine lounge.</description>
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
<object name="gun">
<inherit name="editor_object" />
<take />
<inroomdescription>There's a gun lying on the bed.</inroomdescription>
<ontake type="script">
gun.inroomdescription = "There's a gun lying on the floor."
</ontake>
<ondrop type="script">
HandleSingleCommand ("look")
</ondrop>
</object>
</object>
</asl>

OurJud
Thanks, Pertex, but I'd have to do that for every single room and object. I ain't going there :shock:

Pertex
Hmm, then I don't understand your problem. You want to turn off the build-in object autolist but want to create a new object autolist? When should which object be displayed where?

OurJud
Pertex wrote:Hmm, then I don't understand your problem. You want to turn off the build-in object autolist but want to create a new object autolist? When should which object be displayed where?

Okay, let me try and explain again.

I like to describe my objects in the room description, rather than use the auto-list feature which simply adds "You can see a [object name]" on it's own line, after the room description.

I do this because in literary terms, I think:

You find yourself in an old, dusty hut. A workbench sits in the corner, on which lies a rusty machete.


Sounds far better than:

You find yourself in an old, dusty hut.
You can see a workbench and a machete.


So in order to do this I must turn off the auto-list objects feature.

However, my problem with that, is that if the player drops an object in any room, other than the one where the object was originally contained, that object would not show up in that room. It would be there, but it wouldn't be included in the room's description. This would result in something like:

You are in the kitchen. Exits lie to the north and west.
> drop machete

You drop it.
> look
You are in the kitchen. Exits lie to the north and west.


So far the best solution for me seems to be to change the default prefix / suffix for the auto-list objects.

I hope that makes thing clearer.

Pertex
I don't see an easy solution to do this. You would have to rebuild the core functionality. I think you would need a text for every object, when it is not taken and when it is dropped. But combining the texts of two objects like "A workbench sits in the corner, on which lies a rusty machete." is difficult.

OurJud
I know. I've kind of come to the same conclusion myself. Ah well.

XanMag
Dumb comment but...

EDIT: Yep. Dumb comment. Go figure. :lol:

The Pixie
A way to do it would be to change ShowRoomDescription, and have it use one description if there is nothing in the room, and a second if there is. The second description might look like this:

"A workbench sits in the corner, on which lies %."

The function would replace "%" with whatever is in the room (which could use FormatObjectString as usual). Even better, ShowRoomDescription checks to see if there is a second description, and if not does some default tacked on to the end of the normal description.

That said, if you have any room descriptions that are scripts, not strings (and I tend to have a lot), you would also need to take account of that.

Forgewright
I threw this together in about 20 min. It may not be what you want but it is how I do it. You can drop cup on floor or place cup on objects. When you look at objects you will get a response I think you'd prefer.

Pertex
The Pixie wrote:A way to do it would be to change ShowRoomDescription, and have it use one description if there is nothing in the room, and a second if there is. The second description might look like this:

"A workbench sits in the corner, on which lies %."

The function would replace "%" with whatever is in the room (which could use FormatObjectString as usual). Even better, ShowRoomDescription checks to see if there is a second description, and if not does some default tacked on to the end of the normal description.

That said, if you have any room descriptions that are scripts, not strings (and I tend to have a lot), you would also need to take account of that.


But what if you drop the machete in an other room than the workbench room? Then you would need another description for the machete. So you would need to script the description text for every object and room. And this is somthing OurJud don't want to do

Pertex
Forgewright wrote:I threw this together in about 20 min. It may not be what you want but it is how I do it. You can drop cup on floor or place cup on objects. When you look at objects you will get a response I think you'd prefer.


Yes but you have to do this for every object in your game!

The Pixie
Pertex wrote:But what if you drop the machete in an other room than the workbench room? Then you would need another description for the machete. So you would need to script the description text for every object and room. And this is somthing OurJud don't want to do

No, you just code a generic description for all objects in the room. Here is an example game. In the lounge, objects are added to the description as normal, but in the klitchen and workshop, the "lookwith" attribute is used, and the objects are inserted into that.
<!--Saved by Quest 5.6.5783.24153-->
<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="rooms">
<gameid>06e182d3-ba14-4b77-8244-afdec814dc23</gameid>
<version>1.0</version>
<firstpublished>2016</firstpublished>
</game>
<object name="lounge">
<inherit name="editor_room" />
<description>There is a long sofa here, with two matching chairs all facing the TV.</description>
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
<exit alias="south" to="kitchen">
<inherit name="southdirection" />
</exit>
<object name="hat">
<inherit name="editor_object" />
<take />
</object>
<object name="ball">
<inherit name="editor_object" />
<look>The lounge has a long sofa, and two matching chairs, all arranged around a large screen television.</look>
<take />
</object>
</object>
<object name="kitchen">
<inherit name="editor_room" />
<description>The kitchen has a cooker and sink. There is a table too.</description>
<lookwith>The kitchen has a cooker and sink. On the table you can see %.</lookwith>
<exit alias="east" to="workshop">
<inherit name="eastdirection" />
</exit>
<exit alias="north" to="lounge">
<inherit name="northdirection" />
</exit>
</object>
<object name="workshop">
<inherit name="editor_room" />
<description>The workshop is a mess, with bit of junk everywhere.</description>
<lookwith>The workshop is a mess, with bit of junk everywhere, including %.</lookwith>
<exit alias="west" to="kitchen">
<inherit name="westdirection" />
</exit>
</object>
<function name="ShowRoomDescription"><![CDATA[
if (HasScript(game.pov.parent, "description")) {
do (game.pov.parent, "description")
}
else {
objects = FormatObjectList("", GetNonTransparentParent(game.pov.parent), "and", "")
if (not objects = "" and HasString(game.pov.parent, "lookwith")) {
fulldesc = Replace(game.pov.parent.lookwith, "%", objects)
}
else {
fulldesc = game.pov.parent.description
if (not objects = "") {
fulldesc = fulldesc + " You can see " + objects + " here."
}
}
if (LengthOf(fulldesc) > 0) {
msg (fulldesc)
}
}
]]></function>
</asl>

Forgewright
Right Pertex. I just thought some of it might be useful. I was trying to get the end result he wanted, Where the description looked more smooth. It is a simple line of code added to the "Look at" description, easily copy and pasted with an easy attribute change. I like the italicized addition of the objects without the generic link. It takes away from the fantasy of the game play. You have to type your commands, not point and click but that option is still available in the side panel.

OurJud
Thanks, all.

I've now tried both TP and Forgewright's test games.

Forgewright, as much as I appreciate your solution, when I tested it I couldn't see any difference between it and the default auot-list objects feature.

I'm not sure if it's done so that I can add my own descriptions or something, but when I dropped the cup in a different room, I just got the room description, followed by the hyperlink 'Cup' on its own line. All it seems to do differently from the default auto-list feature is remove the wording "You can see a ..."

TP, your test game appears to work very well, adding a far more colourful object description to a room, on look, than the default "You can see a ..."

Am I right in thinking all I need to do is copy & paste the ShowRoomDescription script into my own game?

Anyway, thanks to everyone for their efforts.

Pertex
The Pixie wrote:
No, you just code a generic description for all objects in the room. Here is an example game. In the lounge, objects are added to the description as normal, but in the klitchen and workshop, the "lookwith" attribute is used, and the objects are inserted into that.


Yes, but OurJud said "Thanks, Pertex, but I'd have to do that for every single room and object. I ain't going there". So I think he is searching a general way to create descriptions.
And his example "A workbench sits in the corner, on which lies a rusty machete." suggests that workbench and machete are normal objects and it's difficult to create one sentence with 2 or more objects.

I agree, that your solution works with lookwith in rooms. And inroom descriptions work with object.

OurJud
Pertex wrote:

"The Pixie"


I agree, that your solution works with lookwith in rooms. And inroom descriptions work with object.


But isn't that all it need to work with? I get one normal description on entering, and then a slightly different one with the objects added if I should drop them there.

I agree there will have to be a 'generic' description for objects dropped in any room other than their original, but there seems to be no alternative.

Pertex wrote:
And his example "A workbench sits in the corner, on which lies a rusty machete." suggests that workbench and machete are normal objects and it's difficult to create one sentence with 2 or more objects.

But to stay with this example, you have to remember the workbench wouldn't be takeable, so only the machete would need to be catered for in other rooms.

The Pixie
OurJud wrote:TP, your test game appears to work very well, adding a far more colourful object description to a room, on look, than the default "You can see a ..."

Am I right in thinking all I need to do is copy & paste the ShowRoomDescription script into my own game?

That should do it, and add the "lookwith" attributes for whatever rooms. Be aware that this overrides the darkness system. If you have dark rooms and sources of illumination it will need some modification, but the principle should still work.

OurJud
Thanks.

Forgewright
I was in a hurry and forgot to add the script to "look" description for each room. I added a "floor" object in each room that contained the code in look description and forgot the other. I know it wasn't what you wanted but it changed the look of "You see a cup."

OurJud
Ah, ok.

Thanks.

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

Support

Forums