🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Script setting a callback.

Started by
1 comment, last by _Sigma 17 years, 2 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?
Advertisement
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.
Oh yeah...was thinking too complex! Thanks!

This topic is closed to new replies.

Advertisement