Run Script on room description

RedTulip
07 Apr 2011, 00:50
I really don't like the Standard Style, I didn't like the "You see..." or something like that, I wanted to make a custom one on script... But I don't know how to do that. I think you do it like this on Inform 7:

The description of the shore is "Along the shore, you see sharp rocks through the water, they appear as if they are preventing anyone to come in... Or escape this island.[line break][if amulet is on the shore]Lying on the sand is an emerald amulet, shining by the rays of the sun.[end if][line break][if key is on the shore]Halfway dug under the sand, you catch a glimpse of a shiny, silver object.[end if]"

What I am trying to say is, I want the "Lying on the sand is an..." to appear only if the amulet is on the shore, and the "Halfway dug under the sand, you catch a glimpse...", also, only if the key is on the shore. If the player got the key, for example, it won't appear.

Or maybe a way to edit the "You see..." message, as I only see a way to edit the "You are in..." message.

Alex
07 Apr 2011, 08:10
You could almost do this using the default room description:

- For your amulet object, give it a prefix of "Lying on the sand is an emerald" and a suffix of "shining by the rays of the sun"
- For your key, give it an alias of "silver object" and a prefix of "Halfway dug under the sand, you catch a glimpse of a shiny,".

You could then change the alias of the key using a script when the player examined it, if you wanted to turn it from a shiny object into a key.

This would give you everything apart from the linebreaks and the comma in the emerald suffix (as it would appear with an annoying space before it, I think), so it may be the simplest way to go.

If you don't like the standard style of room description, you can replace it globally by going to the Advanced tab on the Game editor, then giving a script for "To describe rooms in the game". There's a code example here http://www.axeuk.com/quest/developer/do ... ptions.htm which it will be easier to paste into your game using Notepad.

Alternatively, you can create a script just for this room by choosing "Run script" from the description style drop-down. It's pretty straightforward and you want a script that looks something like this:


Print "Along the shore, you see sharp rocks through the water, they appear as if they are preventing anyone to come in... Or escape this island."
If "amulet" is in the current room Then Print "Lying on the sand is an emerald amulet, shining by the rays of the sun."
If "key" is in the current room Then Print "Halfway dug under the sand, you catch a glimpse of a shiny, silver object."