User Tag List

Results 1 to 10 of 10

Thread: Arrays of Arrays

  1. #1
    Keese Just registered
    Join Date
    Jan 2018
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    309
    Level
    6
    vBActivity - Bars
    Lv. Percent
    44.52%

    Arrays of Arrays

    Code:
    I would really, really like to see some double array int variables.
    Something like this: 
    
    
    //A variable int that is an array of several other arrays.
    int ComboData[128][176];
    //initialize all variables
    for(int screen=0;screen<=127;screen++)
    	{
    	for(int comboposition=0;comboposition<=175;comboposition++)
    		{
    		ComboData[screen][comboposition];
    		}
    	}
    void SaveMapComboData()
    for(int screen=0;screen<=127;screen++)
    	{	
    	for(int comboposition=0;comboposition<=175;comboposition++)
    		{
    		for(int x=0;x<=256;x+=16)//skips every 16 pixels
    			{
    			for(int y=0;y<=176;y+=16)//skips every 16 pixels
    				{
    				ComboData[screen][comboposition]=Game->GetComboData(Game->GetCurMap(),screen,comboposition);
    				}
    			}
    		}
    	}
    //then afterwards
    void WriteMapComboData()
    for(int screen=0;screen<=127;screen++)
    	{	
    	for(int comboposition=0;comboposition<=175;comboposition++)
    		{
    		for(int x=0;x<=256;x+=16)//skips every 16 pixels
    			{
    			for(int y=0;y<=176;y+=16)//skips every 16 pixels
    				{
    				ComboData[screen][comboposition]=Game->SetComboData(Game->GetCurMap(),screen,comboposition,ComboData[screen][comboposition]);
    				}
    			}
    		}
    	}
    Last edited by Chris Miller; 03-30-2018 at 10:52 AM. Reason: yikes

  2. #2
    How many licks to get to the center Chris Miller's Avatar
    Join Date
    Mar 2001
    Location
    of a Tootsie Roll Pop?
    Age
    46
    Posts
    3,510
    Mentioned
    94 Post(s)
    Tagged
    4 Thread(s)
    vBActivity - Stats
    Points
    5,662
    Level
    23
    vBActivity - Bars
    Lv. Percent
    37.91%
    FTFY.

    To answer your question about the Edit button, look toward the bottom-right of your post.

    Download Lands of Serenity today! You will be knocked comatose by its sheer awesomeness.
    The Titan's Quest, best played in the bathroom as the excitement can be somewhat...overwhelming.





    Official AGN Discord Channel

    Official ZC Dev Discord Channel

  3. #3
    The Timelord
    QDB Manager
    ZC Developer

    Join Date
    Oct 2006
    Location
    Prydon Academy
    Posts
    1,396
    Mentioned
    112 Post(s)
    Tagged
    1 Thread(s)
    vBActivity - Stats
    Points
    4,760
    Level
    21
    vBActivity - Bars
    Lv. Percent
    68.7%
    What you want, is '2D' array. It's not coming anytime soon, sorry.

    I advise against using 'ComboData' as an identifier. That's a pointer, in the alphas of 2.54.

    Other than those points, the for loops in your functions seem extraneous: +16 pixels isn't needed when you are using combo positions. In fact, your function calls are wrong, too, as you're calling a setter, but expecting a return.

    Thankfully, the actual combodata datatype, and the mapdata datatype, make it much easier to do what it looks like you are trying to accomplish.

  4. #4
    Keese Just registered
    Join Date
    Jan 2018
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    309
    Level
    6
    vBActivity - Bars
    Lv. Percent
    44.52%
    Calling a setter? That's not what happened.
    I already compensated and shortened the script with a combo position for instead of writing a comboat(x,y) and shortened it into a 0-175 for instead.
    Then I went and wrote out hundreds of lines of code to save the data and set it back at the push of a button in the same similar fashion as I wrote out in my example code for a hypothetical situation and got the results I was looking for which in no way "called a setter" but instead saved the combo data of every combo on an entire map by equating their values to a combo number on an array just as I described.
    The only difference is that I had to manually write an array for every individual screen instead of an array that accesses other arrays as I had suggested for a future release.
    I did this because the maps indices are limited to the point of 256 total maps, whereas writing all combo data to a series of arrays bypasses that limitation.
    Also, I didn't call setters and expecting a return, those lines of code would in fact write to an array, not return anything.

  5. #5
    The Timelord
    QDB Manager
    ZC Developer

    Join Date
    Oct 2006
    Location
    Prydon Academy
    Posts
    1,396
    Mentioned
    112 Post(s)
    Tagged
    1 Thread(s)
    vBActivity - Stats
    Points
    4,760
    Level
    21
    vBActivity - Bars
    Lv. Percent
    68.7%
    Quote Originally Posted by Downloader View Post
    Calling a setter? That's not what happened.
    I already compensated and shortened the script with a combo position for instead of writing a comboat(x,y) and shortened it into a 0-175 for instead.
    Then I went and wrote out hundreds of lines of code to save the data and set it back at the push of a button in the same similar fashion as I wrote out in my example code for a hypothetical situation and got the results I was looking for which in no way "called a setter" but instead saved the combo data of every combo on an entire map by equating their values to a combo number on an array just as I described.
    The only difference is that I had to manually write an array for every individual screen instead of an array that accesses other arrays as I had suggested for a future release.
    I did this because the maps indices are limited to the point of 256 total maps, whereas writing all combo data to a series of arrays bypasses that limitation.
    Also, I didn't call setters and expecting a return, those lines of code would in fact write to an array, not return anything.
    2.60 might support some form of shorthand format for invoking pseudo-2D arrays, but this will still use multiple arrays within the scope in which it is defined. This is a fatal flaw in ZC, as there are only 255 free global registers, and thus, every global array reduces the free registers for scripts, by one.

    @Grayswandir was working on syntax to allow it, but, at a global scope, woud need to be careful, and it is just a shorthand way of array index offsets.

    The error in your code, is in this line:

    Code:
    ComboData[screen][comboposition]=Game->SetComboData(Game->GetCurMap(),screen,comboposition,ComboData[screen][comboposition]);
    Note how you call SetComboData() in an assign here.

    If you want to save stack space, define your combo arrays inside functions, per map. That way, you can populate one global array using a function with the combos from any virtual map, at any time.

    The 2.54 ZScript spec allows direct access to mapdata and combodata:

    Code:
    combodata cur_map_combos[128*176]; //array size cap is 214748, so you could store four maps per array not including layers
    mapdata m;
    bool StoreScreenCombos(in map)
    {
        for ( int q = 0; q < 128; ++q )
        {
             m =  Game->LoadMapData(map,q); //(map,screen)
             combodata cd;
             for ( int w = 0; w < 176; ++w )
             {
                 cd = Game->LoadComboData(m->ComboD[w]); //Could also store as an int if you want. (All datatypes can now be global arrays.)
                 cur_map_combos[q*128+w] = cd;
             }
        }
        return true;
    }
    ...Something like that. I may increase the maximum map count, in which case, it will be possible to clone maps using mapdata, combodata, and other resources.

    There is no logical way around the array size limit, though. It is a ZC maths cap, because all values are fixed-place at (val/10000), so the 32b system limit is the controlling factor. Thus, even with 2D arrays, you would not be able to have a 2D array with a total size greater than 214748 indices (in any combined format).

    int myArr[107374][2] or similar, would be as large as you could go. This works for arr[256][256] and similar, but not for an array to hold that many variables in one place.

  6. #6
    Keese Just registered
    Join Date
    Jan 2018
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    309
    Level
    6
    vBActivity - Bars
    Lv. Percent
    44.52%
    Sorry for my arrogance about saying I was right about what I wrote. It was just an example that I knew was fake so I wrote it up like array[][]=Set whatever on accident. In the meanwhile I was busy halfway through a script that actually works.
    I realized the mistake I made and meant this:
    //A variable int that is an array of several other arrays.
    int ComboData[128][176];
    //initialize all variables
    for(int screen=0;screen<=127;screen++)
    {
    for(int comboposition=0;comboposition<=175;comboposition++ )
    {
    ComboData[screen][comboposition];
    }
    }
    void SaveMapComboData()
    for(int screen=0;screen<=127;screen++)
    {
    for(int comboposition=0;comboposition<=175;comboposition++ )
    {
    for(int x=0;x<=256;x+=16)//skips every 16 pixels
    {
    for(int y=0;y<=176;y+=16)//skips every 16 pixels
    {
    ComboData[screen][comboposition]=Game->GetComboData(Game->GetCurMap(),screen,comboposition);
    }
    }
    }
    }
    //then afterwards
    void WriteMapComboData()
    for(int screen=0;screen<=127;screen++)
    {
    for(int comboposition=0;comboposition<=175;comboposition++ )
    {
    for(int x=0;x<=256;x+=16)//skips every 16 pixels
    {
    for(int y=0;y<=176;y+=16)//skips every 16 pixels
    {
    Game->SetComboData(Game->GetCurMap(),screen,comboposition,ComboData[screen][comboposition]);
    }
    }
    }
    }

    Anyway, I wrote a series of arrays for every screen on the map of size 176 integers a piece to achieve saving the state of the map and reloading it..

    Here is an example video of what it would be used for, aside from a player option of Save/Load live in ZC, it would replenish combos that were used in my scrolling scripts, because essentially the code erases them off of the given map when picked up/sword slashed, and then the array calls put them back upon entering a different section of the map.
    https://youtu.be/ulIZeH9ZxX0

  7. #7
    Keese Just registered
    Join Date
    Jan 2018
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    309
    Level
    6
    vBActivity - Bars
    Lv. Percent
    44.52%
    So you're saying that an array the size of Array[10000] is possible? I believe that many years ago when I attempted something like that it was limited to much less than that.
    Also, in my Dawn of Minora script I bypassed the size limit of the integers by wrapping into a new integer for place values by using the simple math function add(a,b) to have numbers writable up to trillions of place value.. I am sure a bypass like that would work for something like saving combo data also..

    I have a question though about how many arrays are currently allowed in the first place.. I'm certain that 5-6 years ago it was limited to a lot less than I got away with this time, as ZQ would tell me that I ran out of integers pretty quickly, like around 100 variables or something, whereas this time I wrote several hundred and it works perfectly.

  8. #8
    Keese Just registered
    Join Date
    Jan 2018
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    309
    Level
    6
    vBActivity - Bars
    Lv. Percent
    44.52%
    Also, I'm still looking for that edit button and it just isn't there..
    Another thing, I wrote the staff here at AGN about password recovery and my loss of access to my old email address that I no longer have.. Is there any way I could get my old account activated again and reset the password. Old screen name "Zim."

  9. #9
    The Timelord
    QDB Manager
    ZC Developer

    Join Date
    Oct 2006
    Location
    Prydon Academy
    Posts
    1,396
    Mentioned
    112 Post(s)
    Tagged
    1 Thread(s)
    vBActivity - Stats
    Points
    4,760
    Level
    21
    vBActivity - Bars
    Lv. Percent
    68.7%
    Quote Originally Posted by Downloader View Post
    Also, I'm still looking for that edit button and it just isn't there..
    Another thing, I wrote the staff here at AGN about password recovery and my loss of access to my old email address that I no longer have.. Is there any way I could get my old account activated again and reset the password. Old screen name "Zim."
    You might not be able to edit posts until your post count is > n, or you have been a member for n-days. @Chris Miller might know about this one. I'm not sure.

    The maximum size for a single array is 214748. The ZC system limits are often defined in std_constants.zh, particularly in 2.53.0b+.

  10. #10
    Octorok jeffythedragonslayer's Avatar
    Join Date
    Jan 2024
    Posts
    398
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    29
    Level
    2
    vBActivity - Bars
    Lv. Percent
    15.33%
    Quote Originally Posted by ZoriaRPG View Post
    The maximum size for a single array is 214748.
    Where did this magic number come from?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Armageddon Games is a game development group founded in 1997. We are extremely passionate about our work and our inspirations are mostly drawn from games of the 8-bit and 16-bit era.
Social