Uploaded game bugs

rosieclaverton
02 May 2014, 19:10
Hi all - sorry to trouble you again.

I tested my game on the desktop version and it seemed to be working very well.

However, now I've uploaded it, it's skipping some room descriptions, not executing some scripts at all, putting all my text in the wrong order. I'm not sure how to even start fixing it, as I didn't see these problems on the desktop. I suspect issues with my liberal use of SetTimeout, but I'm not sure.

http://textadventures.co.uk/games/view/ ... nline-game

I've attached the aslx (no walkthrough, as I couldn't figure out how to make it wait)

I'm trying to get this project finished on a very tight deadline and I've just come off a night shift, so that's adding to my confusion. Any and all help would be greatly appreciated.

jaynabonne
02 May 2014, 19:32
SetTimeout, timers, etc. are notorious for not working properly in the web player. There have been issues on the books about these for as long as I can remember.

rosieclaverton
02 May 2014, 20:32
Ah. :(

Is there anything I can use as alternatives? I'm mostly only using them to space out messages for realistic delays in response.

jaynabonne
02 May 2014, 21:35
I figured you might ask that... I have two thoughts.

First, I noticed that there are some places you have nested timeouts:

          SetTimeout (3) {
msg ("NEW MESSAGE FROM JASON")
msg ("Where is the ransom dropoff?")
SetTimeout (2) {
MoveObject (player, Map)
}

and some where you have concurrent, overlapping ones:

          SetTimeout (3) {
msg ("CONNECTED")
}
SetTimeout (4) {
msg ("DOWNLOADING...")
}
SetTimeout (6) {
msg ("DOWNLOAD COMPLETE")
MakeObjectVisible (Interview Transcript)
}

I could see the latter ones being more problematic. You could try making them all nested and see if that fixes the problem. (e.g. settimeout 3, then a nested settimeout 1, then a nested timeout 2). If they're serialized, they might work better.

The second try is a drop-in alternative to SetTimeout, something I just attempted to put together. It's a little bit hacky, but it seems to work. The only requirement is that you can only have one SetTimeout going at a time. This means you *must* nest your timeouts. You can't have (say) one for 3 seconds and one for 4 seconds going at the same time, as you do above. It only knows about the most recent one called.

Add this code to your game:

  <function name="TimeoutCallback" parameters="param">
invoke (game.timeoutscript)
</function>
<function name="SetTimeout" parameters="time, script">
game.timeoutscript = script
JS.eval ("setTimeout(function() { ASLEvent('TimeoutCallback', ''); }, " + time*1000 + ");")
</function>

Basically, this uses JavaScript to do the timeout. It has a TimeoutCallback ASLX function that is invoked by the JS once the timeout completes. This callback then invokes the script that was passed. As long as you nest your timeouts, it should work properly.

Let me know if this doesn't work, and we can possibly look at why. But I think it should. (I'd definitely try nesting my timeouts first, as it may solve the problem, and you have to in order to use my code anyway.)

Edit: Note also that ASLEvent causes turn scripts to run. So if you use the code I gave above, it will fire your turn scripts each time a timeout occurs. I don't see you using any, but I'm mentioning it in general anyway.

rosieclaverton
02 May 2014, 22:15
Thank you very much! I will definitely try nesting first and will let you know how I get on.

rosieclaverton
03 May 2014, 14:43
Nesting alone did not work, but your script is PERFECT! Thank you very much!

jaynabonne
03 May 2014, 15:24
Glad to hear. :) <Adds to bag of tricks.>