🎉 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 var byref

Started by
5 comments, last by WitchLord 19 years, 8 months ago
hi Is it correct that you can't define variables as references in a script function? i'd like to do the following:

// script
void changeMaterial(IEntity* e, UserData* ud)
{
  Material& mat=e->getGraphicObject(0)->getMaterial(0);
  // ...
}
the script compilation bails out when it comes to the assignment of the material. I changed my code to return a pointer to a material and this works without any problem. So I just want to make sure this is an unsupported feature :) Cheers Tom
Advertisement
Yes, references are only supported in the function parameters. I may change this in the future though, at least for objects, as I want to remove pointers altogether.

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

Please don't. Further support for references is great. But pointers have their use too.
Sorry, I need to reformulate that. I want to remove pointers as they do in fact complicate matters, but of course I can't do that until I've found a replacement that works equally well (which probably means never).

However I have recently found myself thinking of branching the project and making a separate library that doesn't even have pointers. It would then work more like Java where all objects are handled with references. The application would still be able to pass a pointer to the scripting engine of course.

These thoughts are still very immature though and it's nothing that's going to happen this year at least.

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

Thanks.
How about implicitly converting pointers to refferences and back? Internally, pointers and refferences are treated the same way. It's only when accessing members that there's a difference. (refferences are like regular variables, pointers use derefferencing). This would pretty much instantly remove the need for pointers
That would be a possibility. I need to look into it further to make sure that it is safe to do it.

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