A puzzle with Random item combinations - Paint Mixing
matsumoto
23 Jan 2017, 18:40Hello!
I'm new to Quest and as a way of practicing with random elements in puzzles, I've decided to try and make a puzzle that requires two out of three possible items that the player should collect, let's say these items are Yellow, Red and Blue paints and the player has to use them up at a bucket to make the color that the puzzle asks, say Green (Y+B) or Purple (R+B).
So, the game should "pick" at random one of the goals and the player would need to mix either the Yellow + Blue paints, to create Green, or Red + Blue paints to create Purple.
I tried using something like the if
and the randomchance(50)
scripts to pick a random result between Green and Purple, but I think I am failing at setting a variable that can actually use these results so I can put it in the puzzle, I had this run at the start of the game:
if (RandomChance(50)) {
Paint = "Purple"
}
else {
Paint = "Green"
}
Ah, I also need to create a note or something that can be used as a hint for the player with the same result, but I couldn't make a note that used this result.
Suggestions on how should I achieve this, please? :)

TinFoilMkIV
23 Jan 2017, 19:57The first issue is that your variable 'Paint' doesn't exist outside your script. It's like writing notes on a piece of scrap paper that gets thrown away after the code finishes, you can use it during that code but afterwards it's gone. What you want to do is store your 'Paint' variable inside an object ie:
if (RandomChance(50)) {
game.Paint = "Purple"
}
else {
game.Paint = "Green"
}
the 'game.' portion says that the varaible 'paint' belongs to the game object, which can be replaced with whatever you want to store it in ie: puzzle.Paint
You can then pull the results to use in both the puzzle and note by referencing 'game.Paint' in any other scripts.
hegemonkhan
23 Jan 2017, 21:57and for the hint msg'ing:
if (RandomChance(50)) {
game.Paint = "Purple"
msg ("YOUR_HINT_FOR_PURPLE")
}
else {
game.Paint = "Green"
msg ("YOUR_HINT_FOR_GREEN")
}
// or, where-ever/when-ever, you need it:
if (game.Paint = "Green") {
msg ("YOUR_HINT_FOR_GREEN")
}
else if (game.Paint = "Purple") {
msg ("YOUR_HINT_FOR_PURPLE")
}

Hambo325
23 Jan 2017, 22:00I need help too but I don't know how to go about it

Hambo325
23 Jan 2017, 22:01nvr mind I posted a new post XD sorry
hegemonkhan
23 Jan 2017, 22:51here's some helpful guides/links:
http://docs.textadventures.co.uk/quest/guides/
and this specifically really helps learning these important things:
http://docs.textadventures.co.uk/quest/guides/character_creation.html