Script overrides unlock script.

I have a locked exit, named Had. I have a script that is done if the player tries to use the exit.
This is the script:

if (game.pokemonget = false) {
  msg ("No wait, I was supposed to follow Silver to the lake...")
}
else {
  if (Had.locked = true) {
    msg ("No wait, I was supposed to follow the others to the lab...")
  }

I have another script that unlocks the exit when the player goes to the lab. But the message script is overriding the unlock script. It's not unlocking. So far, I turned off the run script option and went back to showing a message. I don't know how to fix this. Help?

Game link. http://textadventures.co.uk/games/view/5jllte-m4e2e2whw4gf5jq/pokemon-type-harley-johto-and-sinnoh


Your exit script won't run if Had is locked. You have to unlock the exit first, then go through the exit and the exit script should work.


Dcoder, do you mean at the start of the game? I already have a code for unlocking the exit. That's why printing a message works but this code doesn't.


Where did you put the unlocking script?


The Lab. After Gold gets a Pokemon, he goes to the lab. A message plays, and then the exit should unlock.

After entering room,

if (game.pokemonget = true) {
  firsttime {
    if (Professor Elm.parent = The Lab) {
      msg ("Professor Elms speaks \"Here are some Oran berries and a few pokeballs.\" Professor Elm gives 5 Oran berries and 5 pokeballs to you and Silver, each. ")
      player.potion = player.potion + 5
      player.pokeballs = player.pokeballs + 5
      msg ("Professor Elm takes in a deep breath. His eyes take on a much more serious and experienced look. He looks like he's about to say something very hard, but important.<br/>\"I''m going to tell you about the world, and why it is the way it is. Most parents don't talk to their kids about this, sad to say, so I'm going to do it. 5000 years ago, the Big Catastrophe happened. Yellowstone erupted. As a result, the world changed. The climate grew hard. Earthquakes. Floods. Lava flows. Ash. Hail. Half the land fell into the sea, and it was replaced by new land. Half of all life died. Food became scarce. Pokemon ate humans! Humans ate Pokemon! Pokemon ate Pokemon! Humans ate humans! Humans were forced to enslave Pokemon to conquer the elements, and they made civilization. Some people views Pokemon as friends, some view them as pets, but across the world, people view them simply as feral Pokemon, needing to be controlled. People became greedy. They used their ideals and their Pokemon, and they made war with each other. Everyone's hearts hardened. I do not want your hearts to harden, as mine has, if they have not hardened already. I wish I could help you more, but I did all I can. You both will have to depend on yourselves, now.\"")
      UnlockExit (Had)
    }
    SetTimeout (1) {
      msg ("Your journey begins!")
    }
  }
}
else {
  msg ("Professsor Elm is gone. His assistants are too busy to talk at the moment.")
}

So you're sure that Had is unlocked when the player tries to use the exit? You can use the Debugger tool in-game to confirm this -- under the Exits tab in Debugger, Had.locked should change from True to False.

If Had is unlocked, what happens when the player uses the exit? Make sure in your exit script that you actually have code that moves the player from one room to another, since you have to manually code this in now. You can put in your exit script:

MoveObject (game.pov, Had.to)

Another thing, this part of your exit script is superfluous:

else {
  if (Had.locked = true) {
    msg ("No wait, I was supposed to follow the others to the lab...")
  }

...since this part will never run if Had.locked = True (the "Print message when locked:" message will display instead). So you can delete that part of your exit script.


@dcoder No, I don't know if it unlocks. Also, I'm not sure why you would have to move the player to the exit. Seems redundant.


Nevermind, I figured it out. I turned the other else into an else if, and I put MoveObject (player, Had.to) into the new else. Thank you anyways.


Glad it works!


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

Support

Forums