Attempt at a timer

I'm trying to create a situation in which a player can put an egg in an incubator and, a few minutes later, the egg will hatch. Someone in this forum has suggested creating a timer by playing a silent sound file and checking "Wait for sound to finish before continuing." I've tried this, in the Use/Give tab for the incubator. Currently, when I put the egg in the incubator, an initial sound plays, no message is displayed, and the entire game freezes. Help?

Here's my script (with notes added):

msg ("The mottled brown egg now sits snugly in the incubator, warm and safe.") --This is not displaying.--
PrintCentered ("10 points!")--This is not displaying.--
IncreaseScore (10)--This is not happening.--
play sound ("273570__n-audioman__coin000.wav", true, false)--This IS playing.--
play sound ("silence.mp3", true, false)
play sound ("egg cracking.wav", false, false)
PrintCentered ("The mottled brown egg is starting to hatch!")--This is not displaying.--
RemoveObject (mottled brown egg)
MakeObjectVisible (hatchling dragon)


I've not played around with sounds much, but it sounds like there might be some issue with playing multiple sounds at once; maybe it doesn't know which one to wait for?

Is there some reason you're using a silent sound like this, rather than just using a timer?


There is a demo here somewhere that shows the use of a timer...
I don't recall where it is.


Can’t you just create a three minute timer at which at the end of it just hatch the egg? Why mess with sounds? If the error you’re getting is because you have two sounds at once... yikes. I’ve messed with that and it’s NOT fun.

I’ll put together a sample test if you want. Let me know.


I think this is the demo that DarkLizard is referring to; not sure who posted it up originally as the link I've got is broken.

There used to be a TV program called the Crystal Maze where a team had to recover crystals from different rooms by doing certain challenges. Each person had to do a challenge and the difficult bit was that they only had 5 minutes to do it before the room was locked.
Important note: in Quest 5.3 the object ‘player’ is replaced with ‘game.pov’ so if you are working with Q 5.3 or higher replace ‘player’ with ‘game.pov’
	1. I have set up two rooms in Quest. One room is called Dungeon where the challenge is set.
In the room are lots of different objects:
	1. The first thing I need to do is make a Countdown variable and set it to the time I need
	2. I highlight the player and go to Attributes and click the Add symbol.
	3. I give the Attribute a single word name eg: countdown (CASE SENTITIVE!)
	4. When I click OK it appears at the bottom:
	5. I now need to give the countdown variable a value.
	6. I click on the String drop down box and choose Integer and type the number of seconds I want the clock to run for in the box:
	7. When you click off you see that the attribute now says 30 next to it:
	8. Now I need to add a label so the value appears when you play.
	9. I go up to status attributes and click the Add button and type in the name of the attribute: (CASE SENTITIVE!)
	10. When I click OK I am asked for a Format string. You can leave this blank and the computer will put in countdown: 30
	11. If you want to have a different value, type in the words you want and put a ! where the seconds will go eg
	12. This would look like this when the game runs:
	13. When you click OK you will see the different attributes:
	14. The next step is to add the Timer
	15. I do this by going to Add > Timer and giving it a name:
	16. Next I need to tell the computer to start on 30s and countdown in steps of 1.
	17. I do this by clicking on Script typing in variable and choosing Set a variable or attribute:
	18. I double click on the script to choose it and it looks like this:
	19. I now CAREFULLY type in the name of my variable – player.countdown (Q5.3: game.pov.countdown)
	20. In the expression box I type in the same variable but then with MINUS 1 eg player.countdown -1 (Q5.3: game.pov.countdown -1)
	21. This basically tells the counter to countdown from 30 it steps of 1
	22. Now I add in another script using IF to say what happens if the counter gets to 0
	23. Next we need to tell the computer to start the timer when we go into the Dungeon.
	24. Click on Dungeon then Scripts and find the After entering room section.
	25. Add a script and search for Enable. Enable Timer1 to start:
	26. Next we need to tell the computer to stop the time when the Dungeon.
	27. Click in the Dungeon room and select scripts.
	28. Find the After leaving room section and make up these scripts:
	29. This tells the computer to stop the timer running, write a message and then “reset” it back to 30 when you leave the Dungeon
	30. Run the game. When you go into the room, the timer starts automatically:
	31. Here is the timer counting down some more
	32. Here is the game finished when I did not get out in time
	33. Here is when I get out of the room and go back to the other room – the timer resets to 30s
	34. If you wanted the timer on for the entire game you would go back to the timer and tick the start timer when game begins box
I AM SURE THERE ARE LOTS OF OTHER THINGS YOU CAN DO WITH THIS CODE!

From <http://docs.textadventures.co.uk/quest/guides/hs_countdown.html> 

Sounds and timers are full of potential pitfalls, as you have discovered. I'm assuming that you have NOT put a timer in the same section of code, but just the sounds.

What doesn't make sense is that your print messages don't even display before the sounds are played. To rule one thing out -- your code doesn't, by chance, involve clicking on a showmenu item, and then having the sounds play? There is a known issue with such a scenario, wherein there may be a one-turn delay in processing the rest of the turn.

Otherwise, it sounds like something is happening BEFORE that section of code that is conflicting with those sounds.


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

Support

Forums