Jump to content
  • Advertisement
Sign in to follow this  
_Sigma

Script setting a callback.

This topic is 4253 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!