Counting the number of items worn, and printing a message when the required number is reached

Mikemuk01
16 Nov 2017, 14:32Hi - please help a newbie with his first game. I want my player to find and wear 5 separate items of clothing before being allowed into one of the rooms in my game. The items could be found in any order. I thought I could maybe define a variable kit=0 at the start of the game (? Where?) then put kit=kit+1 each time an item is found and worn, with if kit=5 print message each time. But I can’t find where to put these commands or how to word the instruction. Can anyone help please?
The Pixie
16 Nov 2017, 14:44The best way to do something like this is to set up a script on the exit itself that tests if the condition has been met, and allows the player though if so.
Go to the exit, and tick the "Run Script" checkbox. A place to edit a script will appear. Click the "Code view" button (just below it on the on-line version, just above for the desktop version), and paste this in:
if (WornCount() >= 5) {
player.parent = this.to
}
else {
msg("You cannot go that way so under-dressed.")
}
Be aware that if the player goes through, drops a garment, then comes back, she may get stuck unable to go back through. To prevent that, you this script instead, which will allow the player to use the exit any time as long as she has gone through it the first time:
if (WornCount() >= 5) {
this.triggered = true
}
if (GetBoolean (this, "triggered")) {
player.parent = this.to
}
else {
msg("You cannot go that way so under-dressed.")
}

Mikemuk01
16 Nov 2017, 15:58Thank you Pixie. What will I put when each garment is put on, to register the number worn? Will I need to declare variable WornCount at the start of the game, and if so where does it go?
The Pixie
16 Nov 2017, 16:01Nothing. It will just count the number of garments worn when the player tries to open the door (Quest will set "worn" to true for each item when it is put on, and use that in the WornCount
function, but that all happens behind the scenes).

Mikemuk01
16 Nov 2017, 16:54I’m sorry to be a bit slow. I need my player to try to go ‘in’ from the woods to the laboratory. When I open the woods pages and go to the exits tab there is an exit ‘in’ marked laboratory but I can’t see a ‘run script’ checkbox. Am I looking in the wrong place?

Mikemuk01
16 Nov 2017, 17:44Pixie I’ve found it. Thanks a lot