Thanks for everything

I have some script that's giving me a bit of trouble though, and I was wondering if you could help me out please?
I have a script that asks you to collect ten coins and when you do it unlocks a door to the next part.
The trouble is when talking to the console the door is unlocked - even if you don't collect any coins.
I've tried placing the "trigger 23 1" in the npc1-4 but I cannot get it to work either way.
I know it's probably dead simple but it's really bugging me

Any help would be greatly appreciated.
Thanks for this.
Phantom_Spider
Code: Select all
coins = 0
level_trigger_2 = [
coins = (+ $coins 1)
echo "You picked up a coin!"
]
level_trigger_3 = [showgui npc1-1]
level_trigger_4 = [showgui Troll]
level_trigger_5 = [showgui Dragon]
level_trigger_6 = [showgui Secret_Room]
pickedcoins1 = 0
coinquests = 0
newgui npc1-1 [
if (= $pickedcoins1 2) [
guitext "Coins recieved! If you have" chat
guitext "forgotten where the room is; check the" chat
guitext "corner of the bathroom." chat
] [
guitext "Please insert 10 coins." chat
]
guibar
if (< $pickedcoins1 2) [
if (= $pickedcoins1 0) [
guibutton "What for?" "showgui npc1-2; pickedcoins1 = 1; coinquests = (+ $coinquests 1)" chat
] [
if (> $coins 9) [
guibutton "I've got the coins you wanted" [pickedcoins1 = 2; showgui npc1-4; trigger 23 1; coins = (- $coins 10)] chat
] [
guibutton "I've got the coins you wanted" [showgui npc1-3] chat
]
]
]
guibutton "Good bye" [echo "Castle Guide: Bye!"] chat
] "Castle Guide"
newgui npc1-2 [
guitext "I require 10 coins, if you get them for me" chat
guitext "I will tell you of the secret room." chat
guibar
guibutton "I'll go look for a few then, I'll be back soon" [echo "Castle Guide: Take your time!"] chat
] "Castle Guide"
newgui npc1-3 [
guitext (format "I require 10 coins, you only have %1." $coins) chat
guitext "Keep looking, they're hidden well." chat
guibar
guibutton (format "WTF! %1 more?" (- 10 $coins)) chat
] "Castle Guide"
newgui npc1-4 [
guitext "Coins recieved, the secret room" chat
guitext "is in the corner of the bathroom. Enjoy!" chat
guibar
guibutton "Great, thanks!" [echo "Castle Guide: No problem!"]
] "Castle Guide"
level_trigger_23 = [if (= $triggerstate -1) [echo "The door is locked"] [echo "The doors screeches violently as it flies open"]]