Kahsm
Recruit

I was just quickly wondering if there was a way to use loops to make dynamic menu lengths. Considering the conditionals for the menu items are contained in the item, it seems you have to pre-define all the possible options. So I'm guessing the answer is "no", but I thought I'd make sure there were no snazzy tricks.
Just so you know what I'm talking about, if I were making an NPC who could teleport the player to all cities with a reputation over 20 (the reputation is relative to the city the player is in, not the player himself). I would talk to the npc and he'd offer a list of target cities that fit the following criteria:
1. It's not the current city
2. Has a reputation of at least 20 with the town the player is in
This list could be any number of cities long, from 1 up to however many towns I have in my game (22). But if I added more towns, I wouldn't want to have to find all my dynamic lists and add more menu options. The only quick hack I could think of was to use the town_begin and town_end constants and an iterating variable in a register to count how many cities I've already looped through, then add a bunch of extra placeholders (up to 25 in my example).
I end up with some extremely ugly code like this:
(I would probably add some sort of "fight your way out", if you used a friendly city teleporter to enter an unfriendly city. Probably piss off your ally for pissing off their ally too.)
Just so you know what I'm talking about, if I were making an NPC who could teleport the player to all cities with a reputation over 20 (the reputation is relative to the city the player is in, not the player himself). I would talk to the npc and he'd offer a list of target cities that fit the following criteria:
1. It's not the current city
2. Has a reputation of at least 20 with the town the player is in
This list could be any number of cities long, from 1 up to however many towns I have in my game (22). But if I added more towns, I wouldn't want to have to find all my dynamic lists and add more menu options. The only quick hack I could think of was to use the town_begin and town_end constants and an iterating variable in a register to count how many cities I've already looped through, then add a bunch of extra placeholders (up to 25 in my example).
I end up with some extremely ugly code like this:
插入代码块:
[trp_town_1_traveller, "start", [], "Welcome back {playername}.", "choose_gateway_location", []],
[trp_town_1_traveller, "choose_gateway_location", [(assign,reg1,towns_begin),(assign,reg2,20)], # 20 defined as minimum relation between city's factions.
"So, where do you wish to gate to?", "choose_gateway_location_opt",[(assign,reg1,towns_begin)]],
[trp_town_1_traveller|plyr, "choose_gateway_location_opt", [(assign,":iter_town",reg1),(val_add,reg1,1),(is_between,":iter_town",towns_begin,towns_end),(call_script,"script_get_relation_between_parties","$current_town",":iter_town"),(ge,reg0,reg2),(neq,"$current_town",":iter_town"),(str_store_party_name, s1, ":iter_town")], "Take me to {s1} ({reg0})", "close_window", []], #1
[trp_town_1_traveller|plyr, "choose_gateway_location_opt", [(assign,":iter_town",reg1),(val_add,reg1,1),(is_between,":iter_town",towns_begin,towns_end),(call_script,"script_get_relation_between_parties","$current_town",":iter_town"),(ge,reg0,reg2),(neq,"$current_town",":iter_town"),(str_store_party_name, s1, ":iter_town")], "Take me to {s1} ({reg0})", "close_window", []], #2
[trp_town_1_traveller|plyr, "choose_gateway_location_opt", [(assign,":iter_town",reg1),(val_add,reg1,1),(is_between,":iter_town",towns_begin,towns_end),(call_script,"script_get_relation_between_parties","$current_town",":iter_town"),(ge,reg0,reg2),(neq,"$current_town",":iter_town"),(str_store_party_name, s1, ":iter_town")], "Take me to {s1} ({reg0})", "close_window", []], #3
[trp_town_1_traveller|plyr, "choose_gateway_location_opt", [(assign,":iter_town",reg1),(val_add,reg1,1),(is_between,":iter_town",towns_begin,towns_end),(call_script,"script_get_relation_between_parties","$current_town",":iter_town"),(ge,reg0,reg2),(neq,"$current_town",":iter_town"),(str_store_party_name, s1, ":iter_town")], "Take me to {s1} ({reg0})", "close_window", []], #4
[trp_town_1_traveller|plyr, "choose_gateway_location_opt", [(assign,":iter_town",reg1),(val_add,reg1,1),(is_between,":iter_town",towns_begin,towns_end),(call_script,"script_get_relation_between_parties","$current_town",":iter_town"),(ge,reg0,reg2),(neq,"$current_town",":iter_town"),(str_store_party_name, s1, ":iter_town")], "Take me to {s1} ({reg0})", "close_window", []], #5
[trp_town_1_traveller|plyr, "choose_gateway_location_opt", [(assign,":iter_town",reg1),(val_add,reg1,1),(is_between,":iter_town",towns_begin,towns_end),(call_script,"script_get_relation_between_parties","$current_town",":iter_town"),(ge,reg0,reg2),(neq,"$current_town",":iter_town"),(str_store_party_name, s1, ":iter_town")], "Take me to {s1} ({reg0})", "close_window", []], #6
[trp_town_1_traveller|plyr, "choose_gateway_location_opt", [(assign,":iter_town",reg1),(val_add,reg1,1),(is_between,":iter_town",towns_begin,towns_end),(call_script,"script_get_relation_between_parties","$current_town",":iter_town"),(ge,reg0,reg2),(neq,"$current_town",":iter_town"),(str_store_party_name, s1, ":iter_town")], "Take me to {s1} ({reg0})", "close_window", []], #7
[trp_town_1_traveller|plyr, "choose_gateway_location_opt", [(assign,":iter_town",reg1),(val_add,reg1,1),(is_between,":iter_town",towns_begin,towns_end),(call_script,"script_get_relation_between_parties","$current_town",":iter_town"),(ge,reg0,reg2),(neq,"$current_town",":iter_town"),(str_store_party_name, s1, ":iter_town")], "Take me to {s1} ({reg0})", "close_window", []], #8
[trp_town_1_traveller|plyr, "choose_gateway_location_opt", [(assign,":iter_town",reg1),(val_add,reg1,1),(is_between,":iter_town",towns_begin,towns_end),(call_script,"script_get_relation_between_parties","$current_town",":iter_town"),(ge,reg0,reg2),(neq,"$current_town",":iter_town"),(str_store_party_name, s1, ":iter_town")], "Take me to {s1} ({reg0})", "close_window", []], #9
[trp_town_1_traveller|plyr, "choose_gateway_location_opt", [(assign,":iter_town",reg1),(val_add,reg1,1),(is_between,":iter_town",towns_begin,towns_end),(call_script,"script_get_relation_between_parties","$current_town",":iter_town"),(ge,reg0,reg2),(neq,"$current_town",":iter_town"),(str_store_party_name, s1, ":iter_town")], "Take me to {s1} ({reg0})", "close_window", []], #10
[trp_town_1_traveller|plyr, "choose_gateway_location_opt", [(assign,":iter_town",reg1),(val_add,reg1,1),(is_between,":iter_town",towns_begin,towns_end),(call_script,"script_get_relation_between_parties","$current_town",":iter_town"),(ge,reg0,reg2),(neq,"$current_town",":iter_town"),(str_store_party_name, s1, ":iter_town")], "Take me to {s1} ({reg0})", "close_window", []], #11
[trp_town_1_traveller|plyr, "choose_gateway_location_opt", [(assign,":iter_town",reg1),(val_add,reg1,1),(is_between,":iter_town",towns_begin,towns_end),(call_script,"script_get_relation_between_parties","$current_town",":iter_town"),(ge,reg0,reg2),(neq,"$current_town",":iter_town"),(str_store_party_name, s1, ":iter_town")], "Take me to {s1} ({reg0})", "close_window", []], #12
[trp_town_1_traveller|plyr, "choose_gateway_location_opt", [(assign,":iter_town",reg1),(val_add,reg1,1),(is_between,":iter_town",towns_begin,towns_end),(call_script,"script_get_relation_between_parties","$current_town",":iter_town"),(ge,reg0,reg2),(neq,"$current_town",":iter_town"),(str_store_party_name, s1, ":iter_town")], "Take me to {s1} ({reg0})", "close_window", []], #13
[trp_town_1_traveller|plyr, "choose_gateway_location_opt", [(assign,":iter_town",reg1),(val_add,reg1,1),(is_between,":iter_town",towns_begin,towns_end),(call_script,"script_get_relation_between_parties","$current_town",":iter_town"),(ge,reg0,reg2),(neq,"$current_town",":iter_town"),(str_store_party_name, s1, ":iter_town")], "Take me to {s1} ({reg0})", "close_window", []], #14
[trp_town_1_traveller|plyr, "choose_gateway_location_opt", [(assign,":iter_town",reg1),(val_add,reg1,1),(is_between,":iter_town",towns_begin,towns_end),(call_script,"script_get_relation_between_parties","$current_town",":iter_town"),(ge,reg0,reg2),(neq,"$current_town",":iter_town"),(str_store_party_name, s1, ":iter_town")], "Take me to {s1} ({reg0})", "close_window", []], #15
[trp_town_1_traveller|plyr, "choose_gateway_location_opt", [(assign,":iter_town",reg1),(val_add,reg1,1),(is_between,":iter_town",towns_begin,towns_end),(call_script,"script_get_relation_between_parties","$current_town",":iter_town"),(ge,reg0,reg2),(neq,"$current_town",":iter_town"),(str_store_party_name, s1, ":iter_town")], "Take me to {s1} ({reg0})", "close_window", []], #16
[trp_town_1_traveller|plyr, "choose_gateway_location_opt", [(assign,":iter_town",reg1),(val_add,reg1,1),(is_between,":iter_town",towns_begin,towns_end),(call_script,"script_get_relation_between_parties","$current_town",":iter_town"),(ge,reg0,reg2),(neq,"$current_town",":iter_town"),(str_store_party_name, s1, ":iter_town")], "Take me to {s1} ({reg0})", "close_window", []], #17
[trp_town_1_traveller|plyr, "choose_gateway_location_opt", [(assign,":iter_town",reg1),(val_add,reg1,1),(is_between,":iter_town",towns_begin,towns_end),(call_script,"script_get_relation_between_parties","$current_town",":iter_town"),(ge,reg0,reg2),(neq,"$current_town",":iter_town"),(str_store_party_name, s1, ":iter_town")], "Take me to {s1} ({reg0})", "close_window", []], #18
[trp_town_1_traveller|plyr, "choose_gateway_location_opt", [(assign,":iter_town",reg1),(val_add,reg1,1),(is_between,":iter_town",towns_begin,towns_end),(call_script,"script_get_relation_between_parties","$current_town",":iter_town"),(ge,reg0,reg2),(neq,"$current_town",":iter_town"),(str_store_party_name, s1, ":iter_town")], "Take me to {s1} ({reg0})", "close_window", []], #19
[trp_town_1_traveller|plyr, "choose_gateway_location_opt", [(assign,":iter_town",reg1),(val_add,reg1,1),(is_between,":iter_town",towns_begin,towns_end),(call_script,"script_get_relation_between_parties","$current_town",":iter_town"),(ge,reg0,reg2),(neq,"$current_town",":iter_town"),(str_store_party_name, s1, ":iter_town")], "Take me to {s1} ({reg0})", "close_window", []], #20
[trp_town_1_traveller|plyr, "choose_gateway_location_opt", [(assign,":iter_town",reg1),(val_add,reg1,1),(is_between,":iter_town",towns_begin,towns_end),(call_script,"script_get_relation_between_parties","$current_town",":iter_town"),(ge,reg0,reg2),(neq,"$current_town",":iter_town"),(str_store_party_name, s1, ":iter_town")], "Take me to {s1} ({reg0})", "close_window", []], #21
[trp_town_1_traveller|plyr, "choose_gateway_location_opt", [(assign,":iter_town",reg1),(val_add,reg1,1),(is_between,":iter_town",towns_begin,towns_end),(call_script,"script_get_relation_between_parties","$current_town",":iter_town"),(ge,reg0,reg2),(neq,"$current_town",":iter_town"),(str_store_party_name, s1, ":iter_town")], "Take me to {s1} ({reg0})", "close_window", []], #22
[trp_town_1_traveller|plyr, "choose_gateway_location_opt", [(assign,":iter_town",reg1),(val_add,reg1,1),(is_between,":iter_town",towns_begin,towns_end),(call_script,"script_get_relation_between_parties","$current_town",":iter_town"),(ge,reg0,reg2),(neq,"$current_town",":iter_town"),(str_store_party_name, s1, ":iter_town")], "Take me to {s1} ({reg0})", "close_window", []], #23
[trp_town_1_traveller|plyr, "choose_gateway_location_opt", [(assign,":iter_town",reg1),(val_add,reg1,1),(is_between,":iter_town",towns_begin,towns_end),(call_script,"script_get_relation_between_parties","$current_town",":iter_town"),(ge,reg0,reg2),(neq,"$current_town",":iter_town"),(str_store_party_name, s1, ":iter_town")], "Take me to {s1} ({reg0})", "close_window", []], #24
[trp_town_1_traveller|plyr, "choose_gateway_location_opt", [(assign,":iter_town",reg1),(val_add,reg1,1),(is_between,":iter_town",towns_begin,towns_end),(call_script,"script_get_relation_between_parties","$current_town",":iter_town"),(ge,reg0,reg2),(neq,"$current_town",":iter_town"),(str_store_party_name, s1, ":iter_town")], "Take me to {s1} ({reg0})", "close_window", []], #25
[trp_town_1_traveller|plyr, "choose_gateway_location_opt", [], "I'm fine where I am.", "close_window",[]],
(I would probably add some sort of "fight your way out", if you used a friendly city teleporter to enter an unfriendly city. Probably piss off your ally for pissing off their ally too.)

