Jump to content

tinpont

Members
  • Posts

    4
  • Joined

  • Last visited

Posts posted by tinpont

  1. i guess rA treats last element array to be null if it's 0. or maybe you can change them to string array variable (i don't recommend it)

     

    wow, you changed your profile pic! I thought somebody replied to this thread as well..

    Yeah, array is better than string. Thank you for your help.

     

    you can also do like this.

    setarray .headgear0_0[0],5210,2254,10,7063,50,7168,200,7038,200,10000000;
    setarray .headgear0_1[0],5254,5132,1,5068,1,2255,1,7023,5,983,1,10000000;
    
    
    .@x = .@y = 0;
    .@size = getarraysize( getd( ".headgear"+.@x+"_"+.@y ) )
    // copy to a temporary array
    copyarray .@temp_array,getd( ".headgear"+.@x+"_"+.@y ),.@size;
    
    // check value
    for( .@i = 0; .@i < .@size; .@i++ )
    	mes ".headgear"+.@x+"_"+.@y+"["+.@i+"] = "+.@temp_array[.@i];
    close;
    
    
    way better than having a nested for-loop

     

    Great, a new way to deal with dynamic array. Thank you, Emistry.

  2.  

    I think .@var is a pointer before, but I realize it is a copy pointer with it's own structure (int). So this is why I always get array size equal 1.

    this is the thing that I'd like to say since last night.

     

    sure, np!

     

    //off topic

    shouldn't it be GLHF? (Good Luck Have Fun)?

     

    Yeah, programming is fun. Thank you.

     

    But I just found out a bug, if last element of array is 0, getarraysize will not corrected.

    setarray .headgear[0],2237,1020,100,983,1,2241,1,0;
    debugmes getarraysize(getd(".headgear"));     // output 7

    But it's not a big deal.

  3. getarraysize (.@headgear); will of course return the value of 1.

    think about this:

    .@i = 0;

    .@j = 1;

    .@headgear = getd(".headgear" + .@i + "_" + .@j); ---> .@headgear = .headgear0_1;  right?

     

    Therefore, getarraysize(.@headgear); will ofc be 1. (because .headgear0_1 is the same as .headgear0_1[0] (C's rule))

    (could be different in implementation, tho..)

     

    but if you want to print all elements on the array, then it shall be like this:

    for (.@i = 0; .@i <10; .@i++ <or i think: set .@i, .@i+1> {
      for (.@j = 0; .@j<=1; .@j++) {
        for (.@k = 0; .@k<10; .@k++){
          .@headgear = getd(".headgear" + .@i + "_" + .@j + "[" + k + "]");
          debugmes .@headgear;
        }
      }
    }
    

    if you want to print the item name, then.....

    for (.@i = 0; .@i <10; .@i++ <or i think: set .@i, .@i+1> {
      for (.@j = 0; .@j<=1; .@j++) {
        for (.@k = 0; .@k<10; .@k++){
          .@headgear = getd(".headgear" + .@i + "_" + .@j + "[" + k + "]");
          .@headgearname$ = getitemname(.@headgear);
          debugmes .@headgearname$;
        }
      }
    }
    

    is it the question?

    Hey, Winz, Thank you for your reply.

     

    As you can see, the array size of .headgear{i}_{j} is dynamic(not confirm).

    How can I get the array size? Use while(.headgear{i}_{j}[k]) or something  to calculate?

    I think I should read some source code first. Thanks.

    Final I found out how to get array size dynamic.

    .@count = getarraysize(getd(".HLGFHeadgear" + .@i + "_" + .@j));

    I think .@var is a pointer before, but I realize it is a copy pointer with it's own structure (int). So this is why I always get array size equal 1.

    And getd actually return array's pointer, so it could read size easily. Thank you Winz.

  4. code first.

    setarray .headgear0_0[0],5210,2254,10,7063,50,7168,200,7038,200,10000000;
    setarray .headgear0_1[0],5254,5132,1,5068,1,2255,1,7023,5,983,1,10000000;
    
    .@i = 0;
    .@j = 1;
    .@headgear = getd(".headgear" + .@i + "_" + .@j);
    debugmes getarraysize(.@headgear);      // output 1
    debugmes .@headgear;    // output 5254
    

    I want to get the entire array from dynamic string, but the result not my expect.

    I already read document here: http://rathena.org/wiki/Variables#Simulating_Multidimensional_Arrays , but not telling me how to get entire array dynamic.

     

    Am I missing something or my way is wrong ?

    Sorry for my poor English....

×
×
  • Create New...