-
Notifications
You must be signed in to change notification settings - Fork 9
GlobalArrays
There's a number of global arrays declared for you to access certain game objects. For historical reasons some of them have their length defined as a constant, others have their length provided as a property.
Array | Length | Description |
---|---|---|
Character character[] | Game.CharacterCount | All game's Characters |
Dialog dialog[] | Game.DialogCount | All game's dialogs |
GUI gui[] | Game.GUICount | All game's GUI |
InventoryItem inventory[] | Game.InventoryItemCount | All game's InventoryItems |
Hotspot hotspot[] | AGS_MAX_HOTSPOTS | Current room's Hotspots |
Object object[] | Room.ObjectCount | Current room's Room Objects |
Region region[] | AGS_MAX_REGIONS | Current room's Regions |
ColorType palette[] | PALETTE_SIZE | Game's palette, for 256-color mode |
Arrays that contain game objects contain them in the order of their respective ID. For example, if you have a character with the script name "cChar", then cChar.ID
would tell you the index at which this character is in the character
array. This may be useful if you have to store its numeric ID in an integer variable for later use and then find the Character by this number.
Abstract example:
int saved_id; ... saved_id = cChar.ID; ... Character* found_char = character[saved_id];
Naturally, when you know the array's size it's possible to iterate over it, for example when you want to perform an action on all of these objects, or when you want to find one of the objects in the game array by certain rules:
for (int i = 0; i < Game.CharacterCount; i++) { Character* c = character[i]; Display("Character number %d got name %s", i, c.Name); }
IMPORTANT: there is a known issue that if the game script mentions one of those arrays anywhere, then your game must have at least one object of that type. This is because AGS script cannot have zero-sized arrays and does not declare those that won't have any elements.
This is essential to remember if you're using a game template or script module that works with dialog[]
, gui[]
or inventory[]
arrays: to make your game compile in this case you have to create at least one dummy Dialog, GUI or Inventory item (even if you don't use it).
Getting Started in AGS
Editor
- New Game templates
- Editor Preferences
- General Settings
- Default Setup
- Colours Editor
- Room Editor
- Character Editor
- Cursor Editor
- Dialog Editor
- Font Preview
- GUI Editor
- Inventory Items Editor
- View Editor
- Sprite Manager
- Music and sound
- Voice speech
- Script Modules
- System limits
- Log Panel
- Plugins
- Other Features
Engine
Scripting
- Scripting Tutorial
- Scripting Language
-
Scripting API
- Script API Overview
- Standard Constants
- Standard Enumerated Types
- Standard Types
- Game variables
- Global arrays
- Global event handlers
- repeatedly_execute / repeatedly_execute_always
- Custom dialog options rendering
- Global functions: general
- Global functions: message display
- Global functions: multimedia actions
- Global functions: palette operations
- Global functions: room actions
- Global functions: screen effects
- Global functions: wait
- AudioChannel functions and properties
- AudioClip functions and properties
- Camera functions and properties
- Character functions and properties
- DateTime functions and properties
- Dialog functions and properties
- DialogOptionsRenderingInfo functions and properties
- Dictionary functions and properties
- DrawingSurface functions and properties
- DynamicSprite functions and properties
- File functions and properties
- Game functions and properties
- 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
- Object functions and properties
- Overlay functions and properties
- Parser functions
- Region functions and properties
- Room functions and properties
- Screen functions and properties
- Set functions and properties
- Speech functions and properties
- String functions
- System functions and properties
- TextWindowGUI functions and properties
- ViewFrame functions and properties
- Viewport functions and properties
- Obsolete Script API
- Event Types
- Key code table
- Audio in script
Legal Notice
Getting in touch
Misc