🎉 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!

Context-specific global function or 'this' keyword?

Started by
0 comments, last by WitchLord 16 years, 3 months ago
I'd like to use AngelScript for GUI scripting like.. <form name="form1"> <button name="btn1" label="oldLabel" onclick='this.SetLabel("newLabel")'/> <label name="lb2" text="abc"/> <script> void onLoad() { FormScopeFunc(123); } </script> </form> there are two script code modules above, 1. attribute onclick 2. contents of <script> Anyway, I couldn't use 'this' keyword, maybe because it was not used in a class. It seems okay to omit "this.", so I want to register the script-specific functions: for example, SetLabel() is only valid in script 1 and FormScopeFunc() is valid in script 2. But the engine's Register~ method doesn't receive the 'module' parameter, it seems that all registering functions are global to all contexts. Is there any trick to solve the above problem? Thanks in advance.
Advertisement
You can use the dynamic configuration groups. See BeginConfigGroup and SetConfigGroupModuleAccess in asIScriptEngine.

This will allow you to register functions, types, and properties that are specific to individual modules.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement