Please Help

Im increasing the weight of the player and i want objects to print different messages when player.weight is within certain weight ranges. Changing as more food has been eaten i.e more weight has been gained. Please give me the most simple answer possible

so I got the second option to be read but i have a third one and although the score was over 120 it still read the response for 110

I NEED PLAYER TO WEIGH OVER 120 and SAY "I can't believe Mom and Dad still havent noticed my gut, guess I'll just have to stuff myself even more!"

CURRENTLY (with this code) WHEN PLAYER WEIGHS 124 the game says "Crap! These pants must've shrunk in the wash."

if (player.weight = 110) {
msg (""Looking good, all that hard work at the gym really paid off."")
}
else if (player.weight > 110) {
msg (""Crap! These pants must've shrunk in the wash."")
}
else if (player.weight > 120) {
msg (""I can't believe Mom and Dad still havent noticed my gut, guess I'll just have to stuff myself even more!"")

You are really close, and the answer is more simple than you might imagine. The problem here is that whenever the player is over 120, it is also over 110, so it defaults to the first else if statement. Here is what you need to do to fix it:

if (player.weight = 110) {
msg (""Looking good, all that hard work at the gym really paid off."")
}
else if ((player.weight > 110) and (player.weight < 120)) {
msg (""Crap! These pants must've shrunk in the wash."")
}
else if ((player.weight = 120) or (player.weight > 120))  {
msg (""I can't believe Mom and Dad still havent noticed my gut, guess I'll just have to stuff myself even more!"")
}

Now, the limits for each else if statement are defined. The first else if would be read as, "Whenever the player is more than 110 units of weight, AND less than 120 units of weight, print a message (this is a range of 110 to 119)." The second one is read as, "Whenever the player is equal to 120 units of weight, OR they weigh more than 120 units of weight, print this message." Quest knows when to give up on the first and switch to the second. Hope this helps!


Or just change the order:

if (player.weight = 110) {
  msg (""Looking good, all that hard work at the gym really paid off."")
}
else if (player.weight > 120) {
   msg (""I can't believe Mom and Dad still havent noticed my gut, guess I'll just have to stuff myself even more!"")
}
else if (player.weight > 110) {
  msg (""Crap! These pants must've shrunk in the wash."")
}

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

Support

Forums