Updating the room description automatically?

The player is adding ingredients to a cauldron. Every time they add an ingredient, I would like the room description to update. As in, they use the item and the full room description appears again reflecting the new state of the cauldron.
I saw a previous question similar to this and a user suggested using HandleSingleCommand("look"), but didn't elaborate on where to put that in the code or how to do it with the GUI, and when I tried just slapping it in on my own, it crashes the whole program when I try to enter that room. Needless to say, I'm not much good at coding so, small words please.


In programming, there are several way to do this.
Are the ingredients added in order, IE: A, then B, then C...
OR can they be added in any order? IE: A, then C, then B?
Is the order part of a puzzle for the player to figure out?
If the order is important, then it's easy.


Is this like what you want?
change the room description to "run script".
click on the </> button. It says "Code View".
And paste this into the box:

msg ("This is the room generic description.")
switch (cauldron) {
  case (0) {
    msg ("The cauldron is empty. Maybe you could add something to it.")
  }
  case (1) {
    msg ("It is now filled with water.")
  }
  case (2) {
    msg ("There is some wood under the cauldron, ready to be lit.<br/>")
  }
  case (3) {
    msg ("There is a little fire burning under the cauldron and it's ready for you to start prepairing your potion.")
  }
}

You will need to create a variable game.cauldron and set it's value to "0".
When the player add water to the cauldron, set game.cauldron =1
When the player add the wood, set game.cauldron =2
When the player lights the wood, set game.cauldron=3
I'm sure you can figure the rest out.
Now, if the player is at step 2, the room description would look like:
This is the room generic description.
There is some wood under the cauldron, ready to be lit

Or at least it should look like that.


Thank you, I think I was over complicating it a bit.


Is it possible to use that script to create multiple changes in a room description that can be created out of order? Is there a safety on that particular script that keeps the player from adding water after lighting the fire?
If a player moves the counter to step 3, is it moved back to step 1, when step 1 task is completed?


Yes, but you would have a complicated IF tree...
Actually, no, not complicated. But it would work the same way. But if you want to prompt the player as what to do next it would get a bit complicated...
You could set-up several Boolean variables...
game.pot.empty T=empty, F=not empty
game.pot.water T/F
game.pot.wood
game.pot.fire
and so on.
So now, it would look like this:
(The room description, and you can even add the pot description in the middle here so that it doesn't look, or feal, like the pot's description is just tacked on...)
(How large the pot is would affect the description. Is it a small soup pot that would hang from a hook that you would move over a fire or a large waist high 30 inches across and sitting on the floor? Like a witch's cauldron?)
For this, an if tree would be easer than switch because you are dealing with several variables.
(And I'm sure the other Quest pros would do this differently...)

(code to follow...)


Looking forward to it. And thanks.


I'm creating it as a mini game to show how I would do it. You should be able to add the rest.
There are other tricks that can be used to add and remove verbs from objects so that you can open an open window. I just can't think of it right now.


OK, here is a simple "game" that gives you 3 things to add to the cauldren, wood, water and fire. Other stuff to add SHOULD be just as "simple".
I couldn't get the window to work, but that was just a second thing to change the room descriptions. (fixed!)
If you look at the cauldren, then it's description is blank because it is described in the room.
Let me know if you have any other questions...
(bad link.)
If you have 2 copies of Quest running, then you can copy from one to the other.


There may be a way to just do all this to the cauldren and have IT'S description added to the room description.


The game file is missing. Yes, I'd like to know how to add activating a verb, like look at, to a script.


Strange, it said the file didn't exist and wouldn't let me download it either. I guess they don't like the extension. I've uploaded the file again as a txt file, just change the extension to aslx and Quest should be able to run it...
AND, I got the window fixed so that it changes the room description as well.
Try this: https://mega.nz/file/pi4lVCSQ#41RRz3g3ELRgZZSHBRmifFWBQZodzthlTby6QgZt58A


Thanks!
It will take me a while to analyze it, as I'm not actually code-fluent, but I glean a little here and there. I just would not know where to paste everything even to run the game, yet. I will look into it. It looks neat.


There may be a way to just do all this to the cauldren and have IT'S description added to the room description.

if (HasString (cauldron, "look")) {
  msg (cauldron.look)
}
else if (HasScript (cauldron, "look")) {
  do (cauldron, "look")
}

That's how the lookat verb does it. Relatively simple.

Yes, I'd like to know how to add activating a verb, like look at, to a script.

Technically "look at" is a command, not a verb.
You can invoke it (and other commands) by doing something like:

do (lookat, "script", QuickParams ("object", cauldron))

If you want to use a verb on an object, you can also do it using a shorter method, like:

do (cauldron, "lick")

(if you know that it has that verb)

You could also fall back on the command parser, and do something like:

HandleCommand ("look at cauldron")

although this would also run all the turnscripts again, and can behave unpredictably in some circumstances


I have learned a lot from reading that. And the more I learn, the more I see there is to learn.
Thank you.


do (cauldron, "take") does not work. I do not know why not.


I am told (when not using cauldron, as I haven't one) that while things accept :
do (lookat, "script", QuickParams ("object", cauldron))
they expect :
do (take, "script", QuickParams ("object", cauldron))
to lead to a "list" of objects.

I know I can just tap "add to inventory,
but I wonder if other verbs are "not commands" and what can be done for them all.
I don't really expect anyone to have the time for it, but there is a lot of room for more instructional pages. Maybe, these are secrets, though.


The more you learn, the more you realize you don't know that much.


do (cauldron, "take") does not work. I do not know why not.

Because take is a command, not a verb.

(verbs are a special type of command, which just check if the object has a script attribute with the same name as the verb and runs that script)

to lead to a "list" of objects.

Ah yes… take and drop behave a little differently, because they can take multiple arguments. For example, the player can type "take bell, book, candle" or "drop all". Because it's always running the code that knows how to parse a list of objects, the argument is a list even if it's a list with one item in it.

I know I can just tap "add to inventory,

The big difference here is that the "take" command does a lot more than adding an item to the inventory. It checks if there are limits on the number or weight of items a player can carry, and whether the object is reachable (not in a locked container, for example). It then checks the object's take behaviour (can take, can't take, or run script) and acts as appropriate; and if the object was taken, prints a message to say that the object was taken. AddToInventory just moves an object to the player's inventory without any checks or messages.

If I remember correctly, the take command just loops over the list of objects it's been given and calls a function which does all this other stuff. So if you want to make sure that a script doesn't automatically give the player an object that's too heavy for them to carry, or similar, you would want to use the same function:

DoTake (cauldron, false)

(the second argument determines whether it will print "It's too heavy." or "Cauldron: It's too heavy." if there is some reason it fails. Generally, the take command only repeats the item name before errors if the player was trying to take more than one thing)


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

Support

Forums