Advertisement

Script setting a callback.

Started by April 20, 2007 12:58 AM
1 comment, last by _Sigma 17 years, 7 months ago
I've been looking thought the docs, but am unsure if what I would like to do is possible... I would like a script file something like below, where SetCallback sets a call back function in response to a specific keycode, but specifying what script fn to call.

callBack1()
{
//gets called on esc. key down
}

main()
{
//stuff

SetCallback(callBack1, VK_ESC)

//stuff

}

then in my main kerenel, have a std::map setup something like: +------------+----------+ | VK code | fn | +-----------------------+ | VK_ESC | callBack1| | ... | ... | +-----------------------+ so I can do:

//can't remember what VK's come as 
OnKeyDown(DWORD VK_CODE)
{
      keyMap.Get(VK_CODE).second(); //calls the callBack1 in the script file.
}

Can this be done with angle script?
Of course.

AngelScript doesn't yet support function pointers to AngelScript code, but the name of the function to call would work just as well.
Advertisement
Oh yeah...was thinking too complex! Thanks!

This topic is closed to new replies.

Advertisement