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

Calling script functions from other scripts...

Started by
0 comments, last by WitchLord 18 years, 7 months ago
Hi all!, I've just started using Angelscript and i must say i like it a lot. But I've got a question: Is is possible to have one function in one script (script1.as) call a registered function in the application that calls another function in another script (script2.as)? The reason for me asking is the following: I have a factory class in my application that is responsible for creating objects from different classes. Each class also has a "setup script" that is to be called each time an object is creted. Now, the user can pass a "application setup script" to the application. This script will then call a function in the factory class to create different objects. In short: The "application setup script" will make a number of calls to the factory class to create a number of objects. Each created object will then call it's own script to set up internal variables. How would I go about to implement this? Do I need to suspend the "application setup script" while each separate object runs it's internal script? And if I do, must I reload, recompile the "application setup script"? I know there is a "suspend()" function a context. But is there a corresponding "resume()" function? I hope I made some sence with my question... Best Regards, Risto
Advertisement
Yes, it is possible to call another script function from an application function called from a script. You just need to create another script context, or call ExecuteString() if that is sufficient for you. The script functions will not share call stacks, but if they are from the same script modules the global variables are shared.

The Suspend() method makes the Execute() call return at the earliest possible moment. To resume the execution simply call Execute() again (without first calling Prepare()). But for what you want to do, there is no need to first suspend the 'application setup script'.

Regards,
Andreas

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