Fallout 2 mod arrays

Discussion in 'Fallout General Modding' started by Nirran, Apr 29, 2019.

  1. Nirran

    Nirran Vault Senior Citizen
    Modder

    Apr 15, 2007
    i wnat to create an array that is accessable from anywhere untill game reload,this code works whil ein the same frame,but if i access it from another porocedure it doesnt display the values set to it


    Code:
        PerkName := [get_ini_setting(ini_file + Array_aa), get_ini_setting(ini_file + Array_bb), get_ini_setting(ini_file + Array_cc), get_ini_setting(ini_file + Array_dd), get_ini_setting(ini_file + Array_ee), get_ini_setting(ini_file + Array_ff), get_ini_setting(ini_file + Array_gg), get_ini_setting(ini_file + Array_hh), get_ini_setting(ini_file + Array_ii), get_ini_setting(ini_file + Array_jj), get_ini_setting(ini_file + Array_kk), get_ini_setting(ini_file + Array_ll), get_ini_setting(ini_file + Array_a), get_ini_setting(ini_file + Array_b), get_ini_setting(ini_file + Array_c), get_ini_setting(ini_file + Array_d), get_ini_setting(ini_file + Array_e), get_ini_setting(ini_file + Array_f), get_ini_setting(ini_file + Array_g), get_ini_setting(ini_file + Array_h), get_ini_setting(ini_file + Array_i), get_ini_setting(ini_file + Array_j), get_ini_setting(ini_file + Array_k), get_ini_setting(ini_file + Array_l), get_ini_setting(ini_file + Array_m), get_ini_setting(ini_file + Array_n), get_ini_setting(ini_file + Array_o), get_ini_setting(ini_file + Array_p), get_ini_setting(ini_file + Array_q), get_ini_setting(ini_file + Array_r), get_ini_setting(ini_file + Array_s), get_ini_setting(ini_file + Array_t), get_ini_setting(ini_file + Array_u), get_ini_setting(ini_file + Array_v), get_ini_setting(ini_file + Array_w), get_ini_setting(ini_file + Array_x), get_ini_setting(ini_file + Array_y), get_ini_setting(ini_file + Array_z)];
        Display_Array := [Array_aa, Array_bb, Array_cc, Array_dd, Array_ee, Array_ff, Array_gg, Array_hh, Array_ii, Array_jj, Array_kk, Array_ll, Array_a, Array_b, Array_c, Array_d, Array_e, Array_f, Array_g, Array_h, Array_i, Array_j, Array_k, Array_l, Array_m, Array_n, Array_o, Array_p, Array_q, Array_r, Array_s, Array_t, Array_u, Array_v, Array_w, Array_x, Array_y, Array_z];
       if (Spam_INI) then begin
           while (track < 38) do begin
               display_msg(Display_Array[track] + " " + PerkName[track]);
               track := track +1;
           end
        end
       fix_array(PerkName);
    what am i doing wrong?

    edit : found the problem,seems using a variable name to set a variable is the problem,any way of doing that?for instance i have a variable string i want to use the string as the name for an int variable,is this possible?or is any way of assigning a static int as the array id for arrays?
     
    Last edited: Apr 29, 2019
  2. Mr.Stalin

    Mr.Stalin Agent of Enclave Modder

    281
    Oct 29, 2015
    how is it?!) show a good example
     
  3. Mr.Stalin

    Mr.Stalin Agent of Enclave Modder

    281
    Oct 29, 2015
    no.
    I do not quite understand the task, what do you want to do ?.
    if you need a constant array with your ”id", make it saveable.
     
  4. Nirran

    Nirran Vault Senior Citizen
    Modder

    Apr 15, 2007
    i have a defined string that when using an array variable name is set to an int,i want to use this as the array name,but is stored as int
     
  5. Nirran

    Nirran Vault Senior Citizen
    Modder

    Apr 15, 2007
    boo thnx,i wanted the arrayID int to be settable by me
     
    Last edited: Apr 30, 2019
  6. Mr.Stalin

    Mr.Stalin Agent of Enclave Modder

    281
    Oct 29, 2015
    I don't understand anything, string... name... int...
    give a practical example.

    Code:
    mapArray["i have a defined string"] := 515;
    So?)
     
    Last edited: Apr 30, 2019
  7. Nirran

    Nirran Vault Senior Citizen
    Modder

    Apr 15, 2007
    ww
    Code:
    
    #define PerkName     Comprehension
    
    used before array :
    
    dsiplay_msg (PerkName): results "Comprehension"
    
    used afetr array : 
    
    PerkName := ["a","b","c"];
    
    display_msg(PerkName); = "1" //or w/e internal name array number
     
  8. Mr.Stalin

    Mr.Stalin Agent of Enclave Modder

    281
    Oct 29, 2015
    :shock: full shit
    #define PerkName - first, it is not a variable with text, but a simple substitution of the characters - Comprehension.

    Code:
    #define PerkName                     Comprehension
    #define ArrayPerk(name)            mapArray[#name] := PerkName
    #define GetPerkValue(name, i)     mapArray.name[i]
    
    variable PerkName, mapArray;
    
    procedure start begin
          PerkName := ["a","b","c"];
          ArrayPerk(Comprehension);
    
          display_msg("result: " + GetPerkValue(PerkName, 0)); // should print "a"
    end
    after compille script
    Code:
    variable Comprehension, mapArray;
          Comprehension := temp_array(0, 0) + arrayexpr(0, "a") + arrayexpr(1, "b") + arrayexpr(2, "c");
          set_array(mapArray, "Comprehension", Comprehension);
          display_msg("result:" + get_array(get_array(mapArray, "Comprehension"), 0));
     
    Last edited: May 1, 2019
  9. Nirran

    Nirran Vault Senior Citizen
    Modder

    Apr 15, 2007
    ok thnx,il try that,see if its what im after


    Gonna Give example,thxn
     
    Last edited: May 3, 2019
  10. Nirran

    Nirran Vault Senior Citizen
    Modder

    Apr 15, 2007
    this code copy pasted into blank gl_ ,results in 0 when in game
     
  11. Mr.Stalin

    Mr.Stalin Agent of Enclave Modder

    281
    Oct 29, 2015
    This should not work, because it is an example, and the script code is not complete, the associative array is not made.
    Read the documentation about arrays.
     
  12. Nirran

    Nirran Vault Senior Citizen
    Modder

    Apr 15, 2007
    ok thxn for ur help

    question,do arrays act similar to sfall globals?as in they are accessable from anywhere?


    edit : i feela s tho i was rude,im sorry Mr.Stalin
     
    Last edited: May 2, 2019
  13. Mr.Stalin

    Mr.Stalin Agent of Enclave Modder

    281
    Oct 29, 2015
    Yes.
     
  14. Nirran

    Nirran Vault Senior Citizen
    Modder

    Apr 15, 2007
    thnx

    edit : wanta ask before i submit a request

    1) what is the pro's cons of using arrays vrs sfall globals

    2) is it possible to add static int arrayID settable by the modder via sfall function request?
     
    Last edited: May 2, 2019
  15. Mr.Stalin

    Mr.Stalin Agent of Enclave Modder

    281
    Oct 29, 2015
    It's not about the pros and cons, they just have different tasks to use.
    Сan add a new function.
    But I do not understand why use a statistical ID?
    You not told me about your task, your example above does not explain why you need it.
    Possible, it can be done without a statistical ID.
     
  16. NovaRain

    NovaRain Casual Modder Modder

    Mar 10, 2007
    If you want to use saved arrays, you access them by their names you set. Not sure why you insist on static int.
     
  17. Nirran

    Nirran Vault Senior Citizen
    Modder

    Apr 15, 2007
    im debating switching my perk mods from sfall globals to arrays,thus would have tons of arrays,donno if it is worth it,lots of work,setting int specific for each would be easy,tho if u can use a string thats even better,in this procedure i have most of the code reading the ini files,how would i use the name?

    Code:
    procedure Innit_Array(variable PerkName,variable Spam_INI,variable ini_file) begin
    variable Array_aa := PerkName + aa;
    variable Array_bb := PerkName + bb;                                                                    
    variable Array_cc := PerkName + cc;                                                
    variable Array_dd := PerkName + dd;                                                                      
    variable Array_ee := PerkName + ee;                                                                      
    variable Array_ff := PerkName + ff;                                                                     
    variable Array_gg := PerkName + gg;                                                                     
    variable Array_hh := PerkName + hh;                                                                 
    variable Array_ii := PerkName + ii;                                                                 
    variable Array_jj := PerkName + jj;                                                                 
    variable Array_kk := PerkName + kk;                                                               
    variable Array_ll := PerkName + ll;                                                             
    variable Array_a := PerkName + a;                                                                   
    variable Array_b := PerkName + b;                                                                
    variable Array_c := PerkName + c;                                                                  
    variable Array_d := PerkName + d;                                                            
    variable Array_e := PerkName + e;                                                              
    variable Array_f := PerkName + f;                                                                
    variable Array_g := PerkName + g;                                                        
    variable Array_h := PerkName + h;                                                            
    variable Array_i := PerkName + i;                                                          
    variable Array_j := PerkName + j;                                                            
    variable Array_k := PerkName + k;                                                            
    variable Array_l := PerkName + l;                                                                  
    variable Array_m := PerkName + m;                                                                  
    variable Array_n := PerkName + n;                                                                  
    variable Array_o := PerkName + o;                                                                
    variable Array_p := PerkName + p;                                                                  
    variable Array_q := PerkName + q;                                                                
    variable Array_r := PerkName + r;                                                                
    variable Array_s := PerkName + s;                                                                  
    variable Array_t := PerkName + t;                                                    
    variable Array_u := PerkName + u;                                                    
    variable Array_v := PerkName + v;                                                    
    variable Array_w := PerkName + w;                                                          
    variable Array_x := PerkName + x;                                                                
    variable Array_y := PerkName + y;                                                                  
    variable Array_z := PerkName + z;
    variable track := 0;
    variable PerkArrayName;      
    variable Display_Array := PerkName + "Spam";
    
        //PerkArrayName := PerkName;
       PerkName := [get_ini_setting(ini_file + Array_aa), get_ini_setting(ini_file + Array_bb), get_ini_setting(ini_file + Array_cc), get_ini_setting(ini_file + Array_dd), get_ini_setting(ini_file + Array_ee), get_ini_setting(ini_file + Array_ff), get_ini_setting(ini_file + Array_gg), get_ini_setting(ini_file + Array_hh), get_ini_setting(ini_file + Array_ii), get_ini_setting(ini_file + Array_jj), get_ini_setting(ini_file + Array_kk), get_ini_setting(ini_file + Array_ll), get_ini_setting(ini_file + Array_a), get_ini_setting(ini_file + Array_b), get_ini_setting(ini_file + Array_c), get_ini_setting(ini_file + Array_d), get_ini_setting(ini_file + Array_e), get_ini_setting(ini_file + Array_f), get_ini_setting(ini_file + Array_g), get_ini_setting(ini_file + Array_h), get_ini_setting(ini_file + Array_i), get_ini_setting(ini_file + Array_j), get_ini_setting(ini_file + Array_k), get_ini_setting(ini_file + Array_l), get_ini_setting(ini_file + Array_m), get_ini_setting(ini_file + Array_n), get_ini_setting(ini_file + Array_o), get_ini_setting(ini_file + Array_p), get_ini_setting(ini_file + Array_q), get_ini_setting(ini_file + Array_r), get_ini_setting(ini_file + Array_s), get_ini_setting(ini_file + Array_t), get_ini_setting(ini_file + Array_u), get_ini_setting(ini_file + Array_v), get_ini_setting(ini_file + Array_w), get_ini_setting(ini_file + Array_x), get_ini_setting(ini_file + Array_y), get_ini_setting(ini_file + Array_z)];
        Display_Array := [Array_aa, Array_bb, Array_cc, Array_dd, Array_ee, Array_ff, Array_gg, Array_hh, Array_ii, Array_jj, Array_kk, Array_ll, Array_a, Array_b, Array_c, Array_d, Array_e, Array_f, Array_g, Array_h, Array_i, Array_j, Array_k, Array_l, Array_m, Array_n, Array_o, Array_p, Array_q, Array_r, Array_s, Array_t, Array_u, Array_v, Array_w, Array_x, Array_y, Array_z];
       if (Spam_INI) then begin
           while (track < 38) do begin
               display_msg(Display_Array[track] + " " + PerkName[track]);
               track := track +1;
           end
        end
       //call SetPerkVariable(PerkArrayName, PerkName);
       //save_array(PerkArrayName, PerkName);
       fix_array(PerkName);
    end
    as u can see,im using a precedure var to set the name

    quite probably is a better way of doing it
     
  18. Mr.Stalin

    Mr.Stalin Agent of Enclave Modder

    281
    Oct 29, 2015
    Why so many variables? What do aa bb cc suffixes contain?
    Show the full script.

    ps. very bad script code. :-)
     
  19. Nirran

    Nirran Vault Senior Citizen
    Modder

    Apr 15, 2007
    they are defines for ini settings,and i know,not done yet

    this is some of the defines,they are all similar
    Code:
    #define aa                                                                     "Enable"                       //0
    #define bb                                                                      "Ranks"                        //1
    #define cc                                                                       "RequirementLevel"     
    
    got it working,this is the relavent code

    init
    Code:
     save_array(PerkArrayName, PerkName);
     PerkArrayName := load_array(PerkArrayName);
    
    and retrieve
    Code:
    procedure GetPerkValue(variable PerkArrayName, variable ArrayLocation) begin
       variable ArrayName := load_array(PerkArrayName);
       return ArrayName[ArrayLocation];
    end
    
    thnx for the help guys

    wondering if it is worth hastle

    edit : here is the script

    edit : which is better?the array or sfall globals?this is globals script
     

    Attached Files:

    Last edited: May 3, 2019
  20. Mr.Stalin

    Mr.Stalin Agent of Enclave Modder

    281
    Oct 29, 2015
    I rewrote your script to you, without using statistical id and global variables.
    in Set_Global_Variables - arrays will be initialized for all your added perks
    in GetPerkValue - you can refer to any of its parameters by the name of the perk

    Arrays are better suited for this. Global variables were created for other uses.
     

    Attached Files:

    Last edited: May 3, 2019