Setting flags and making something happen.

The tutorial was not very clear on what a flag is exactly or how to create one. Right now I'm trying to figure out how to change an object's description after I give it an object from my inventory. I'm sure it involves an "if" script and setting a flag, but I don't know how. If it's hard to do with the interface, I just might not bother.


Actually, it is very simple. I do not have the Quest installed right now to make a step by step for you, but I'll do my best from the top of my head, because I did it in past once.

My intention was having a character that, during the game, had a description and after the player finding a secret, had a different description.

I created the "Object", which was the NPC and filled it up with all the stuff I needed. Then, I went to the NPC's attributes and creted a new attribute which was a boolean, what means, a flag. A boolean or flag is a variable with only two states: True or False. I set it to false.

During the game, when the player finds the secret, the game runs the command 'set flag', name of the flag, then to "true". In code it would be something like 'npc_name.secret = true', but if yu are not writing code, the GUI already has this command in the variables section. I decided doing this for a matter of organization, but you can actually use this "set flag" command on the fly, creating it as "true" at the moment the player fnds the secret.

Now, comes one of th best features in Quest, in my opinion. You may use the text processor to do script things for you. So, the NPCs description had two different descriptions: One for the {IF npc_name.secret = false: Show the regular description}. The other was {IF npc_name.secret=true: Show the secret description}. Every time the player used the "Look at" command on the NPC, the game checked if the secret was true or false, delivering the adequate description in game.


I don't think you exactly explained each step. I added a new attribute and called it ball. Then made it boolean and set it to false. In the look at description for the object I want to give ball to, I have it to run script. The plan is if ball has not been given then show a picture and a description. Then give the object a ball taken from elsewhere in the room and is in your inventory, which shows text acknowledging the ball has been taken and removed from inventory. After that, I want it so if you look at the object again a different picture is shown along with text. What do after setting boolean attribute to false?


Ok. The thing is a little more complex than just a simple description, so the text will not gi fine.

What you need doing is: when player uses the "Look at" button, the game checks IF object.ball is true. If so, show the picture A and display text. Else, show picture B and display other text.


Should I name the flag or not? Because I'm starting to think doing so might be tripping something up.


You have to. Quest is Object Oriented, so the flag must be something belonging to someone. That's what the dot means like player.score. The object is the 'player', who owns a variable named 'score'. I'm not sure, but I think in Quest, if you don't use this format, the program assumes the object is 'game', so while in practice you just use the name of the variable, for the game it means 'game.flag'. But I'm not sure.

If you make by GUI, setting a name for the flag will bind it to the object it asks when you use the 'set flag'. If you do it by coding, you have to say object.flag. If you go stright into the object to set the flag, well... the object is the one getting the flag.


If you still having troubles, use the set flag in the begining of the game.
Then take the object with the changing description and run the scrip with that conditional.
These steps will work.


Never mind me now. Turns out what I needed to do was set the flag in the object's give (other object) to this. Then have the second image I wanted shown as the first thing in an if command if the object is looked at. After which I had to add an else command below which would have the first image I wanted shown second. Sounds a bit wonky, but at least it works and that's what matters. This can officially be labeled resolved.


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

Support

Forums