|repeat_for_troops stuffed up in WB

正在查看此主题的用户

Thi is the first time that I have used any of the |repeat_for_... concepts. And I failed. I am trying to make it so that the repeat_for_troops only shows the troop stacks in the current center using the following code:
插入代码块:
  [anyone|plyr|repeat_for_troops, "companion_officer_task_train_2",
        [(store_repeat_object, ":troop"),
         (party_get_num_companion_stacks, ":no_stack", "$current_town"),
         (try_for_range, ":i_stack", 0, ":no_stack"),
             (party_stack_get_troop_id, ":stack_troop", "$current_town", ":i_stack"),
             (eq, ":stack_troop", ":troop"),
             (assign, ":continue", 1),
         (try_end),
         (eq, ":continue", 1),
         (str_store_troop_name_plural, s1, ":troop"),], 
"Train the {s1}", "companion_officer_task_train_accept",
        [(store_repeat_object, ":troop"),
         (party_set_slot, "$current_town", slot_town_train_troop, ":troop"),]],
Only problem is that it shows all the troops in the game. So I am clearly stuffing up somewhere. Help would be really apreciated. Thanks.
 
It's far better in this case to use repeat_for_100 to iterate through the stacks (each of which contains an unique entry) instead of repeating for every troop. As to where your code went wrong - you did not initialize the value of continue beforehand to 0.
 
后退
顶部 底部