Skip to main content
GameDev.net gamedev.net
🔒 Locked

Properties in AngelScript

Started by RCL Sep 11, 2004 at 8:07 AM 1 replies 1.7k views
Original Post
RCL
RCL
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
WitchLord
WitchLord
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 - <a href="http://www.angelcode.com/tower" rel
Deyja
Deyja
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.