Array Element Zero

TURBU

Array Element Zero

 

Due to the nature of Object Pascal, all dynamic arrays (arrays whose range is not determined before the program runs) start at element #0, not element #1.  Actual objects used in-game start at #1, in keeping with the RPG Maker database arrangement.  The RPG Script system reserves element 0 of each array as a "junkyard," redirecting invalid values to it.  For example, if there were only seven heroes defined in the database, the line hero[9].equip(10); would instead equip hero[0].  This helps keep the script engine from bailing out or causing a system error.

Warning:  Unlike objects defined from the database, element 0 objects are not guaranteed to be stable, and the values of their variables are not clearly defined at any given moment.  Clever programmers could use element 0 for their own purposes, but they do so at their own risk.  Accessing element 0 has the potential to cause unforseen consequences, especially if it is done unintentionally.  In the example given above, the equip routine would still work properly, including removing the equipment item from the inventory, but the item would be equipped to hero # 0, not to anyone defined in the database.  This could make the item appear to have vanished if the programmer is not aware of this behavior.

 

RPG Script Reference

This help file was created with the free trial version of HelpScribble.