-
Notifications
You must be signed in to change notification settings - Fork 0
UpgradingTo271
AGS 2.71 adds new simple string support to the scripting language. Strings have long been a pain to use in AGS, but this is finally addressed by v2.71.
There's a new String type (that's a capital 'S'). These new strings
behave like Java/C#
strings in that you can easily assign to and
manipulate them.
For example, in 2.7 and previous versions, you had to do this:
string text;
StrCopy(text, "This is my text");
in 2.71, you can now do:
String text = "This is my text";
Furthermore, the == and != operators can be used to compare strings for equality (equivalent to using StrComp but much more intuitive). An additional benefit is that there is no longer a need for GetText() and SetText() methods -- instead, we can now just have Text properties.
All the old-style functions that took a "string buffer" parameter have now been replaced with new ones that return a string instead. Where properties have been created, you should be able to use them like any other property, so:
lblLabel.Text = "Hello";
String buttonValue = btnOK.Text;
and so on.
NOTE: Some of the new functions are provided on the Game object --
for example, the new GetSaveSlotDescription function needs to be called
like this:
String description = Game.GetSaveSlotDescription(10);
This is part of a move towards all built-in functions being
object-based, but watch out for it as it could well cause some
confusion. The manual will show you which functions require this.
Rather than using old functions like StrCat and StrContains, you now call the functions directly on the strings:
String text = "Hello";
text = text.Append("World");
will mean that text now contains "HelloWorld".
Note the text = in that expression. Functions like Append will
return a modified version of the string, they won't actually change the
original. Therefore, to update the text variable you need to assign
the result to it.
Backwards compatibility
In order to maintain backwards compatibility, a new "const" keyword has been added. This applies only to old-style strings, and allows them to interoperate with the new ones. A new-style String can be passed to a function that expects a "const string" (which means that it will not be allowed to change the string's contents), but cannot be passed to a function that expects a "string" (since it could overwrite the string data and mess things up).
So, you may find that any custom functions you have that take a string parameter stop working. If this is the case, change the parameter from "string" to "const string" and that should fix it.
Apologies for the inconvenience, but this is the only way to allow new Strings to interoperate safely with old-style strings.
Getting Started in AGS
Editor Reference
- Music and sound
- Distributing your game
- Backing up your game
- The text parser
- Translations
- Global variables
- Custom Properties
- Plugins
- Lip sync
- New Game templates
- Debugging features
- Auto-number speech files
- Integration with Windows
- Source Control integration
Engine
Scripting
- Scripting tutorial part 1
- Scripting tutorial part 2
- Pointers in AGS
- Calling global functions from local scripts
- The script header
- String formatting
- Multiple Scripts
- Understanding blocking scripts
- Dynamic Arrays
- Extender functions
- Game variables
- Predefined global script functions
- repeatedly_execute (_always)
- Custom dialog options rendering
- Built-in enumerated types
- Script language keywords
- AudioChannel functions and properties
- AudioClip functions and properties
- Character functions and properties
- DateTime functions and properties
- Dialog functions and properties
- DialogOptionsRenderingInfo functions and properties
- DrawingSurface functions and properties
- DynamicSprite functions and properties
- File functions and properties
- Game / Global functions
- GUI functions and properties
- GUI control functions and properties
- GUI Button functions and properties
- GUI InvWindow functions and properties
- GUI Label functions and properties
- GUI List Box functions and properties
- GUI Slider properties
- GUI Text Box functions and properties
- Hotspot functions and properties
- Inventory item functions and properties
- Maths functions and properties
- Mouse functions and properties
- Multimedia functions
- Object functions and properties
- Overlay functions and properties
- Palette functions
- Parser functions
- Region functions and properties
- Room functions
- Screen functions
- Speech functions and properties
- String functions
- System functions and properties
- Text display / Speech functions
- ViewFrame functions and properties
Working on Legacy games
Upgrading from a previous version
- Upgrading to AGS 2.7
- Upgrading to AGS 2.71
- Upgrading to AGS 3.0
- Upgrading to AGS 3.1
- Upgrading to AGS 3.2
- Upgrading to AGS 3.3
- Upgrading to AGS 3.3.5
- Upgrading to AGS 3.4
- Upgrading to AGS 3.4.1
Legal Notice
Getting in touch