B Tutorial Module System String typer kit v0.76 **updated**

Users who are viewing this thread

jik

Knight
Ok, while I was waiting on an answer (thanks MartinF) for one of my questions, I thought that I would pre-emptive strike on an in game string typer.  This KIT allows you to create a text string (much like typing your name) in game.

[EDIT: Fixed the problem with the f and a keys]

###UPDATED (02/23/2009)###
Thanks to MartinF and Jinnai, I have gotten this to a more usable state.  Can use letters,numbers and spaces.  Backspace will delete the most recent character.  You can toggle the caps for the next char with either left or right shift.  Press Delete to clear the string.  Press enter to view the current full string.  I have it set to hold a max of 25 characters, but this can be changed in the script file.




this has 3 parts, but the third is just for info:
This is the mission_template, placed anywhere:
##JIK's typing in game.  Call this mission_template to any scene.  I have tested calling it
##from a dialog, and pointing it to town_1_arena as the scene.
##Use with party_set_name to change the name of a party(town) and faction_set_name to
##change the name of a faction.
("type_out_words",mtf_no_blood,-1,"Type In a Name",
[(56, mtef_visitor_source|mtef_team_0, af_override_horse, aif_start_alarmed, 1, []),
#(58, mtef_visitor_source|mtef_team_2, af_override_horse, aif_start_alarmed, 1, []),
],
[common_inventory_not_available,
(ti_question_answered, 0, 0, [],      ##Question answer code : yes/no outcome
[(store_trigger_param_1,":answer"),
(try_begin),
(eq,":answer",0),
(finish_mission,0),
(try_end),
]
),
(1,0,ti_once,[],  ##first clear the string, reset capslock, reset string counter
[(str_clear,s10),
(assign,"$caps_on",0),
(dialog_box,"str_texttype_mission_info"),
(assign,"$str_len",0),                                ##Reset the string length   
]
),  #make sure the string to use is empty to start, turn off caps lock
(ti_tab_pressed, 0, 0, [],[(question_box,"str_do_you_wish_to_leave_tutorial"),]),

##Special keys with functionality
(0, 0, 0,[(key_clicked, key_delete)],  ## to erase and start anew
[(str_clear,s10),(assign,"$str_len",0),(display_message, "@Clearing the current string",0xaa0000)]
),
(0, 0, 0,[(this_or_next|key_clicked, key_left_shift),(key_clicked, key_right_shift)],
[(try_begin),
(eq, "$caps_on",1),
(assign, "$caps_on",0),
(display_message, "@The next letter will be lowercase..."),
(else_try),
(assign, "$caps_on",1),
(display_message, "@THE NEXT LETTER WILL BE UPPERCASE..."),
]
),
(0, 0, 0,[(key_clicked, key_backspace)],  ## to erase the last typed character
[(try_begin),
(gt,"$str_len",0),
(troop_set_slot, "trp_temp_array_b", "$str_len",0),  #test
(val_sub,"$str_len",1),
(assign,reg2,"$str_len"),
(display_message, "@Deleted last later.  $str_len is now {reg2}",0x550055),
(call_script,"script_show_text_string"),
(else_try),
(display_message, "@Nothing to delete!"),
(try_end),
]
),
(0, 0, 0,[(key_clicked, key_enter)],  ## show the string
[(call_script,"script_show_text_string"),]
),


##tip : (troop_set_slot, "trp_temp_array_b", reg(12),reg(12)), #Initialize temp_array_b such that temp_array_b = i
## Letter work here :
(0, 0, 0,[(key_clicked, key_space)],
[(assign,":val",key_space),
(troop_set_slot, "trp_temp_array_b", "$str_len",":val"),
(val_add,"$str_len",1),
(call_script,"script_show_text_string"),
]
),
(0, 0, 0,[(key_clicked, key_1)],
[(assign,":val",key_1),
(troop_set_slot, "trp_temp_array_b", "$str_len",":val"),
(val_add,"$str_len",1),
(call_script,"script_show_text_string"),
]
),
(0, 0, 0,[(key_clicked, key_2)],
[(assign,":val",key_2),
(troop_set_slot, "trp_temp_array_b", "$str_len",":val"),
(val_add,"$str_len",1),
(call_script,"script_show_text_string"),
]
),
(0, 0, 0,[(key_clicked, key_3)],
[(assign,":val",key_3),
(troop_set_slot, "trp_temp_array_b", "$str_len",":val"),
(val_add,"$str_len",1),
(call_script,"script_show_text_string"),
]
),
(0, 0, 0,[(key_clicked, key_4)],
[(assign,":val",key_4),
(troop_set_slot, "trp_temp_array_b", "$str_len",":val"),
(val_add,"$str_len",1),
(call_script,"script_show_text_string"),
]
),
(0, 0, 0,[(key_clicked, key_5)],
[(assign,":val",key_5),
(troop_set_slot, "trp_temp_array_b", "$str_len",":val"),
(val_add,"$str_len",1),
(call_script,"script_show_text_string"),
]
),
(0, 0, 0,[(key_clicked, key_6)],
[(assign,":val",key_6),
(troop_set_slot, "trp_temp_array_b", "$str_len",":val"),
(val_add,"$str_len",1),
(call_script,"script_show_text_string"),
]
),
(0, 0, 0,[(key_clicked, key_7)],
[(assign,":val",key_7),
(troop_set_slot, "trp_temp_array_b", "$str_len",":val"),
(val_add,"$str_len",1),
(call_script,"script_show_text_string"),
]
),
(0, 0, 0,[(key_clicked, key_:cool:],
[(assign,":val",key_:cool:,
(troop_set_slot, "trp_temp_array_b", "$str_len",":val"),
(val_add,"$str_len",1),
(call_script,"script_show_text_string"),
]
),
(0, 0, 0,[(key_clicked, key_9)],
[(assign,":val",key_9),
(troop_set_slot, "trp_temp_array_b", "$str_len",":val"),
(val_add,"$str_len",1),
(call_script,"script_show_text_string"),
]
),
(0, 0, 0,[(key_clicked, key_0)],
[(assign,":val",key_0),
(troop_set_slot, "trp_temp_array_b", "$str_len",":val"),
(val_add,"$str_len",1),
(call_script,"script_show_text_string"),
]
),
(0, 0, 0,[(key_clicked, key_a)],
[(assign,":val",key_a),
(try_begin),
(eq,"$caps_on",1),
(val_add,":val",10000),  ## When checking for caps, can test if the value is over 9999, then subtract 10000 from it to get just the value
(try_end),
(troop_set_slot, "trp_temp_array_b", "$str_len",":val"),
(val_add,"$str_len",1),
(call_script,"script_show_text_string"),
]
),
(0, 0, 0,[(key_clicked, key_b)],
[(assign,":val",key_b),
(try_begin),
(eq,"$caps_on",1),
(val_add,":val",10000),  ## When checking for caps, can test if the value is over 9999, then subtract 10000 from it to get just the value
(try_end),
(troop_set_slot, "trp_temp_array_b", "$str_len",":val"),
(val_add,"$str_len",1),
(call_script,"script_show_text_string"),
]
),
(0, 0, 0,[(key_clicked, key_c)],
[(assign,":val",key_c),
(try_begin),
(eq,"$caps_on",1),
(val_add,":val",10000),  ## When checking for caps, can test if the value is over 9999, then subtract 10000 from it to get just the value
(try_end),
(troop_set_slot, "trp_temp_array_b", "$str_len",":val"),
(val_add,"$str_len",1),
(call_script,"script_show_text_string"),
]
),
(0, 0, 0,[(key_clicked, key_d)],
[(assign,":val",key_d),
(try_begin),
(eq,"$caps_on",1),
(val_add,":val",10000),  ## When checking for caps, can test if the value is over 9999, then subtract 10000 from it to get just the value
(try_end),
(troop_set_slot, "trp_temp_array_b", "$str_len",":val"),
(val_add,"$str_len",1),
(call_script,"script_show_text_string"),
]
),
(0, 0, 0,[(key_clicked, key_e)],
[(assign,":val",key_e),
(try_begin),
(eq,"$caps_on",1),
(val_add,":val",10000),  ## When checking for caps, can test if the value is over 9999, then subtract 10000 from it to get just the value
(try_end),
(troop_set_slot, "trp_temp_array_b", "$str_len",":val"),
(val_add,"$str_len",1),
(call_script,"script_show_text_string"),
]
),
(0, 0, 0,[(key_clicked, key_f)],
[(assign,":val",key_f),
(try_begin),
(eq,"$caps_on",1),
(val_add,":val",10000),  ## When checking for caps, can test if the value is over 9999, then subtract 10000 from it to get just the value
(try_end),
(troop_set_slot, "trp_temp_array_b", "$str_len",":val"),
(val_add,"$str_len",1),
(call_script,"script_show_text_string"),
]
),
(0, 0, 0,[(key_clicked, key_g)],
[(assign,":val",key_g),
(try_begin),
(eq,"$caps_on",1),
(val_add,":val",10000),  ## When checking for caps, can test if the value is over 9999, then subtract 10000 from it to get just the value
(try_end),
(troop_set_slot, "trp_temp_array_b", "$str_len",":val"),
(val_add,"$str_len",1),
(call_script,"script_show_text_string"),
]
),
(0, 0, 0,[(key_clicked, key_h)],
[(assign,":val",key_h),
(try_begin),
(eq,"$caps_on",1),
(val_add,":val",10000),  ## When checking for caps, can test if the value is over 9999, then subtract 10000 from it to get just the value
(try_end),
(troop_set_slot, "trp_temp_array_b", "$str_len",":val"),
(val_add,"$str_len",1),
(call_script,"script_show_text_string"),
]
),
(0, 0, 0,[(key_clicked, key_i)],
[(assign,":val",key_i),
(try_begin),
(eq,"$caps_on",1),
(val_add,":val",10000),  ## When checking for caps, can test if the value is over 9999, then subtract 10000 from it to get just the value
(try_end),
(troop_set_slot, "trp_temp_array_b", "$str_len",":val"),
(val_add,"$str_len",1),
(call_script,"script_show_text_string"),
]
),
(0, 0, 0,[(key_clicked, key_j)],
[(assign,":val",key_j),
(try_begin),
(eq,"$caps_on",1),
(val_add,":val",10000),  ## When checking for caps, can test if the value is over 9999, then subtract 10000 from it to get just the value
(try_end),
(troop_set_slot, "trp_temp_array_b", "$str_len",":val"),
(val_add,"$str_len",1),
(call_script,"script_show_text_string"),
]
),
(0, 0, 0,[(key_clicked, key_k)],
[(assign,":val",key_k),
(try_begin),
(eq,"$caps_on",1),
(val_add,":val",10000),  ## When checking for caps, can test if the value is over 9999, then subtract 10000 from it to get just the value
(try_end),
(troop_set_slot, "trp_temp_array_b", "$str_len",":val"),
(val_add,"$str_len",1),
(call_script,"script_show_text_string"),
]
),
(0, 0, 0,[(key_clicked, key_l)],
[(assign,":val",key_l),
(try_begin),
(eq,"$caps_on",1),
(val_add,":val",10000),  ## When checking for caps, can test if the value is over 9999, then subtract 10000 from it to get just the value
(try_end),
(troop_set_slot, "trp_temp_array_b", "$str_len",":val"),
(val_add,"$str_len",1),
(call_script,"script_show_text_string"),
]
),
(0, 0, 0,[(key_clicked, key_m)],
[(assign,":val",key_m),
(try_begin),
(eq,"$caps_on",1),
(val_add,":val",10000),  ## When checking for caps, can test if the value is over 9999, then subtract 10000 from it to get just the value
(try_end),
(troop_set_slot, "trp_temp_array_b", "$str_len",":val"),
(val_add,"$str_len",1),
(call_script,"script_show_text_string"),
]
),
(0, 0, 0,[(key_clicked, key_n)],
[(assign,":val",key_n),
(try_begin),
(eq,"$caps_on",1),
(val_add,":val",10000),  ## When checking for caps, can test if the value is over 9999, then subtract 10000 from it to get just the value
(try_end),
(troop_set_slot, "trp_temp_array_b", "$str_len",":val"),
(val_add,"$str_len",1),
(call_script,"script_show_text_string"),
]
),
(0, 0, 0,[(key_clicked, key_o)],
[(assign,":val",key_o),
(try_begin),
(eq,"$caps_on",1),
(val_add,":val",10000),  ## When checking for caps, can test if the value is over 9999, then subtract 10000 from it to get just the value
(try_end),
(troop_set_slot, "trp_temp_array_b", "$str_len",":val"),
(val_add,"$str_len",1),
(call_script,"script_show_text_string"),
]
),
(0, 0, 0,[(key_clicked, key_p)],
[(assign,":val",key_p),
(try_begin),
(eq,"$caps_on",1),
(val_add,":val",10000),  ## When checking for caps, can test if the value is over 9999, then subtract 10000 from it to get just the value
(try_end),
(troop_set_slot, "trp_temp_array_b", "$str_len",":val"),
(val_add,"$str_len",1),
(call_script,"script_show_text_string"),
]
),
(0, 0, 0,[(key_clicked, key_q)],
[(assign,":val",key_q),
(try_begin),
(eq,"$caps_on",1),
(val_add,":val",10000),  ## When checking for caps, can test if the value is over 9999, then subtract 10000 from it to get just the value
(try_end),
(troop_set_slot, "trp_temp_array_b", "$str_len",":val"),
(val_add,"$str_len",1),
(call_script,"script_show_text_string"),
]
),
(0, 0, 0,[(key_clicked, key_r)],
[(assign,":val",key_r),
(try_begin),
(eq,"$caps_on",1),
(val_add,":val",10000),  ## When checking for caps, can test if the value is over 9999, then subtract 10000 from it to get just the value
(try_end),
(troop_set_slot, "trp_temp_array_b", "$str_len",":val"),
(val_add,"$str_len",1),
(call_script,"script_show_text_string"),
]
),
(0, 0, 0,[(key_clicked, key_s)],
[(assign,":val",key_s),
(try_begin),
(eq,"$caps_on",1),
(val_add,":val",10000),  ## When checking for caps, can test if the value is over 9999, then subtract 10000 from it to get just the value
(try_end),
(troop_set_slot, "trp_temp_array_b", "$str_len",":val"),
(val_add,"$str_len",1),
(call_script,"script_show_text_string"),
]
),
(0, 0, 0,[(key_clicked, key_t)],
[(assign,":val",key_t),
(try_begin),
(eq,"$caps_on",1),
(val_add,":val",10000),  ## When checking for caps, can test if the value is over 9999, then subtract 10000 from it to get just the value
(try_end),
(troop_set_slot, "trp_temp_array_b", "$str_len",":val"),
(val_add,"$str_len",1),
(call_script,"script_show_text_string"),
]
),
(0, 0, 0,[(key_clicked, key_u)],
[(assign,":val",key_u),
(try_begin),
(eq,"$caps_on",1),
(val_add,":val",10000),  ## When checking for caps, can test if the value is over 9999, then subtract 10000 from it to get just the value
(try_end),
(troop_set_slot, "trp_temp_array_b", "$str_len",":val"),
(val_add,"$str_len",1),
(call_script,"script_show_text_string"),
]
),
(0, 0, 0,[(key_clicked, key_v)],
[(assign,":val",key_v),
(try_begin),
(eq,"$caps_on",1),
(val_add,":val",10000),  ## When checking for caps, can test if the value is over 9999, then subtract 10000 from it to get just the value
(try_end),
(troop_set_slot, "trp_temp_array_b", "$str_len",":val"),
(val_add,"$str_len",1),
(call_script,"script_show_text_string"),
]
),
(0, 0, 0,[(key_clicked, key_w)],
[(assign,":val",key_w),
(try_begin),
(eq,"$caps_on",1),
(val_add,":val",10000),  ## When checking for caps, can test if the value is over 9999, then subtract 10000 from it to get just the value
(try_end),
(troop_set_slot, "trp_temp_array_b", "$str_len",":val"),
(val_add,"$str_len",1),
(call_script,"script_show_text_string"),
]
),
(0, 0, 0,[(key_clicked, key_x)],
[(assign,":val",key_x),
(try_begin),
(eq,"$caps_on",1),
(val_add,":val",10000),  ## When checking for caps, can test if the value is over 9999, then subtract 10000 from it to get just the value
(try_end),
(troop_set_slot, "trp_temp_array_b", "$str_len",":val"),
(val_add,"$str_len",1),
(call_script,"script_show_text_string"),
]
),
(0, 0, 0,[(key_clicked, key_y)],
[(assign,":val",key_y),
(try_begin),
(eq,"$caps_on",1),
(val_add,":val",10000),  ## When checking for caps, can test if the value is over 9999, then subtract 10000 from it to get just the value
(try_end),
(troop_set_slot, "trp_temp_array_b", "$str_len",":val"),
(val_add,"$str_len",1),
(call_script,"script_show_text_string"),
]
),
(0, 0, 0,[(key_clicked, key_z)],
[(assign,":val",key_z),
(try_begin),
(eq,"$caps_on",1),
(val_add,":val",10000),  ## When checking for caps, can test if the value is over 9999, then subtract 10000 from it to get just the value
(try_end),
(troop_set_slot, "trp_temp_array_b", "$str_len",":val"),
(val_add,"$str_len",1),
(call_script,"script_show_text_string"),
]
),



],

),


This script will convert the key strokes to the text string s10.  You still need to, at the end of the process, dump the text of s10 into what ever you are renaming.
##script_show_text_string
##converts a string of key presses into a string s10
##Input : none
##Output: string to s10
("show_text_string",
[(str_clear,s10),
(assign,":acaps",0),
######Test Max of 25 Chars
(try_begin),
(eq,"$str_len",25),
(display_message,"@MAXIMUM 25 characters.  The last character was not recorded",0xff8800),\
(val_sub,"$str_len",1),
(try_end),
######Test end
(assign,":endcount","$str_len"),
(try_for_range,":mad:count",0,":endcount"),
(troop_get_slot,reg1,"trp_temp_array_b", ":mad:count"),
(assign,":acaps",0), 
######Test CAPS
(try_begin),
(gt,reg1,10000),  ##capital letter here
(assign,":acaps",1),
(val_sub,reg1,10000),
(try_end),
######Test end
(try_begin),
(eq,reg1,key_space),
(str_store_string,s10,"@{s10} "),
(else_try),
(eq,reg1,key_1),
(str_store_string,s10,"@{s10}1"),
(else_try),
(eq,reg1,key_2),
(str_store_string,s10,"@{s10}2"),
(else_try),
(eq,reg1,key_3),
(str_store_string,s10,"@{s10}3"),
(else_try),
(eq,reg1,key_4),
(str_store_string,s10,"@{s10}4"),
(else_try),
(eq,reg1,key_5),
(str_store_string,s10,"@{s10}5"),
(else_try),
(eq,reg1,key_6),
(str_store_string,s10,"@{s10}6"),
(else_try),
(eq,reg1,key_7),
(str_store_string,s10,"@{s10}7"),
(else_try),
(eq,reg1,key_:cool:,
(str_store_string,s10,"@{s10}8"),
(else_try),
(eq,reg1,key_9),
(str_store_string,s10,"@{s10}9"),
(else_try),
(eq,reg1,key_0),
(str_store_string,s10,"@{s10}0"),
(else_try),
(eq,reg1,key_a),
(try_begin),
(eq,":acaps",1),
(str_store_string,s10,"@{s10}A"),
(else_try),
(eq,":acaps",0),
(str_store_string,s10,"@{s10}a"),
(try_end),
(else_try),
(eq,reg1,key_b),
(try_begin),
(eq,":acaps",1),
(str_store_string,s10,"@{s10}B"),
(else_try),
(eq,":acaps",0),
(str_store_string,s10,"@{s10}b"),
(try_end),
(else_try),
(eq,reg1,key_c),
(try_begin),
(eq,":acaps",1),
(str_store_string,s10,"@{s10}C"),
(else_try),
(eq,":acaps",0),
(str_store_string,s10,"@{s10}c"),
(try_end),
(else_try),
(eq,reg1,key_d),
(try_begin),
(eq,":acaps",1),
(str_store_string,s10,"@{s10}D"),
(else_try),
(eq,":acaps",0),
(str_store_string,s10,"@{s10}d"),
(try_end),
(else_try),
(eq,reg1,key_e),
(try_begin),
(eq,":acaps",1),
(str_store_string,s10,"@{s10}E"),
(else_try),
(eq,":acaps",0),
(str_store_string,s10,"@{s10}e"),
(try_end),
(else_try),
(eq,reg1,key_f),
(try_begin),
(eq,":acaps",1),
(str_store_string,s10,"@{s10}F"),
(else_try),
(eq,":acaps",0),
(str_store_string,s10,"@{s10}F"),
(try_end),
(else_try),
(eq,reg1,key_g),
(try_begin),
(eq,":acaps",1),
(str_store_string,s10,"@{s10}G"),
(else_try),
(eq,":acaps",0),
(str_store_string,s10,"@{s10}g"),
(try_end),
(else_try),
(eq,reg1,key_h),
(try_begin),
(eq,":acaps",1),
(str_store_string,s10,"@{s10}H"),
(else_try),
(eq,":acaps",0),
(str_store_string,s10,"@{s10}h"),
(try_end),
(else_try),
(eq,reg1,key_i),
(try_begin),
(eq,":acaps",1),
(str_store_string,s10,"@{s10}I"),
(else_try),
(eq,":acaps",0),
(str_store_string,s10,"@{s10}i"),
(try_end),
(else_try),
(eq,reg1,key_j),
(try_begin),
(eq,":acaps",1),
(str_store_string,s10,"@{s10}J"),
(else_try),
(eq,":acaps",0),
(str_store_string,s10,"@{s10}j"),
(try_end),
(else_try),
(eq,reg1,key_k),
(try_begin),
(eq,":acaps",1),
(str_store_string,s10,"@{s10}K"),
(else_try),
(eq,":acaps",0),
(str_store_string,s10,"@{s10}k"),
(try_end),
(else_try),
(eq,reg1,key_l),
(try_begin),
(eq,":acaps",1),
(str_store_string,s10,"@{s10}L"),
(else_try),
(eq,":acaps",0),
(str_store_string,s10,"@{s10}l"),
(try_end),
(else_try),
(eq,reg1,key_m),
(try_begin),
(eq,":acaps",1),
(str_store_string,s10,"@{s10}M"),
(else_try),
(eq,":acaps",0),
(str_store_string,s10,"@{s10}m"),
(try_end),
(else_try),
(eq,reg1,key_n),
(try_begin),
(eq,":acaps",1),
(str_store_string,s10,"@{s10}N"),
(else_try),
(eq,":acaps",0),
(str_store_string,s10,"@{s10}n"),
(try_end),
(else_try),
(eq,reg1,key_o),
(try_begin),
(eq,":acaps",1),
(str_store_string,s10,"@{s10}O"),
(else_try),
(eq,":acaps",0),
(str_store_string,s10,"@{s10}o"),
(try_end),
(else_try),
(eq,reg1,key_p),
(try_begin),
(eq,":acaps",1),
(str_store_string,s10,"@{s10}P"),
(else_try),
(eq,":acaps",0),
(str_store_string,s10,"@{s10}p"),
(try_end),
(else_try),
(eq,reg1,key_q),
(try_begin),
(eq,":acaps",1),
(str_store_string,s10,"@{s10}Q"),
(else_try),
(eq,":acaps",0),
(str_store_string,s10,"@{s10}q"),
(try_end),
(else_try),
(eq,reg1,key_r),
(try_begin),
(eq,":acaps",1),
(str_store_string,s10,"@{s10}R"),
(else_try),
(eq,":acaps",0),
(str_store_string,s10,"@{s10}r"),
(try_end),
(else_try),
(eq,reg1,key_s),
(try_begin),
(eq,":acaps",1),
(str_store_string,s10,"@{s10}S"),
(else_try),
(eq,":acaps",0),
(str_store_string,s10,"@{s10}s"),
(try_end),
(else_try),
(eq,reg1,key_t),
(try_begin),
(eq,":acaps",1),
(str_store_string,s10,"@{s10}T"),
(else_try),
(eq,":acaps",0),
(str_store_string,s10,"@{s10}t"),
(try_end),
(else_try),
(eq,reg1,key_u),
(try_begin),
(eq,":acaps",1),
(str_store_string,s10,"@{s10}U"),
(else_try),
(eq,":acaps",0),
(str_store_string,s10,"@{s10}u"),
(try_end),
(else_try),
(eq,reg1,key_v),
(try_begin),
(eq,":acaps",1),
(str_store_string,s10,"@{s10}V"),
(else_try),
(eq,":acaps",0),
(str_store_string,s10,"@{s10}v"),
(try_end),
(else_try),
(eq,reg1,key_w),
(try_begin),
(eq,":acaps",1),
(str_store_string,s10,"@{s10}W"),
(else_try),
(eq,":acaps",0),
(str_store_string,s10,"@{s10}w"),
(try_end),
(else_try),
(eq,reg1,key_x),
(try_begin),
(eq,":acaps",1),
(str_store_string,s10,"@{s10}X"),
(else_try),
(eq,":acaps",0),
(str_store_string,s10,"@{s10}x"),
(try_end),
(else_try),
(eq,reg1,key_y),
(try_begin),
(eq,":acaps",1),
(str_store_string,s10,"@{s10}Y"),
(else_try),
(eq,":acaps",0),
(str_store_string,s10,"@{s10}y"),
(try_end),
(else_try),
(eq,reg1,key_z),
(try_begin),
(eq,":acaps",1),
(str_store_string,s10,"@{s10}Z"),
(else_try),
(eq,":acaps",0),
(str_store_string,s10,"@{s10}z"),
(try_end),
(try_end),
(try_end),
(display_message,"@the string is now:"),
(display_message,"@{s10}",0xfff000),
(assign, "$caps_on",0),  ##Turn caps off after each letter
]
),

This is the dialog for the dialog box that tells the player how it works.  I put this at the bottom of module_stirngs.py:
("texttype_mission_info","JIK's in game Text typer.  Maximum 25 Characters.\
  ^In this scene you can type in letters (and spaces) to add to the string s10.\
  ^Press either shift key to toggle caps lock,^Press Delete key to erase the string\
  ^Press ENTER to display the current string. ^^ Press TAB to exit.\
  ^==Make sure to assign s10 to the item to be named at the end of this process=="
),



This is far from complete (as in v0.2), but I did most of the grunt work (adding in all the letters both caps on and off).  This is in hopes that we can rename certian aspects of the game.  I have heard that we can re-name towns, but I would like to use it to name offspring in my mod, as well as founded villiages and the like.

I used hareck in my tutorial to call it up with this dialog option:
  [trp_hareck|plyr,"hareck_talk", [], "I wish to type a name", "close_window",
[
    (set_visitor, 0, "trp_player"),
    (set_visitor, 1, "$g_talk_troop"),
    (set_jump_mission, "mt_type_out_words"),
    (jump_to_scene, "scn_town_1_arena"),
]
  ],

One more note to add.  This is a presentation version of kit (on the second page of this thread).  I'll link it here, so it doesn't get lost:
http://forums.taleworlds.com/index.php/topic,57775.msg1503015.html#msg1503015



(SIDE NOTE: in adding the string at the bottom, I noticed that I made the credits in the feedback section..  Woo hoo!)
 
cool! this is a somewhat more elegant way of (re)naming things than the way some mods use now, like say Chronicles of Talera, where you have to rename your character and use that to name your party with.

So I guess down the line in your mod we'll be able to use this to name the new baby we just made with the new bride, huh? :smile:


[edit]

Ok just tested this. I'm calling it from a game menu instead of dialog, but it works the same. Using this code btw if anyone wants to do it that way:

Code:
	("camp_string_typer",
		[],
		"type a string using jik's string typer.",
		[
			(set_visitor, 0, "trp_player"),
			(set_visitor, 1, "$g_talk_troop"),
			(set_jump_mission, "mt_type_out_words"),
			(jump_to_scene, "scn_town_1_arena"),
			(change_screen_mission),
		]
	),

This is in the camp menu as I use that for all my mod test thingies.

Anyway, it seems to work fine, except that when I press 'a', it comes up as 'af'. Now I've looked at the code and there's no reason it should do that, yet it does...

Another strange thing is that the dialog doesn't appear for me the first time, but it does the second time. Again, no idea why atm <- this problem has gone now, must've been some weird coincidence or freak occurence in mnb.

Third thing is that I think you need to put code in so that p and q don't pop up the party and quest window, since they do that for me now. I saw it earlier today, there's an operation or something for it but I can't find it atm.

I don't think any of these bugs should be related to me starting the mission from a menu instead of a dialog, but either way they should be looked at I guess. I'll try and find that key thingie

[edit2]
guess what I saw was 'mnf_enable_hot_keys' which does the exact opposite. Having tried several different solutions to no avail, I'm not sure how to tackle this one. I trief using different mtef flags, figuring the settings might be hardcoded but that did nothing. I also noticed that when in battle, you can't use p, but you can still use l and q.

[edit3] I guess I checked the code with my eyes closed. It says:

Code:
     

  (0, 0, 0,[(key_clicked, key_a)],
         [(try_begin),
            (eq,"$caps_on",1),
            (str_store_string, s10, "@{s10}F"),
          (else_try),
            (str_store_string, s10, "@{s10}f"),
          (try_end),

Which is why 'a' comes up as 'af' and the 'f' key does nothing.
 
Great!

I have some suggestions.

Probably it is better to use presentations. They can be run from menu directly or form mission by hotkey, without starting new mission, and I think it will be faster. Presentations also have triggers, so the main part of code doesn't change.

Another thing about deletion.
I think that  deletion can be handled in the following way.
It is possible to use each string register for 1 character.
So there should  be variable “:num_of_chars”
If player input 5 characters, “:num_of_chars” should be  set to 5 and overall string should be build as
...
(else_try)
(eq,“:num_of_chars”,5),
(display_message,”@{s1}{s2}{s3}{s4}{s5}”),
...
then if  player push backspace “:num_of_chars” should be  set to 4 and overall string should be build as
...
(else_try)
(eq,“:num_of_chars”,4),
(display_message,”@{s1}{s2}{s3}{s4}”),
...

Number of registers is limited by 64 thus we have limited size of input, but 64 charactes will be enough for many purposes.
But of course such realization requires a lot of typing.
 
Rongar said:
Great!

I have some suggestions.

Probably it is better to use presentations. They can be run from menu directly or form mission by hotkey, without starting new mission, and I think it will be faster. Presentations also have triggers, so the main part of code doesn't change.

As brilliant as this suggestion is, I'm not sure it will work. In presentations, you can only use simple triggers, this seems to be limited to the ti_on_presentation_begin and such. I tried using the (0,0,0 []) type triggers but they won't compile.

 
When I originally suggested this method of string entry I didn't think anyone would actually try to implement it.

Pretty sure you need to do it in a mission template to get the key triggers to work properly.  A whole bunch of eq statements tracking the length of the string would be a horribly frustrating thing to type out.  Instead, track the length of what has been typed, as suggested, but instead of storing everything in individual string registries, store the key values in temp_troop_array while building the single string register as it is now.  Then, when the backspace key is pressed, subtract one from the length, delete the last entry in the temp array, then use the temp array to rebuild the string from scratch since it has a record of every key press.  Then continue on as normal.  You could probably use a presentation in combination with the mission_template to make the interface look a little nicer, but I would only worry about that after everything else is done...
 
MartinF said:
In presentations, you can only use simple triggers, this seems to be limited to the ti_on_presentation_begin and such. I tried using the (0,0,0 []) type triggers but they won't compile.
The only real advantage of non simple triggers are delays (before action, before next activation). And It is not important here.

Construction like
Code:
      (ti_on_presentation_run,
       [
(try_begin),
          (key_clicked, key_a),
...
(else_try)
          (key_clicked, key_b),
...
(else_try)
...
(try_end),


        ]),
will work.

For instance, in the same way tactics mode is suspended in native.

But yes, I was wrong about coding. It is required total retyping.
 
:oops: :oops: :oops: :oops:
Didn't get around to testing specific letters...  Fixed the a as af though.

I Have yet to play with the presentation screen, nor have I realy though how to manage the string deletion.
the first option by Rongar would work if I could dynamically name the string regs
var char_num = 1 

get_input key
store_string,s[char_num],"@a"

if that was the case, it wouldn't be so bad, but I doubt it.

As to Jinnai's idea, sounds good since you can access the items in the array by array number, though I have never done that (or seen it) with M&B.  Do you have an example of where this is done in native?

Also, how do we get around the I or P keys being pressed in the mission.  Is that hard coded?  C works fine and doesn't bring up the character screen, which is why I thought it was ok...
[EDIT]

Ok, tried it with presentations, and it's not working.  Here's the basic code:
("presentation_typing",0,mesh_load_window,
[(ti_on_presentation_load,
[(str_clear,s10),
(assign,"$caps_on",0)
]
),
(ti_on_presentation_run,
[(try_begin),
(key_clicked, key_1),
(try_begin),
(eq,"$caps_on",1),
(assign,"$caps_on",0),
(else_try),
(assign,"$caps_on",1),
(try_end),
(else_try),
(key_clicked, key_a),
(try_begin),
(eq,"$caps_on",1),
(str_store_string, s10, "@{s10}A"),
(else_try),
(str_store_string, s10, "@{s10}a"),
(try_end),
(assign,"$caps_on",0),
(display_message, "@Current string is {s10}"),
(else_try),
(key_clicked, key_p),
(try_begin),
(eq,"$caps_on",1),
(str_store_string, s10, "@{s10}P"),
(else_try),
(str_store_string, s10, "@{s10}p"),
(try_end),
(assign,"$caps_on",0),
(display_message, "@Current string is {s10}"),
(else_try),
(key_clicked, key_enter),
(display_message, "@The final string is {s10}"),
(assign,"$caps_on",0),
(presentation_set_duration, 0),  ## End presentation
(try_end),
]
),
]
),

Basically just testing any letter (a) and one that has a current setting (p).  Bad news is that p still goes to the party window, even from a presentation.

Right now, and I'm not sure why, when I start the mission, I get just a grey screen.  Can't do anything, so it works for what I want to do.  Am trying to re-write it with Jinnai's idea... BTW it's trp_temp_array_a or b...  ummm..  which to use?  Are they used for something specific?
 
They're temp arrays, use em for whatever you want.  If you want examples, take a look at the code for castle_meeting in game_menus.  For an example of how to handle the inventory key press in mission templates, look at common_battle_inventory in mission_templates.  Not sure how it would be handled in presentations...  I'm not sure about the party key, as some missions it seems to work, but others (like when fighting castle defenders that sally out) it doesn't.  Not sure, but it might be linked to mtf_battle_mode?  Haven't tested that.
 
cool.  I think I might have to make a seperate script that feeds back what you have typed, since it doesn't look as easy as it is with playing with s10.  Or maybe I can still store it in both, but go back the the trp_temp_array when the backspace is used...  Ok... have an idea and going with it...

[EDIT]

Quick question... I assume that text can be stored in the arrays, but do I have to move them to a registry in order to then put them into a string registry?  how much processing can the {} handle?
 
ok, double post, but I'm about to leave work, and I almost have it... here's the new key trigger:

(0, 0, 0,[(key_clicked, key_a)],
[(try_begin),
(eq,"$caps_on",1),
#(str_store_string, s10, "@{s10}A"),
(troop_set_slot, "trp_temp_array_b", "$str_len","@A"),
(else_try),
#(str_store_string, s10, "@{s10}a"),
(troop_set_slot, "trp_temp_array_b", "$str_len","@a"),
(try_end),
(val_add,"$str_len",1),      ##increment the number of chars in the string
(call_script,"script_array_2_s10"),
#(display_message, "@Current string is {s10}")
]
),
#

Here is the script:
# JIK's script to move text from trp_temp_array_b into s10
# input: none, $str_len is global
# output: the string into s10
("array_2_s10",
[(str_clear,s10),
(try_for_range,":len_count",1,"$str_len"),
(troop_get_slot,reg10,"trp_temp_array_b",":len_count"),
(str_store_string, s10, "@{s10}{reg10}"),
(try_end),
(display_message, "@Current string is {s10}"),
]
),

My problem...  it looks like when I put the value into either the array or the reg10, it turns it into a number.  Other then that it works...  :oops:  Have set up the back_space as well (simple val_sub...) so if I can only get it to see letters I'm golded (besides the P key...)
 
Just added this to my mod for when a player chooses to change their kingdom's name. Works very well. I set it up through the camp menu instead of a dialogue so that when the player chooses to enter a name, they are taken to the camp scene. I'm eventually going to make different camp scenes based on the current terrain, but for now it is just plains with a campfire and some rocks. When I'm bored enough I'm going to customize it some more with props that would make sense to find at a temporary campsite. But anyway....yeah

I added the lines in blue to module_game_menus (modifying Highlander's Kingdom Management script):
#Own kingdom start------------------------------
  ("own_kingdom",0,
  "Choose an action:",
  "none",
  [
    ],
    [
      ("change_kingdom_name",
      [],"Change your kingdom's name.",
      [
  (str_store_faction_name,s22,"fac_player_supporters_faction"),
      (jump_to_menu,"mnu_change_kingdom_name"),
      ]),

  ("recruit_lords",
      [
      (assign,":num_lords",0),
      (try_for_range,":lord","trp_reserved_knight_1","trp_kingdom_1_pretender"),
        (troop_slot_eq, ":lord", slot_troop_occupation, slto_kingdom_hero),
        (val_add,":num_lords",1),
      (try_end),
      (assign,reg1,":num_lords"),
And then added this sub-menu:
  ("change_kingdom_name",0,
  "Current kingdom name: {s22}\
^Name you are considering: {s21}\
^If you want to change your kingdom's name, you will first need to enter the camp scene.\
^In this scene, you will type in the new name. Only letters and spaces will work.\
^You can press '1' to turn on CAPS Lock, and press ENTER to finish and exit the scene.\
^Then you will return to this menu where you can choose to change the name to what you entered,\
^or you can choose to enter a different name.",
  "none",
  [],
    [
      ("enter_name",[],"I want to enter a new name now.",
      [
        (set_visitor, 0, "trp_player"),
        (set_visitor, 1, "$g_talk_troop"),
        (set_jump_mission, "mt_type_out_words"),
        (jump_to_scene, "scn_camp_scene"),
        (change_screen_mission),
        ]
      ),
      ("change_name",[], "I want to change my kingdom's name now.",
      [
    (faction_set_name, "fac_player_supporters_faction", "@{s21}"),
    (jump_to_menu, "mnu_own_kingdom"),
        ]
      ),
      ("return",[], "I do not want to change my kingdom's name at this time.",
      [(jump_to_menu, "mnu_own_kingdom"),
        ]
      ),
      ]
  ),
The only thing I changed about the module_mission_templates part was I changed s10 to s21, since when it was s10, after I conquered my first center to start my kingdom, when I went into the camp menu to change my kingdom's name, s10 was already something like "You have entered Senuzgda Castle". It seems s10 is used in multiple places in dialogues and game menus to refer to the current center you are in.
 
You're almost there.  You can't store strings in slots though, so what I meant was to store the value of the key that was pressed.  Think of it like hitting record on a VCR.  Then when the player hits backspace, just go back to the start, and play through the recording minus the last keypress entered.  If that makes sense.
 
I fixed that and have it clear when the mission starts.  Still trying to figure out the array>reg>string thing.  I'm making some other changes that will hopefully make it better.  Still can't get around the P key..


Jinnai, that makes sense, but I'm not sure how to code that.  What if the same key is pressed twice?  Would this cause a hic-up?  The only other thing to do is to convert the char number back to a char with another script...

[EDIT]
thinking this over again, I'm still not sure how this would work.  even if you store which keys are pressed, you still have to convert them back into a string char, unless you can reference the key stroke id from the int stored in the array...  Any way I look at it, I have to define the letters twice.  Once for the key stroke, and once for the script to convert the numbers to actual letters. 

Can you give an example of how you would code that Jinnai?  This would also give problems with Uppercase letters, as they are not coded differently... unless you record the caps, which should be changed from a toggle to just making the next character Uppercase.  Getting complex...  I think I'll just go old school and map out the int values of the letters in the script....
 
Yes, you would have to check the keys twice.  Once, like you do in the mission triggers, and then I would write a script to do it the second time for when backspace is pressed.  Right now if key_a is pressed, you try to store "@a" in the slot, which will not work.  But you could store key_a in it.  key_a is just a constant that is associated with the a key being pressed.  You would need to do something to track if shift is pressed for caps.  So you could change your set_slot to:

Code:
(0, 0, 0,[(key_clicked, key_a)],
         [(assign,":val",key_a),
          (try_begin),
            (eq,"$caps_on",1),
            (val_add,":val",10000),
          (try_end),
          (troop_set_slot, "trp_temp_array_b", "$str_len",":val"),
          (val_add,"$str_len",1),
          Put whatever code you have to build your string here.
         ]
       ),

Then when backspace is pressed you call a script that does something like:

Code:
(str_clear_string,s1), # Change s1 in this whole thing to whatever string you use to store the compiled string
(val_sub,"$str_len",1),
(try_for_range,":index",0,"$str_len"),
  (troop_get_slot,":combined_char","trp_temp_array_b",":index"),
  (store_div,":shift",":combined_char",10000),
  (try_begin),
    (eq,":shift",1),
    (store_sub,":char",":combined_char",10000),
  (else_try),
    (assign,":char",":combined_char"),
  (try_end),
  (try_begin),
    (eq,":char",key_a),
    (try_begin),
      (eq,":shift",1),
      (str_store_string,s1,"@{s1}A"),
    (else_try),
      (str_store_string,s1,"@{s1}a"),
    (try_end),
  (else_try),
    (eq,":char",key_b),
    (try_begin),
      (eq,":shift",1),
      (str_store_string,s1,"@{s1}B"),
    (else_try),
      (str_store_string,s1,"@{s1}b"),
    (try_end),
  (else_try),
     etc. etc. etc. fill it all in for each key again.
  (try_end),
(try_end),

At least, I think that would work.

EDIT: Moved the val_sub to the start because I always forget things start with 0 rather than 1.  Now it should work properly.

EDIT AGAIN: I'm an idiot, the mod was supposed to be a div.  We want what's on the left of the decimal, not the right.  Oops.
 
Jinnai said:
For an example of how to handle the inventory key press in mission templates, look at common_battle_inventory in mission_templates.  Not sure how it would be handled in presentations...  I'm not sure about the party key, as some missions it seems to work, but others (like when fighting castle defenders that sally out) it doesn't.  Not sure, but it might be linked to mtf_battle_mode?  Haven't tested that.

I tried that quickly yesterday and it didn't seem to make much difference. Either way, the most positive scenario seems to be the one where party screen doesn't work, but quest and log will still work since they work anywhere in the game (as far as I can tell).

Must be some way around that..... maybe something in the trigger that closes the menu
 
Jinnai said:
For an example of how to handle the inventory key press in mission templates, look at common_battle_inventory in mission_templates.  Not sure how it would be handled in presentations...  I'm not sure about the party key, as some missions it seems to work, but others (like when fighting castle defenders that sally out) it doesn't. 
Then a presentation is called from menu, hotkeys are blocked in it.

Afaik in campaign missions (in quick battles all hotkeys block, but it seems it is hardcoded) only inventory can be blocked  (just set mtf_battle_mode and no additional triggers are required). A presentation called from a mission have the same behavior as a mission. 
 
Jinnai said:
...
EDIT AGAIN: I'm an idiot, the mod was supposed to be a div.  We want what's on the left of the decimal, not the right.  Oops.

Are you sure you didn't want to sub 10000?  If you add that much on, shouldn't you subtract the same amount to get the initial value?

Rongar, so you have this working from a presentation?  I tried it when you first suggested it, but I could not get it to work at all (even with the old basic code).
 
jik: Positive.  The 10000 is added as a flag that a capital letter should be used.  So in the replay, divide by 10000 and if you get a 1, the flag is there and we DO subtract 10000.  If we don't get a 1 (ie, a 0) then the flag is not there and there's no need to subtract 10000 because it wasn't added in the first place.
 
> so you have this working from a presentation?
Does this mean your string typer?
No, I do not.
I just have another presentation at hand to test.
But maybe I'll post here some code a bit later. 
 
Jinnai said:
jik: Positive.  The 10000 is added as a flag that a capital letter should be used.  So in the replay, divide by 10000 and if you get a 1, the flag is there and we DO subtract 10000.  If we don't get a 1 (ie, a 0) then the flag is not there and there's no need to subtract 10000 because it wasn't added in the first place.

Why not just test if it is ge 10000?  anyway, going throught this now as one last test.
 
Back
Top Bottom