User Tag List

Page 2 of 2 FirstFirst 1 2
Results 11 to 17 of 17

Thread: Regarding arrays

  1. #11
    The Time-Loop Continues ZC Developer
    Gleeok's Avatar
    Join Date
    Apr 2007
    Posts
    4,826
    Mentioned
    259 Post(s)
    Tagged
    10 Thread(s)
    vBActivity - Stats
    Points
    12,958
    Level
    33
    vBActivity - Bars
    Lv. Percent
    26.09%

    Re: Regarding arrays

    Oh, I get what you're doing now. I don't know that's even neccessary though. since ASCII chars already have a number value why do you need to assign them another?

    I just tested this out and it works friggin great. Check it out, this was about as user freindly as I could make:


    EDIT: Got it.

    Code:
    int string1[98] = "this is a test |this is only a test |if this had been an actual emergency, |you would be dead.";
    
    int string2[25] = "abcdefghijklmnopqrstuvwxyz";
    
    
    int string3[9] = {1,2,3,4,5,6,7,8,9};
    int string4[9] = {1,2,3,4,5,6,7,8,9};
    int string5[9] = {1,2,3,4,5,6,7,8,9};
    int string6[9] = {1,2,3,4,5,6,7,8,9};
    int string7[9] = {1,2,3,4,5,6,7,8,9};
    int string8[9] = {1,2,3,4,5,6,7,8,9};
    int string9[9] = {1,2,3,4,5,6,7,8,9};
    
    
    
    
    global script test{
    	void run(){
    
    		while(true){
    
    			Waitframes(30);
    
    			Draw_String(1,98,0,0,6);
    		}
    	}
    }
    
    int temp[255];
    
    void Draw_String(int string, int max_depth, int Xindent, int Yindent, int cset){
    
    	int x = Xindent; int y = Yindent;
    	int i; int t; int j; int k;
    	int tile = 520;
    
    	if(string==1){ for(i=0;i<=max_depth;i++) temp[i] = string1[i]; }
    	else if(string==2){ for(i=0;i<=max_depth;i++) temp[i] = string2[i]; }
    	else if(string==3){ for(i=0;i<=max_depth;i++) temp[i] = string3[i]; }
    	else if(string==4){ for(i=0;i<=max_depth;i++) temp[i] = string4[i]; }
    	else if(string==5){ for(i=0;i<=max_depth;i++) temp[i] = string5[i]; }
    	else if(string==6){ for(i=0;i<=max_depth;i++) temp[i] = string6[i]; }
    	else if(string==7){ for(i=0;i<=max_depth;i++) temp[i] = string7[i]; }
    	else if(string==8){ for(i=0;i<=max_depth;i++) temp[i] = string8[i]; }
    	else if(string==9){ for(i=0;i<=max_depth;i++) temp[i] = string9[i]; }
    
    	Waitframe();
    
    
    	for(i=0;i<=max_depth;i++){
    
    		for(k=0;k<4;k++){
    
    			for(j=0;j<=i;j++){
    
    				if(temp[j]==124){
    					t = tile + 32;
    					Screen->DrawTile(6,x,y,t,1,1,cset,1,0,0,0,0,true,128);
    					y+=8;x=Xindent;
    				}
    				else{
    					t = tile + temp[j];
    					Screen->DrawTile(6,x,y,t,1,1,cset,1,0,0,0,0,true,128);
    					x+=6;
    				}
    			}
    			x=Xindent;y=Yindent;
    			Waitframe();
    		}
    	}
    }

    This post contains the official Gleeok seal of approval. Look for these and other posts in an area near you.

  2. #12
    Lynel
    ZC Developer
    pkmnfrk's Avatar
    Join Date
    Jan 2004
    Location
    Toronto
    Age
    37
    Posts
    1,248
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    3,141
    Level
    18
    vBActivity - Bars
    Lv. Percent
    10.29%

    Re: Regarding arrays

    http://zctut.com/strings.zip

    This is how I done it.

    The original strings are in strings.tbl. It's a plain text file, comments start with @. Certain comments are special, such as the @bufname at the top. That tells strings.exe what to call the variable.

    A string is said to be everything from the start of a line to the end. If a string ends in "\", it's "escaping" the new line at the end, and allows a string to span more than one line (with an embedded new-line). Also, you can explicitly embed control codes (or, rather, you will be able to), such as "\n" for new line, or "\c" for change cset.

    anyway, drag strings.tbl onto strings.exe to create strings.zh. This is a very ugly file to inspect manually. Your strings are those ugly blocks of numbers and brackets that look like something out of the IOCCC competition. Don't worry about that.

    Anyway, strings.zh defines 5 important things for your script:
    * a string buffer (although, you shouldn't have to interact with this directly)
    * a constant with the size of the buffer (again, it's primarily for internal use)
    * a loadString(int) function, which allows you to load a string into the buffer.
    * a loadString(int, int) function, which allows you to load part of a string into the buffer. The second parameter is how much to load. You can only load from the beginning to an arbitrary point.
    * a stringLen(int) function, which returns the size of a string.

    Combining the two last functions allows you to have, say, a block of text that slowly appears on screen.

    The last file to look at is quest.z, which is the main script file. It has all the non-directly-related-to-strings stuff, such as the font-width definitions, a couple unrelated arrays, and the drawString() function.

    drawString accepts 5 parameters: s_tile (the first tile in the font set, which should be ASCII 32), cset (the cset), lay (the layer), x and y (yeah).

    Above this, in the onStart() script, I demonstrate how one could create a marquee (scrolling text). My intro is comprised of three strings, which slow scroll from bottom to top, one after another. As a speed optimization, it won't load and draw the string unless part of it is on screen.

    Start a new game on the included quest to check it out in action.
    Tale of the Cave - a web comic - Updates Monday, Wednesday, Friday
    ZC Tutorials - Tutorials and Script Library - Updated July 30, 2008
    ZeldaGuard - Corruption in my save files? It's more likely than you think!
    I do script requests!

  3. #13
    The Time-Loop Continues ZC Developer
    Gleeok's Avatar
    Join Date
    Apr 2007
    Posts
    4,826
    Mentioned
    259 Post(s)
    Tagged
    10 Thread(s)
    vBActivity - Stats
    Points
    12,958
    Level
    33
    vBActivity - Bars
    Lv. Percent
    26.09%

    Re: Regarding arrays

    Wowsers. You made a seperate program to do that for you. That's pretty impressive. No wonder I couldn't make heads or tails out of what you were posting. ..Well then, carry on.

    What's the max number of strings you can generate like that? ..And good god, how long did that take?

    Looks awesome.
    This post contains the official Gleeok seal of approval. Look for these and other posts in an area near you.

  4. #14
    Lynel
    ZC Developer
    pkmnfrk's Avatar
    Join Date
    Jan 2004
    Location
    Toronto
    Age
    37
    Posts
    1,248
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    3,141
    Level
    18
    vBActivity - Bars
    Lv. Percent
    10.29%

    Re: Regarding arrays

    Altogether, about three hours.

    How many strings? Well, the program can do about 2 billion before it chokes, though I don't know how much ZC can handle.

    I do know that obscenely long strings (500 chars+, maybe) cause ZC to barf a little in its mouth, and not do anything at all, but if you break them up like I did, it should be fine.

    The main advantage of my method over yours is that I'm not relying on arrays being saved and loaded. You are. I bet your code would break if you saved, since right now arrays are borked. And, if that was fixed, then you couldn't ever change your arrays, since they're only set on a new game (in ~Init).

    My way is more likely to chew up valuable room in the script buffer, but it won't break on new versions of the quest.
    Tale of the Cave - a web comic - Updates Monday, Wednesday, Friday
    ZC Tutorials - Tutorials and Script Library - Updated July 30, 2008
    ZeldaGuard - Corruption in my save files? It's more likely than you think!
    I do script requests!

  5. #15
    Developer
    ZC Developer
    jman2050's Avatar
    Join Date
    Jun 2001
    Location
    Do you really need to know
    Age
    37
    Posts
    3,883
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    5,708
    Level
    23
    vBActivity - Bars
    Lv. Percent
    45.98%

    Re: Regarding arrays

    ...I should've finished implementing strings a long time ago. Ah well, Zscripters are resourceful as always XD
    AGN's Resident Zelda Classic Developer and Sonic the Hedgehog Fanboy

  6. #16
    Lynel
    ZC Developer
    pkmnfrk's Avatar
    Join Date
    Jan 2004
    Location
    Toronto
    Age
    37
    Posts
    1,248
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    3,141
    Level
    18
    vBActivity - Bars
    Lv. Percent
    10.29%

    Re: Regarding arrays

    Your mistake was to give me an inch. Strictly speaking, none of this requires strings proper, only arrays
    Tale of the Cave - a web comic - Updates Monday, Wednesday, Friday
    ZC Tutorials - Tutorials and Script Library - Updated July 30, 2008
    ZeldaGuard - Corruption in my save files? It's more likely than you think!
    I do script requests!

  7. #17
    Octorok CaRmAgE's Avatar
    Join Date
    Oct 2008
    Location
    Historia
    Age
    35
    Posts
    494
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    1,334
    Level
    12
    vBActivity - Bars
    Lv. Percent
    42.41%

    Re: Regarding arrays

    I'm sure this program will have some useful applications. Nice brainstorming, guys.

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