Those temp arrays are used by the Native code in various places and must never be used for persistent storage.Caba`drin said:Quick question...after spending some time with the code and running a couple of (admittedly brief) tests, I'm wondering why you chose to use a new troop for the key data rather than utilizing one of the three temp_array troops? Is there something I'm missing there? Changing the constant key_config_data to trp_temp_array_a, for instance, only requires one additional call of "script_init_key_config".
I'm aware of that...I've used them numerous times myself.Lav said:Those temp arrays are used by the Native code in various places and must never be used for persistent storage.
Unless you like a little unpredictability in your scripts.
And now suppose someone else did too, taking great care not to screw up with slots used by Native, but having no idea what slots are used by you. And then imagine yet another person trying to use both scripts in his project...Caba`drin said:I'm aware of that...I've used them numerous times myself.Lav said:Those temp arrays are used by the Native code in various places and must never be used for persistent storage.
Unless you like a little unpredictability in your scripts.
Probably. But then I wouldn't be able to understand the code, not with my nearly-zero knowledge of Python.Caba`drin said:But my point is, from what I can see and from messing with the code, this key_config_data faux-troop is not needed for persistent storage, either. All the persistent storage needed is in the global variables and the scripts that are generated at compile-time.
def set_key_config():
key_config = []
for i in xrange(len(keys_list)):
key_config.append((troop_set_slot, key_config_data, slot_default_keys_begin+i, keys_list[i][1]))
for i in xrange(len(all_keys_list)):
key_config.append((troop_set_slot, key_config_data, slot_key_defs_begin+i, all_keys_list[i][0])) ##THIS LINE
return key_config[:]
("str_store_key_name",
[
(store_script_param_1, ":str_reg"),
(store_script_param_2, ":key"),
(assign, ":end", number_of_all_keys),
(try_for_range, ":i", 0, ":end"),
(store_add, ":key_offset", slot_key_defs_begin, ":i"),
(troop_slot_eq, key_config_data, ":key_offset", ":key"),
(store_add, ":strings_offset", key_label_begin, ":i"),
(assign, ":end", 0),
(try_end),
(try_begin),
(eq, ":end", 0),
(neq, ":key", 0xff),
(str_store_string, ":str_reg", ":strings_offset"),
(else_try),
(str_store_string, ":str_reg", "str_blank_string"),
(try_end),
]),
Did you make the changes noted in my post above yours? There's a small bit missing in the Python dunde has in the OP.shokkueibu said:Hmm. This isn't working for me and I know it did before with the old code.
I even applied it to a clean module system to be sure and the same happens: the keys don't have default values and I can't bind new ones. Pressing default or reset doesn't work either.
Ah, right. Of course.shokkueibu said:Yeah. I had to otherwise it wouldn't even compile properly.
Caba`drin said:Code:def set_key_config(): key_config = [] for i in xrange(len(keys_list)): key_config.append((troop_set_slot, key_config_data, slot_default_keys_begin+i, keys_list[i][1])) for i in xrange(len(all_keys_list)): key_config.append((troop_set_slot, key_config_data, slot_key_defs_begin+i, all_keys_list[i][0])) ##THIS LINE return key_config[:]
(call_script, "script_init_all_keys"),
# Key configuration
("key_config", prsntf_manual_end_only, 0, [ #Change the header to this
(ti_on_presentation_load, [
(presentation_set_duration, 999999),
(set_fixed_point_multiplier, 1000),
(create_mesh_overlay, reg0, "mesh_load_window"), #ADD THIS