Difference between revisions of "PackArray"
Jump to navigation
Jump to search
imported>Speedo (New page: {{Beta}} A command for Pluggy. '''Syntax:''' PackArray ArrayID:long ''Global:short'' Removes all unused indexes from the array, and resizes the array to the count...) |
imported>Speedo (Added example) |
||
Line 1: | Line 1: | ||
{{Beta}} | {{Beta}} | ||
__NOTOC__ | |||
A command for [[:Category: Pluggy|Pluggy]]. | A command for [[:Category: Pluggy|Pluggy]]. | ||
Line 10: | Line 12: | ||
*Since the values in the array are moved to fill the gaps, any index from the array stored before the operation will become meaningless. | *Since the values in the array are moved to fill the gaps, any index from the array stored before the operation will become meaningless. | ||
*If you want to modify an array from another mod, you will need to set the Global flag to 1. If Global is 0 or unset the function will fail. If the array is protected the function will fail. | *If you want to modify an array from another mod, you will need to set the Global flag to 1. If Global is 0 or unset the function will fail. If the array is protected the function will fail. | ||
==Example:== | |||
If you have the following data in an array ''' ''myArray'' ''': | |||
{| border="2" cellpadding="5" cellspacing="0" | |||
|- | |||
!style="background:#ffdead;" |Index | |||
|style="background:#ffeded;" |Value | |||
|- | |||
!style="background:#ffdead;" |Index 0 | |||
|style="background:#ffeded;" |3 | |||
|- | |||
!style="background:#ffdead;" |Index 1 | |||
|style="background:#ffeded;" |10 | |||
|- | |||
!style="background:#ffdead;" |Index 2 | |||
|style="background:#ffeded;" |(empty) | |||
|- | |||
!style="background:#ffdead;" |Index 3 | |||
|style="background:#ffeded;" |8 | |||
|- | |||
!style="background:#ffdead;" |Index 4 | |||
|style="background:#ffeded;" |(empty) | |||
|- | |||
!style="background:#ffdead;" |Index 5 | |||
|style="background:#ffeded;" |(empty) | |||
|- | |||
!style="background:#ffdead;" |Index 6 | |||
|style="background:#ffeded;" |15 | |||
|} | |||
then | |||
PackArray myArray | |||
will modify the array to be the following: | |||
{| border="2" cellpadding="5" cellspacing="0" | |||
|- | |||
!style="background:#ffdead;" |Index | |||
|style="background:#ffeded;" |Value | |||
|- | |||
!style="background:#ffdead;" |Index 0 | |||
|style="background:#ffeded;" |3 | |||
|- | |||
!style="background:#ffdead;" |Index 1 | |||
|style="background:#ffeded;" |10 | |||
|- | |||
!style="background:#ffdead;" |Index 2 | |||
|style="background:#ffeded;" |8 | |||
|- | |||
!style="background:#ffdead;" |Index 3 | |||
|style="background:#ffeded;" |15 | |||
|} | |||
[[Category: Functions (Pluggy)]] | [[Category: Functions (Pluggy)]] | ||
[[Category: Array Functions (Pluggy)]] | [[Category: Array Functions (Pluggy)]] |
Revision as of 21:25, 26 February 2008
Beta Function
This function has not been fully tested yet, and is not ready to be used in a released mod. It may not have the same function in later versions, may require the script to be recompiled, or simply may be removed. Use for testing purposes only until the author of the function says otherwise.
A command for Pluggy.
Syntax:
PackArray ArrayID:long Global:short
Removes all unused indexes from the array, and resizes the array to the count of filled indexes.
- Since the values in the array are moved to fill the gaps, any index from the array stored before the operation will become meaningless.
- If you want to modify an array from another mod, you will need to set the Global flag to 1. If Global is 0 or unset the function will fail. If the array is protected the function will fail.
Example:
If you have the following data in an array myArray :
Index | Value |
---|---|
Index 0 | 3 |
Index 1 | 10 |
Index 2 | (empty) |
Index 3 | 8 |
Index 4 | (empty) |
Index 5 | (empty) |
Index 6 | 15 |
then
PackArray myArray
will modify the array to be the following:
Index | Value |
---|---|
Index 0 | 3 |
Index 1 | 10 |
Index 2 | 8 |
Index 3 | 15 |