I need to create an array but need the index to change dynamically. so eg.
string[] sNPCNamesFoundArray
...
...
sNPCNamesFoundArray = new String [x]
...
where 'x' is needs to change based on other values within the game/script, but according to vanilla programing, it can't accept variables and needs a literal number.
but, skse has a way to do just that using this function:
"
String[] http://www.creationkit.com/index.php?title=CreateStringArray_-_Utility&action=edit&redlink=1(Int size, String fill = "")
- Creates and returns a String array with length size, with each element initialized to fill.
- Be careful when using this function. It is possible to create arrays longer than 128 elements, and size is treated as an unsigned integer. Negative numbers will produce extremely large values, which can cause major issues."
i just have no idea how to use that. If I could see a real use scenario script in how CreateStringArray works, then I can figure it out and incorporate it within my own scripts.
PS: the array will be used in a listbox, used from SkyUTil which lists npc's for the player to choose from. but that list changes all the time and i need the array to reflect the change. everything works so far, but when using literal values, the list also produces spaces in the list box because the array index is filled with blanks but contains no NPC names. the list doesn't care if there are no strings, it just cares about how long the index array total is. hence why i need an array to change the index on the fly if needed.
eg..currently, i have a space for an 80 index array.. that's the max, in the list box it'll show
[ NPC name ]
[ ]
[ ]
[ NPC name ]
..
etc.. till all 80 from the array are shown.
with a dynamic array, i can have the array size the same as however many npc's it finds. i'd check my other array, if an index is used, tick a counter on it, when a counter gets to the end, add it up, then create the new array using the counter number. done and done. would take me 2 seconds to do.
TLDR; http://www.creationkit.com/index.php?title=CreateStringArray_-_Utility&action=edit&redlink=1 , need to know how to use this function in psuedo script. please.
thanks,
CS - T-Mush-S