How do i save more values in one slot and check

Users who are viewing this thread

Kosolov325

Recruit
i'm doing a door owner system.. so i did a simple checker, that work checking if the player have in a slot called ("slot player door key") the same value of the val1 from the prop were i setted in the map editor


Code:
    (try_begin),
        (neg|player_is_admin, ":player_id"),
        (gt, ":check_var", 9),
        (player_is_active, ":player_id"),
        (player_get_slot, ":player_door_key", ":player_id", slot_player_door_key),
        (eq, ":check_var", ":player_door_key"),
        (try_begin),
          (assign, ":fail", 0),
        (else_try),
          (assign, ":fail", 1),
      (try_end),
   
      (eq, ":fail", 0),
       (prop_instance_get_position, pos1, ":linked_door_instance_id"),
       (position_move_x, pos1, ":x_offset"),
       (position_move_y, pos1, ":y_offset"),
       (position_move_z, pos1, ":z_offset"),
      (try_begin),
       (eq, ":horse_can_tp", 1),
       (agent_get_horse, ":horse_agent_id", ":agent_id"),
       (gt, ":horse_agent_id", -1),
       (assign, ":agent_id", ":horse_agent_id"),
     (try_end),
     (agent_set_position, ":agent_id", pos1),

So ... i was thinking ... if intend to set more "keys" for the player .... how do i set more than one value ("key") in slot and check if in this var (now an array) there are any value equals to the prop val1?

**Sorry, my English is rusty
 
Last edited:
Solution
WSE integrated array functionality, however I never worked with them so I can't help with them too much.

Python:
array_create        = 5000 #(array_create, <destination>, <type_id>, <Dim 0>, [<Dim 1>], [<Dim 2>], [<Dim 3>], [<Dim 4>], [<Dim 5>], [<Dim 6>], [<Dim 7>], [<Dim 8>], [<Dim 9>], [<Dim 10>], [<Dim 11>], [<Dim 12>], [<Dim 13>]), #Creates an array object of <type_id> (0: Integer, 1: String, 2: Position) and stores its ID into <destination>. You can specify up to 14 dimensions, from <Dim 0> to [<Dim 13>]. The array will be initialized by default with 0 / empty string / 0-position.
array_free          = 5001 #(array_free, <arrayID>), #Frees array with <arrayID>.
array_copy          = 5002 #(array_copy, <destination>, <source arrayID>)...
WSE integrated array functionality, however I never worked with them so I can't help with them too much.

Python:
array_create        = 5000 #(array_create, <destination>, <type_id>, <Dim 0>, [<Dim 1>], [<Dim 2>], [<Dim 3>], [<Dim 4>], [<Dim 5>], [<Dim 6>], [<Dim 7>], [<Dim 8>], [<Dim 9>], [<Dim 10>], [<Dim 11>], [<Dim 12>], [<Dim 13>]), #Creates an array object of <type_id> (0: Integer, 1: String, 2: Position) and stores its ID into <destination>. You can specify up to 14 dimensions, from <Dim 0> to [<Dim 13>]. The array will be initialized by default with 0 / empty string / 0-position.
array_free          = 5001 #(array_free, <arrayID>), #Frees array with <arrayID>.
array_copy          = 5002 #(array_copy, <destination>, <source arrayID>), #Copys array with <source arrayID> and stores the new array id into <destination>.
array_save_file     = 5003 #(array_save_file, <arrayID>, <file>), #Saves <arrayID> into a file. For security reasons, <file> is just a name, not a full path, and will be stored into a WSE managed directory.
array_load_file     = 5004 #(array_load_file, <destination>, <file>), #Loads <file> as an array and stores the newly created array's ID into <destination>.
array_delete_file   = 5005 #(array_delete_file, <file>), #Deletes array <file>.
array_set_val       = 5006 #(array_set_val, <arrayID>, <value>, <Index 0>, [<Index 1>], [<Index 2>], [<Index 3>], [<Index 4>], [<Index 5>], [<Index 6>], [<Index 7>], [<Index 8>], [<Index 9>], [<Index 10>], [<Index 11>], [<Index 12>], [<Index 13>]), #Writes <value> to the array with <arrayID> at the specified index. <value> can be an integer, a position register or a string register and must match the type of the array.
array_set_val_all   = 5007 #(array_set_val_all, <arrayID>, <value>), #Writes <value> to all indices of the array with <arrayID>. <value> can be an integer, a position register or a string register and must match the type of the array.
array_get_val       = 5008 #(array_get_val, <destination>, <arrayID>, <Index 0>, [<Index 1>], [<Index 2>], [<Index 3>], [<Index 4>], [<Index 5>], [<Index 6>], [<Index 7>], [<Index 8>], [<Index 9>], [<Index 10>], [<Index 11>], [<Index 12>], [<Index 13>]), #Gets a value from the array with <arrayID> at the specified index and writes it to <destination>. <destination> can be a variable, a position register or a string register and must match the type of the array.
array_push          = 5009 #(array_push, <destination arrayID>, <source>), #Pushes <source> on the array with <destination arrayID>. If <destination arrayID> is a 1D array, <source> can be an int, string, or position register and must match the type of <destination arrayID>. If <destination arrayID> is multidimensional, <source> must be the id of an array with matching type, src dimension count = dest dimension count - 1, and dimension sizes src_dim_0_size = dest_dim_1_size ... src_dim_n_size = dest_dim_n+1_size.
array_pop           = 5010 #(array_pop, <destination>, <arrayID>), #Pops the last value  from the array with <arrayID>. If <arrayID> is a 1D array, <destination> must be a variable, string, or position register and must match the type of <arrayID>. If <arrayID> is multidimensional, a new array with dimension count = src dimension count - 1, dimensions dim_0 = src_dim_1 ... dim_n = src_dim_n+1 will be created and its ID will be stored in <destination>
array_resize_dim    = 5011 #(array_resize_dim, <arrayID>, <dimIndex>, <size>), #Changes the size of the dimension with <dimIndex> of the array with <arrayID> to <size>.
array_get_dim_size  = 5012 #(array_get_dim_size, <destination>, <arrayID>, <dimIndex>), #Gets the size of the dimension with <dimIndex> of the array with <arrayID> and stores it into <destination>.
array_get_dim_count = 5013 #(array_get_dim_count, <destination>, <arrayID>), #Gets the the amount of dimensions of the array with <arrayID> and stores it into <destination>.
array_get_type_id   = 5014 #(array_get_type_id, <destination>, <arrayID>), #Gets the the type id of the array with <arrayID> and stores it into <destination>.
array_sort          = 5015 #(array_sort, <arrayID>, <sortMode>, [<Index 1>], [<Index 2>], [<Index 3>], [<Index 4>], [<Index 5>], [<Index 6>], [<Index 7>], [<Index 8>], [<Index 9>], [<Index 10>], [<Index 11>], [<Index 12>], [<Index 13>]), #Sorts the array with <arrayID> using a stable natural-mergesort algorithm. <sortMode> can be: [sort_m_int_asc or sort_m_int_desc] for int, [sort_m_str_cs_asc, sort_m_str_cs_desc, sort_m_str_ci_asc, sort_m_str_ci_desc] for str (asc=ascending, desc=descending, cs=case sensitive, ci=case insensitive, strings are compared alphabetically, upper before lower case). If the array is multidimensional, only the first dimension will be sorted and you must specify (dim_count - 1) fixed indices that will be used for access.
array_sort_custom   = 5016 #(array_sort_custom, <arrayID>, <cmpScript>, [<Index 1>], [<Index 2>], [<Index 3>], [<Index 4>], [<Index 5>], [<Index 6>], [<Index 7>], [<Index 8>], [<Index 9>], [<Index 10>], [<Index 11>], [<Index 12>], [<Index 13>]), #Sorts the array with <arrayID> using a stable natural-mergesort algorithm. <cmpScript> must compare its two input values (reg0 and reg1 / s0 and s1 / pos0 and pos1) and use (return_values, x) where x is nonzero if the first value goes before or is equal to the second, and zero otherwise. If the array is multidimensional, only the first dimension will be sorted and you must specify (dim_count - 1) fixed indices that will be used for access. The sorting won't be successful if the compare script does not work properly. The algorithm will abort at some point and not go into an infinite loop, it may however take extremely long to finish on big arrays.
array_eq            = 5017 #(array_eq, <arrayID>, <value_1>, <Index 0>, [<Index 1>], [<Index 2>], [<Index 3>], [<Index 4>], [<Index 5>], [<Index 6>], [<Index 7>], [<Index 8>], [<Index 9>], [<Index 10>], [<Index 11>], [<Index 12>], [<Index 13>]), #Fails if the specified value in the array with <arrayID> is not equal to <value_1>. Works for int, str and pos.
array_neq           = 5018 #(array_neq, <arrayID>, <value_1>, <Index 0>, [<Index 1>], [<Index 2>], [<Index 3>], [<Index 4>], [<Index 5>], [<Index 6>], [<Index 7>], [<Index 8>], [<Index 9>], [<Index 10>], [<Index 11>], [<Index 12>], [<Index 13>]), #Fails if the specified value in the array with <arrayID> is equal to <value_1>. Works for int, str and pos.
array_gt            = 5019 #(array_gt, <arrayID>, <value_1>, <Index 0>, [<Index 1>], [<Index 2>], [<Index 3>], [<Index 4>], [<Index 5>], [<Index 6>], [<Index 7>], [<Index 8>], [<Index 9>], [<Index 10>], [<Index 11>], [<Index 12>], [<Index 13>]), #Fails if the specified value in the array with <arrayID> is not greater than <value_1>. Works for int and str. Strings are compared alphabetically, upper before lower case.
array_ge            = 5020 #(array_ge, <arrayID>, <value_1>, <Index 0>, [<Index 1>], [<Index 2>], [<Index 3>], [<Index 4>], [<Index 5>], [<Index 6>], [<Index 7>], [<Index 8>], [<Index 9>], [<Index 10>], [<Index 11>], [<Index 12>], [<Index 13>]), #Fails if the specified value in the array with <arrayID> is not greater or equal to <value_1>. Works for int and str. Strings are compared alphabetically, upper before lower case.
array_lt            = 5021 #(array_lt, <arrayID>, <value_1>, <Index 0>, [<Index 1>], [<Index 2>], [<Index 3>], [<Index 4>], [<Index 5>], [<Index 6>], [<Index 7>], [<Index 8>], [<Index 9>], [<Index 10>], [<Index 11>], [<Index 12>], [<Index 13>]), #Fails if the specified value in the array with <arrayID> is not lower than <value_1>. Works for int and str. Strings are compared alphabetically, upper before lower case.
array_le            = 5022 #(array_le, <arrayID>, <value_1>, <Index 0>, [<Index 1>], [<Index 2>], [<Index 3>], [<Index 4>], [<Index 5>], [<Index 6>], [<Index 7>], [<Index 8>], [<Index 9>], [<Index 10>], [<Index 11>], [<Index 12>], [<Index 13>]), #Fails if the specified value in the array with <arrayID> is not lower or equal to <value_1>. Works for int and str. Strings are compared alphabetically, upper before lower case.

The second idea I had was storing your "keys" in string, separating individual keys by - let's say comma using WSE str_split operation.
Python:
str_split                                 = 4213 #(str_split, <destination>, <string_register>, <string_1>, <delimiter>, [<skip_empty>], [<max>]), #Splits <string_1> using <delimiter> into a range of string registers, starting from <string_register>, storing [<max>] substrings at most (default = unlimited), ignoring empty (zero length) substrings if [<skip_empty>] (default = false). Stores the amount of substrings split into <destination>

break_loop                   = 8 #(break_loop), #Break out of a loop, no matter how deeply nested in try_begin blocks (requires allow_wse_execute_statement_blocks = 1 in wse_settings.ini)
continue_loop                = 9 #(continue_loop), #Continue to the next iteration of a loop, no matter how deeply nested in try_begin blocks (requires allow_wse_execute_statement_blocks = 1 in wse_settings.ini)
try_for_dict_keys            = 18 #(try_for_dict_keys, <cur_key_string_register>, <dict>), #Loops through keys of <2> (requires allow_wse_execute_statement_blocks = 1 in wse_settings.ini)
 
Upvote 0
Solution
Back
Top Bottom