new functions

Pertex
10 Jan 2012, 21:10
Hi Alex,
with 5.1 "new" functions like ask, wait or show menu are coming. The old ask and ShowMenu functions are deprecated, what about WaitForKeyPress? Must /should I replace these functions?

Alex
11 Jan 2012, 08:54
You don't have to replace the functions, unless you want your game to be converted into an app at some point. (The reason I had to deprecate the old functions and introduce new ones was that in Javascript you can't have threads - meaning that asking a question, waiting for a keypress or showing a menu can't pause a script while waiting for user input.)

WaitForKeyPress is also deprecated (just updated the wiki to mention this) - you should use the "wait" script command instead.

Pertex
11 Jan 2012, 09:44
So you can't/shouldn't do something like this?


for (x,0,2) {
ask (StringDictionaryItem (game.test, tostring(x) ) ) {
msg(result)
}
}


By the way, such a function kills Q5

Alex
11 Jan 2012, 10:44
You shouldn't do that because the "ask" script command will not suspend the thread. The script keeps running after the "ask" command, so your loop will trigger three "ask" commands simultaneously.

Looks like I will need to raise an exception if asking more than one question at a time - that will at least stop Quest from crashing.

Pertex
12 Jan 2012, 11:00
But is the GetInput function ok then?

Alex
12 Jan 2012, 16:35
You're right - that will need to be deprecated too, as it also pauses the thread.

But at the moment it's not deprecated as it doesn't have a replacement! (I didn't need to implement one for the Bump app)