New room description if item removed.
Gleve
27 May 2013, 13:15Hi, I'm very new to quest, but I desperately want to make a Text based game for my son.
He's great at maths, but not English (which is my forte), so a Text based game would be great for fun and education.
First stumbling block (and I can see quite a few occurring), is that I have a room description that I want to change when an item has been picked up.
Lounge room description while having item toys & rubbish needs to be 'x'.
Lounge Room description while having item toys, but not rubbish needs to be 'x'.
Lounge Room description while having item rubbish, but not toys, needs to be 'x'.
Does that make sense? I want to have three different room descriptions, but I can't seem to get the scripting to work the way I want it to.
Please help!
He's great at maths, but not English (which is my forte), so a Text based game would be great for fun and education.
First stumbling block (and I can see quite a few occurring), is that I have a room description that I want to change when an item has been picked up.
Lounge room description while having item toys & rubbish needs to be 'x'.
Lounge Room description while having item toys, but not rubbish needs to be 'x'.
Lounge Room description while having item rubbish, but not toys, needs to be 'x'.
Does that make sense? I want to have three different room descriptions, but I can't seem to get the scripting to work the way I want it to.
Please help!
Liam315
27 May 2013, 14:43So the simplest way I can think of is as follows:
Change the Lounge Room description from "text" to "script". For the script, you need to tell it what to print for each option, so create an if... script to begin with and use conditions based on what the parent of each of those objects is:
if - (toys.parent=lounge room) and (rubbish.parent=lounge room)
then: print message x
else if (toys.parent=lounge room)
then print message y
else if rubbish.parent=lounge room
then print message z
else
then print a message if neither the toys or rubbish are in the lounge room.
That is what you should do if the description changes significantly for each permutation. If having the object in the room just adds another part of the description rather than changing or subtracting the entire description, then you could go about it differently. e.g. have a script that says:
print first part of description.
if rubbish.parent=lounge room
then print next part of the description.
if toys.parent=lounge
then print another part of the description.
It all depends whether these different combinations are additive (each object adds another sentence) or transformative (each object affects all of the sentences).
Change the Lounge Room description from "text" to "script". For the script, you need to tell it what to print for each option, so create an if... script to begin with and use conditions based on what the parent of each of those objects is:
if - (toys.parent=lounge room) and (rubbish.parent=lounge room)
then: print message x
else if (toys.parent=lounge room)
then print message y
else if rubbish.parent=lounge room
then print message z
else
then print a message if neither the toys or rubbish are in the lounge room.
That is what you should do if the description changes significantly for each permutation. If having the object in the room just adds another part of the description rather than changing or subtracting the entire description, then you could go about it differently. e.g. have a script that says:
print first part of description.
if rubbish.parent=lounge room
then print next part of the description.
if toys.parent=lounge
then print another part of the description.
It all depends whether these different combinations are additive (each object adds another sentence) or transformative (each object affects all of the sentences).
Gleve
27 May 2013, 14:55Definitely additive.
I just figured out what you were talking about. You are using the expression function. I was trying to find an option for 'and'!
Will try. Thank you
I just figured out what you were talking about. You are using the expression function. I was trying to find an option for 'and'!
Will try. Thank you
Gleve
27 May 2013, 15:08That worked brilliantly. I will work with expressions in future I think.
I had been trying with the standard options ( if object is missing, blah blah) but I couldn't get it to work.
Next thing, is there anyway of making the exits and objects in a given room appear after the room description?
I had been trying with the standard options ( if object is missing, blah blah) but I couldn't get it to work.
Next thing, is there anyway of making the exits and objects in a given room appear after the room description?
Liam315
27 May 2013, 15:43Expressions are a very useful way to control the if scripts, and the standard options themselves are just commonly used expressions. If you select one of the option from the drop box, then change it back to expression, you can see how that particular option is written as an expression. I found this very instructive when I started learning how quest works.
As for listing object and exits after a room description, this should be a thing quest does by default. If you select "game" in the object tree and go to the tab marked "room descriptions," there are a bunch of options that control how exits and objects are displayed in the room description. You need to make sure the "scenery" options are not selected for the objects/exits if they are to appear in the description.
As for listing object and exits after a room description, this should be a thing quest does by default. If you select "game" in the object tree and go to the tab marked "room descriptions," there are a bunch of options that control how exits and objects are displayed in the room description. You need to make sure the "scenery" options are not selected for the objects/exits if they are to appear in the description.
Gleve
27 May 2013, 15:47Final question for the night, how do I make it so that if I try to put an object in a container that doesn't belong there, not work?
I tried to put a script in the give to section, but that didn't work. I want the rubbish bin to only accept the item rubbish. Currently, I can put toys in the rubbish, which I dont want. I would prefer it to give me a message saying something like toys dont go in the rubbish, that sort of thing.
I tried to put a script in the give to section, but that didn't work. I want the rubbish bin to only accept the item rubbish. Currently, I can put toys in the rubbish, which I dont want. I would prefer it to give me a message saying something like toys dont go in the rubbish, that sort of thing.
Liam315
27 May 2013, 16:03This one is a little bit trickier because the PUT command is a built-in feature of quest. You don't want to stop it from doing things like "put toys on bench" or something like that, so the best way (as far as I know) involves altering the behaviour at the command level.
First you'll need to go to the option below the object tree marked "filter" and select "show library elements. Then go to game>commands and find the one named "put". When you select this there will be a yellow bar at the top and a button marked "copy" which you need to click.
From here, scroll down through the script to where you can add another "else if" and add your conditions there. In this case it will be along the lines of
else if object1=toys and object2=rubbish
then print message "Toys don't go in the bin. Even if they are your sister's stupid boring dolls."
You're basically creating a special exception in this command for that particular combination of objects without creating any new verbs that might cause problems.
First you'll need to go to the option below the object tree marked "filter" and select "show library elements. Then go to game>commands and find the one named "put". When you select this there will be a yellow bar at the top and a button marked "copy" which you need to click.
From here, scroll down through the script to where you can add another "else if" and add your conditions there. In this case it will be along the lines of
else if object1=toys and object2=rubbish
then print message "Toys don't go in the bin. Even if they are your sister's stupid boring dolls."
You're basically creating a special exception in this command for that particular combination of objects without creating any new verbs that might cause problems.
HegemonKhan
27 May 2013, 23:08Liam has already answered, but here's my own similiar comments as well:
as Liam said, you basically need to alter the action (verb or command), to include a conditional (if script) element, for example, in conceptual terms (understanding "coding's logic"):
let's say we've got a boy's fort treehouse, wanting to maintain their "no girls allowed" policy.
for the associated action, let's say for example, "enter" (verb and~or command), we have a conditional:
if object_HK.gender=male {
-> move object_HK into treehouse (in code: object_HK.parent=treehouse)
} else if object_HK.gender=female {
-> msg ("Sorry, /"No girls allowed./"") // HK's Note: object_HK remains outside of the treehouse (in code: not object_HK.parent=treehouse; it remains effectively as: object_HK.parent=outside)
}
then, you just need to also "set" (add) the "flag" (boolean) attribute, object.gender=male or object.gender=female, upon the objects, such as on the object, object_HK.
this is just a conceptual example using a mix of quasi-coding and quasi-GUI-Editor lines, you'll have to figure out how to do this via code or GUI-Editor, or ask us how to do it for you, if you need help with it.
as Liam said, you basically need to alter the action (verb or command), to include a conditional (if script) element, for example, in conceptual terms (understanding "coding's logic"):
let's say we've got a boy's fort treehouse, wanting to maintain their "no girls allowed" policy.
for the associated action, let's say for example, "enter" (verb and~or command), we have a conditional:
if object_HK.gender=male {
-> move object_HK into treehouse (in code: object_HK.parent=treehouse)
} else if object_HK.gender=female {
-> msg ("Sorry, /"No girls allowed./"") // HK's Note: object_HK remains outside of the treehouse (in code: not object_HK.parent=treehouse; it remains effectively as: object_HK.parent=outside)
}
then, you just need to also "set" (add) the "flag" (boolean) attribute, object.gender=male or object.gender=female, upon the objects, such as on the object, object_HK.
this is just a conceptual example using a mix of quasi-coding and quasi-GUI-Editor lines, you'll have to figure out how to do this via code or GUI-Editor, or ask us how to do it for you, if you need help with it.
Gleve
28 May 2013, 00:17Is there a command line that says that only rubbish can go in there?
I expect I will make more objects in this game, and i really doubt I'm going to put in an else if command for every object I make.
Also, that command you gave me liam makes the item stay in the players inventory. Is that because it takes precedent over the action of putting it in the object?
I expect I will make more objects in this game, and i really doubt I'm going to put in an else if command for every object I make.
Also, that command you gave me liam makes the item stay in the players inventory. Is that because it takes precedent over the action of putting it in the object?
Liam315
28 May 2013, 02:28Yes, when you create an additional exception to the command for certain objects, it will override the rest of the command. So in this case, it won't put object1 in object2 anymore, it will only do whatever you've told it to. If you want to make it so that the bin only accepts rubbish (and that is the better way to do it), you can do it in the put command like so (remove the other one you added and use this):
~the beginning of the put command script is here~
else if (object2=bin) {
if (object1=rubbish) {
MoveObject (rubbish,bin)
msg ("You put the rubbish in the bin")
}
else {
msg ("The bin is only for rubbish!")
}
}
Gleve
28 May 2013, 02:43Thank you Liam. Now, are the questions you are answering for me on a post somewhere else? I feel as if I'm hogging all your time, and, believe me, I will continue to come up with questions if you dont tell me to stop!
My next question (told you) is with the Lounge room, I've got the msg's flowing correctly (if theres rubbish in the room play this message, if theres toys in this room, play this and so on) but can I add another exception where if either of the items is in the players inventory, that it plays another message?
I can see the command in the if options, but I can't see where it goes in the order of things.
As you can see, getting rid of loop holes is the name of my game. I would hate for my boy to figure out that if he picked up the rubbish and the toys in the loungeroom, and then looked at the loungeroom, that it would say it was clean, when in fact he just has the items in his hands.
Am I thinking too literally here? Should I let it go? Im trying to be very specific. Even at the age of 6, I just know he'd think outside the box and catch me out!
Side note, I tried to add that command that you suggested, where the first expression was, and now I can't load the game.... It says that I've taken out the put scripte. If you could send that to me, I'd be appreciative!
My next question (told you) is with the Lounge room, I've got the msg's flowing correctly (if theres rubbish in the room play this message, if theres toys in this room, play this and so on) but can I add another exception where if either of the items is in the players inventory, that it plays another message?
I can see the command in the if options, but I can't see where it goes in the order of things.
As you can see, getting rid of loop holes is the name of my game. I would hate for my boy to figure out that if he picked up the rubbish and the toys in the loungeroom, and then looked at the loungeroom, that it would say it was clean, when in fact he just has the items in his hands.
Am I thinking too literally here? Should I let it go? Im trying to be very specific. Even at the age of 6, I just know he'd think outside the box and catch me out!
Side note, I tried to add that command that you suggested, where the first expression was, and now I can't load the game.... It says that I've taken out the put scripte. If you could send that to me, I'd be appreciative!
Liam315
28 May 2013, 03:01haha, I'm more than happy to keep answering as many questions as you have. The more loop holes you consider and make scripts to take care of them, the better your game will be.
If you can post the description of the lounge room it would be easier to know how you should do it. The beauty of Quest is that is often more than one way to do something, depending on exactly what you want to accomplish.
I think want you want to do is add another condition using NOT in the expression. NOT is a recognised operator in expressions for the opposite of the condition you write. So if the lounge room has neither rubbish nor toys in it, you want to add another if condition like so:
Using the .parent attribute is better than checking for the items in the inventory, because if the toys and rubbish just get dropped in another room (i.e. they aren't in the inventory any more) the lounge room will still display the clean message. There is a function that you can use if you ever do need to check the inventory though, called scopeinventory().
Do you mean you deleted the entire put command? Because if you save the game, close quest, then reload it, it should appear in the default list again when you check "show library elements" and you can copy and edit it again from scratch.
If you can post the description of the lounge room it would be easier to know how you should do it. The beauty of Quest is that is often more than one way to do something, depending on exactly what you want to accomplish.
I think want you want to do is add another condition using NOT in the expression. NOT is a recognised operator in expressions for the opposite of the condition you write. So if the lounge room has neither rubbish nor toys in it, you want to add another if condition like so:
if ((not toys.parent=loungeroom) and (not rubbish.parent=loungeroom)) {
msg ("The lounge room is clean and tidy.")
}
Using the .parent attribute is better than checking for the items in the inventory, because if the toys and rubbish just get dropped in another room (i.e. they aren't in the inventory any more) the lounge room will still display the clean message. There is a function that you can use if you ever do need to check the inventory though, called scopeinventory().
Do you mean you deleted the entire put command? Because if you save the game, close quest, then reload it, it should appear in the default list again when you check "show library elements" and you can copy and edit it again from scratch.
Gleve
28 May 2013, 03:45I can't even open the game anymore.....
Unexpected 'else' (error with parent 'if':?)
Im going to have to start again arent I.....
Unexpected 'else' (error with parent 'if':?)
Im going to have to start again arent I.....
Liam315
28 May 2013, 03:56No, you shouldn't need to. If you attach your game to your next post I can open it up in a text editor and try and find the piece of code that's causing it not to open.
Gleve
28 May 2013, 04:09Se attached. Thank you for trying to salvage this
Liam315
28 May 2013, 04:17I'm not sure what's happened but the file you uploaded doesn't have anything in it apart from the default "room" and "player" objects.
Sora574
28 May 2013, 04:22Could you check to make sure that's the correct file?
As Liam said, it's nothing but a default template with your name in it.
As Liam said, it's nothing but a default template with your name in it.
Gleve
28 May 2013, 05:20Try this then. I thought I only kept one file...
Liam315
28 May 2013, 06:12OK, it's all fixed now, and I've added the addition to the put command so that only rubbish can go in the rubbish bin. You can select the command and scroll down to see what I've done and how I did it. You'll probably also want to change the print messages that I put in.
CORRECT VERSION IN MY POST BELOW.
CORRECT VERSION IN MY POST BELOW.
Sora574
28 May 2013, 06:26Liam, you removed an else {} script that needs to be there in the 'put' command
Without it, unless the second object has a delegate implementation, object 1 will always be put on/into object 2...
P.S. I feel like I'm being too hard on you all the time...
If I am, I'm sorry. If not, I'm sorry for being sorry
// else {
if (GetBoolean(object2, "hidechildren")) {
object2.hidechildren = false
}
if (HasDelegateImplementation(object2, "addscript")) {
rundelegate (object2, "addscript", object1)
}
else {
object1.parent = object2
msg (Template("Done"))
}
// }
Without it, unless the second object has a delegate implementation, object 1 will always be put on/into object 2...
P.S. I feel like I'm being too hard on you all the time...

Liam315
28 May 2013, 06:52Doh, it was the formatting of those lines that was causing the game to not load in the first place so I deleted those lines to get it open but forgot to put it back in correctly. I would say you were too hard on me, if it weren't for the fact that you keep picking up all the dumb mistakes I keep leaving in
Anyway, ignore the last one, here is the correct version of the game.

Anyway, ignore the last one, here is the correct version of the game.
Gleve
28 May 2013, 09:36so what did I actually break? Just so I don't do it again....
Gleve
28 May 2013, 09:49Liam315 wrote:haha, I'm more than happy to keep answering as many questions as you have. The more loop holes you consider and make scripts to take care of them, the better your game will be.
If you can post the description of the lounge room it would be easier to know how you should do it. The beauty of Quest is that is often more than one way to do something, depending on exactly what you want to accomplish.
I think want you want to do is add another condition using NOT in the expression. NOT is a recognised operator in expressions for the opposite of the condition you write. So if the lounge room has neither rubbish nor toys in it, you want to add another if condition like so:
if ((not toys.parent=loungeroom) and (not rubbish.parent=loungeroom)) {
msg ("The lounge room is clean and tidy.")
}
Using the .parent attribute is better than checking for the items in the inventory, because if the toys and rubbish just get dropped in another room (i.e. they aren't in the inventory any more) the lounge room will still display the clean message. There is a function that you can use if you ever do need to check the inventory though, called scopeinventory().
Do you mean you deleted the entire put command? Because if you save the game, close quest, then reload it, it should appear in the default list again when you check "show library elements" and you can copy and edit it again from scratch.
I can't get this code to work. Am I creating a new expression, below the current expressions?
Also, when I click on copy: code, and then paste in the expression bar, it only puts in the first line.
Liam315
28 May 2013, 11:34Code view is different from using expressions, copying and pasting that into the expression bar won't work.
Scrap what I said before, having seen your game I think I know what you mean now. You want to keep on adding "else if" scripts onto the room description. So as you would write it as an expression, you first need to change the message you currently have under the "else" heading and move it up to an if else.
else if [expression] (Rubbish.parent = Rubbish Bin) and (Toys.parent = Shelves)
then print message "It's so clean you're allowed to watch TV" etc.
Then under the "else" script you can have another message like "The toys/rubbish aren't in the room anymore but they're still not where they're supposed to be."
Your first if/else if scripts cover either or both the toys/rubbish being in the room. The else if written above basically says that the cleaning job won't be fully acknowledged until the rubbish is in the bin and the toys are on the shelf. The final else script needs a message that covers the toys not being in the room but not in the bin either.
Scrap what I said before, having seen your game I think I know what you mean now. You want to keep on adding "else if" scripts onto the room description. So as you would write it as an expression, you first need to change the message you currently have under the "else" heading and move it up to an if else.
else if [expression] (Rubbish.parent = Rubbish Bin) and (Toys.parent = Shelves)
then print message "It's so clean you're allowed to watch TV" etc.
Then under the "else" script you can have another message like "The toys/rubbish aren't in the room anymore but they're still not where they're supposed to be."
Your first if/else if scripts cover either or both the toys/rubbish being in the room. The else if written above basically says that the cleaning job won't be fully acknowledged until the rubbish is in the bin and the toys are on the shelf. The final else script needs a message that covers the toys not being in the room but not in the bin either.
Gleve
28 May 2013, 13:01Beauty, all done now, and looking much better.
The trick you said with have the program select the function, then switching it back to expression so as to see the code is brilliant, giving me good ideas as to where to go to next with this. Thank you all round, and as the problems keep arising, Ill keep asking!
The trick you said with have the program select the function, then switching it back to expression so as to see the code is brilliant, giving me good ideas as to where to go to next with this. Thank you all round, and as the problems keep arising, Ill keep asking!
Gleve
28 May 2013, 13:14Didn't take long did it?
The script is seeing the toys when they are in the shelves. Because the shelves are in the lounge room, when the script looks to see whether the toys are in the room, or on the player, it notices the toys on the shelves.
Can I make a script for the shelves which makes the item disappear? Because once the item is where it needs to go, I can just make some text to represent it, rather than an object.
The script is seeing the toys when they are in the shelves. Because the shelves are in the lounge room, when the script looks to see whether the toys are in the room, or on the player, it notices the toys on the shelves.
Can I make a script for the shelves which makes the item disappear? Because once the item is where it needs to go, I can just make some text to represent it, rather than an object.
Liam315
28 May 2013, 13:39There is a remove object script that you can call, you just need to add some additional "else if" scripts to the put command like you did with the rubbish.
However I'm not sure you should need to, when I tested the version of the game you posted, the different descriptions printed correctly when the toys were on the shelf. The lounge room shouldn't be able to see the toys if you're using the expression [object].parent. If you use the "if objects contains" option then the script can see all the child objects, but that's why I like to use the .parent attribute in these sorts of cases.
However I'm not sure you should need to, when I tested the version of the game you posted, the different descriptions printed correctly when the toys were on the shelf. The lounge room shouldn't be able to see the toys if you're using the expression [object].parent. If you use the "if objects contains" option then the script can see all the child objects, but that's why I like to use the .parent attribute in these sorts of cases.
Gleve
28 May 2013, 23:17(Rubbish.parent=Rubbish Bin) and (Toys.parent=Shelves)
Thats the expression Im using, but its still noticing the toys.
I looked at the shelves, and when I play the game, it shows me whats in the shelves without asking. I tried to alter some of the options there ( I went into the give command and added the script to remove item once it is given to the shelves) but that didn't help either.
Thats the expression Im using, but its still noticing the toys.
I looked at the shelves, and when I play the game, it shows me whats in the shelves without asking. I tried to alter some of the options there ( I went into the give command and added the script to remove item once it is given to the shelves) but that didn't help either.
Liam315
29 May 2013, 04:06Ohhhh, I understand, I thought you were talking about the actual description of the room (the room is tidy/the room is messy) rather than the description of the actual shelves.
Select the shelves and go to the container tab. Uncheck the box labelled (list contents when object is looked at or opened. That will stop the toys being displayed when you look at the shelves.
If you do that the toys are still there though and they can be picked up again, and will still be listed when you look at the room. To stop that happening you can use the following script. Again you need to place it in the Put command, but add the new script separately below everything else i.e. not an if else script. The [square brackets] denote each input box.
if [expression] object1=Toys and object2=shelves
-set a variable or attribute- [Toys.take] [False]
-set a variable or attribute- [Toys.scenery] [True]
-set a variable or attribute- [Toys.takemsg] ["The toys are tidied away on the shelves, best leave them there for now."]
Note the use of "quotation marks" for the last one, but not the first two.
The benefit of doing it this way is that the toys can still be examined, you can try and take them again even though the game will stop you etc. whereas deleting the object would get a nonsensical response (you can't see that) if you tried to look at them.
When you change the properties of objects in the GUI (writing descriptions, checking boxes etc.), all you are really doing is changing a specific attribute of that object. Therefore, with the "set a variable or attribute" script, you can change literally anything about an object during the game, they don't need to stay how they were originally set up. By looking at the attributes tab you can check what all these properties you are changing are called and get a feel for how to refer to them within the script using the expression syntax object.attribute.
I hope that makes some sort of sense.
Select the shelves and go to the container tab. Uncheck the box labelled (list contents when object is looked at or opened. That will stop the toys being displayed when you look at the shelves.
If you do that the toys are still there though and they can be picked up again, and will still be listed when you look at the room. To stop that happening you can use the following script. Again you need to place it in the Put command, but add the new script separately below everything else i.e. not an if else script. The [square brackets] denote each input box.
if [expression] object1=Toys and object2=shelves
-set a variable or attribute- [Toys.take] [False]
-set a variable or attribute- [Toys.scenery] [True]
-set a variable or attribute- [Toys.takemsg] ["The toys are tidied away on the shelves, best leave them there for now."]
Note the use of "quotation marks" for the last one, but not the first two.
The benefit of doing it this way is that the toys can still be examined, you can try and take them again even though the game will stop you etc. whereas deleting the object would get a nonsensical response (you can't see that) if you tried to look at them.
When you change the properties of objects in the GUI (writing descriptions, checking boxes etc.), all you are really doing is changing a specific attribute of that object. Therefore, with the "set a variable or attribute" script, you can change literally anything about an object during the game, they don't need to stay how they were originally set up. By looking at the attributes tab you can check what all these properties you are changing are called and get a feel for how to refer to them within the script using the expression syntax object.attribute.
I hope that makes some sort of sense.