-
Notifications
You must be signed in to change notification settings - Fork 0
CustomProperties
What are custom properties?
Suppose you're making a LucasArts-style game, and you want all your hotspots to have a default event (so if the player right-clicks a window, for example, "Open" will be the default, but if they click on a pen, "Pick up" will be the default).
To do that, surely you would have to script in lots of code to change the default mode over each different object?
This is where Custom Properties come to the rescue. You can create a custom property for "Default event", for example, and then have some simple code in the global script to use the setting accordingly.
How do I use them?
You'll notice that characters, objects, hotspots, rooms and inventory items all have a "Properties" option in their property grids. Select it and click the "..." button.
Since you don't yet have any custom properties, you'll get a blank window, so click the "Edit Schema" button. This takes you to the Schema Editor, where you can create the various properties you want in your game. To begin with you are presented with an empty list box, so right-click in it and choose "Add property".
In the "Add Property" window you can set various options about the new property:
- Name - this is the name by which you will access the property from the script. This cannot be changed after the property has been created.
- Description - this is the user-friendly description which will be displayed in the custom property editor when you are setting the property.
- Type - this specifies what type of property you want. "Boolean" gives you a checkbox (which will return 0 or 1 to the script), "Number" gives you a text box which you can type numbers into, and "Text" gives you a larger text box which can store a string.
- Default value - this specifies what the default value of the property will be for objects where you have not set it specifically.
For example, add a new "Boolean" property. Close the schema editor, and then click the "Properties" button again. You'll now have a window with a checkbox with the description text you typed in. You can click the "Edit schema" button there to return to the schema editor if you like.
All types of game item share the same schema. That is, if you create a "Jibble" property in the schema editor for a hotspot, it will also appear in the properties window for characters, objects, and so on.
Getting and setting values in the script
To access the properties from the script, there are various script functions. See their descriptions for how they work:
Character.GetProperty
Character.GetTextProperty
Character.SetProperty
Character.SetTextProperty
Hotspot.GetProperty
Hotspot.GetTextProperty
Hotspot.SetProperty
Hotspot.SetTextProperty
InventoryItem.GetProperty
InventoryItem.GetTextProperty
InventoryItem.SetProperty
InventoryItem.SetTextProperty
Object.GetProperty
Object.GetTextProperty
Object.SetProperty
Object.SetTextProperty
Room.GetProperty
Room.GetTextProperty
Room.SetProperty
Room.SetTextProperty
NOTE: Calling ResetRoom will reset that room's properties to default values, as well as that room's hotspot and object properties.
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