List Library

Passing multiple integers to a function is something I needed to do, so came up with the simple library in the attached map in a few minutes' time.

Technically, the editor and galaxy language don't allow us to pass arrays to functions. Strings are arrays however, and as such can substitute as arrays. We have very limited functionality dealing with strings, but basic storage can be done easily, if inefficiently.

If we had more powerful tools, a better solution could be created... we could even create our own dynamic allocation system using strings as a memory space. There doesn't appear to be a way to access characters of a string by index however, nor are there atoi or itoa functions, nor even a logarithm function to easily get the position of values in an integer, and implicit casting is disallowed. I was attempting to create a system where the integers would be converted into byte values with an ascii character representation, but got frustrated with the roadblocks of the galaxy language, so stuck with this. The list isn't something I use often or store large values in, so simply converting integers to strings is good enough for my purposes.

The functions here can also be easily extended to use floating point values or other numbers as well, if you need to do that. Any sort of lists involving spaces (such as unit names) will need a different solution for storage however.

I've also included some examples in the map using the functions.

Note: The import/export library functions of the editor are broken, so copy-paste the functions from the example map after you import/export the library. Hint and grammar text are wiped out when you use import.

Hope this is useful for you. If you have any questions, just send me a private message.




Example use of functions:

Test
    Events
        Timer - Elapsed time is 0.25 Game Time seconds
    Local Variables
        Test List <Integer List>
    Actions
        Variable - Set Test List = ((1), (2), (3))
        List - Do stuff with list (Test List)
        Variable - Set Test List = ((0), Test List)
        Variable - Set Test List = (Test List, (4))
        List - Do stuff with list (Test List)
        UI - Display (Text(Test List)) for (All players) to Debug area


Do Stuff with List
    Options: Action
    Parameters
        List <Integer List>
    Local Variables
        Index = 1 <Integer>
    Actions
        General - For each integer Index from 1 to (Size of List) with increment 1, do (Actions)
            Actions
                UI - Display (Text(List[Index])) for (All players) to Debug area

Comments

Posts Quoted:
Reply
Clear All Quotes

About This Project

  • Project ID
    23646
  • Created
    May 20, 2010
  • Last Released File
    May 20, 2010
  • Total Downloads
    420
  • License

Categories

Members

Recent Files