Properties in AngelScript

Started by
1 comment, last by Deyja 19 years, 7 months ago
Hi, I think it would be great if AngelScript supported properties (a kind of variables, which are accessed via pair of Get/Set functions). The actual variable may not even exist at all. Consider the following example: Let's say we have an in-game console and player has a [limited] access to internal game variables. Wouldn't it be nicer to let him type like: [CONSOLE] game.maxPlayers 32 when he wants to set the max number of players instead of clumsy [CONSOLE] game.SetMaxPlayers( 32 ) ? Of course it is possible to export variable maxPlayers through RegisterObjectProperty(), but what if this variable is not allowed to be changed at any time (and/or some action is required to be taken upon its change)? Cheers, RCL
Advertisement
I recognize the usefulness of properties that are accessed with hidden functions. Thanks, I'll add your suggestion to the to-do list.

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

You could use a class type with an assignment operator to emulate the setting behavior. Catching gets is more difficult. I'd do it in C++ with a copy constructor. The copy is 'getting' the value of the source. Whenever you pass by value the copy constructor is called. SomeClass.Member won't call it, but as soon as you try and store it or use it in any way, it will be called.

This topic is closed to new replies.

Advertisement