Should I ignore "Use cf_ at the beginning" warning? What this warning message means?

Users who are viewing this thread

Hi i am modding warband using module system. For making the game more random and unique each new game, i started adding new random stuff to the "game_start" script. I just created a basic function that picks random lord from the specified faction and returns the lord's id as reg60. And then at the "game_start"
I used reg60 to assign centers to the random lords. When i compile it though:

Code:
Exporting info_page data...
Exporting scripts...
WARNING: Script can fail at operation #436. Use cf_ at the beginning of its name: game_start
WARNING: Script can fail at operation #438. Use cf_ at the beginning of its name: game_start
WARNING: Script can fail at operation #440. Use cf_ at the beginning of its name: game_start
WARNING: Script can fail at operation #443. Use cf_ at the beginning of its name: game_start
WARNING: Script can fail at operation #445. Use cf_ at the beginning of its name: game_start
WARNING: Script can fail at operation #447. Use cf_ at the beginning of its name: game_start
WARNING: Script can fail at operation #450. Use cf_ at the beginning of its name: game_start
WARNING: Script can fail at operation #452. Use cf_ at the beginning of its name: game_start
WARNING: Script can fail at operation #454. Use cf_ at the beginning of its name: game_start
WARNING: Script can fail at operation #457. Use cf_ at the beginning of its name: game_start
WARNING: Script can fail at operation #459. Use cf_ at the beginning of its name: game_start
WARNING: Script can fail at operation #462. Use cf_ at the beginning of its name: game_start
WARNING: Script can fail at operation #464. Use cf_ at the beginning of its name: game_start
WARNING: Script can fail at operation #467. Use cf_ at the beginning of its name: game_start
WARNING: Script can fail at operation #469. Use cf_ at the beginning of its name: game_start
WARNING: Script can fail at operation #471. Use cf_ at the beginning of its name: game_start
Exporting mission_template data...
Exporting game menus data...
exporting simple triggers...

I get these warnings. Other than that code works perfectly fine. The game loads and Count Fraichin had 2 Castles as intended. But the weird thing is as i read it from other forum posts, people say when a script named with "cf_" prefix, the game tries to expect an error. But my code works fine? Is my code vulnerable? If it is, how can i improve it? If these warnings are not dangerous should i ignore the warnings? Also the codes that i added:

Here is the "game_start" part:
Code:
...
      #Now give towns to random lords. (Except for capitals)
     
      # Praven / Capital
      (call_script, "script_give_center_to_lord", "p_town_6",  "trp_kingdom_1_lord", 0),
      (call_script, "script_cf_pick_random_lord", "fac_kingdom_1", 1, 21),
      (call_script, "script_give_center_to_lord", "p_town_4",  reg60, 0),
      (call_script, "script_cf_pick_random_lord", "fac_kingdom_1", 1, 21),
      (call_script, "script_give_center_to_lord", "p_town_7",  reg60, 0),
      (call_script, "script_cf_pick_random_lord", "fac_kingdom_1", 1, 21),
      (call_script, "script_give_center_to_lord", "p_town_16", reg60, 0),
     
      # Reyvadin / Capital
      (call_script, "script_give_center_to_lord", "p_town_8",  "trp_kingdom_2_lord", 0),
      (call_script, "script_cf_pick_random_lord", "fac_kingdom_2", 1, 21),
      (call_script, "script_give_center_to_lord", "p_town_9",  reg60, 0),
      (call_script, "script_cf_pick_random_lord", "fac_kingdom_2", 1, 21),
      (call_script, "script_give_center_to_lord", "p_town_11", reg60, 0),
      (call_script, "script_cf_pick_random_lord", "fac_kingdom_2", 1, 21),
      (call_script, "script_give_center_to_lord", "p_town_13", reg60, 0),
     
      # Tulga / Capital
      (call_script, "script_give_center_to_lord", "p_town_10", "trp_kingdom_3_lord", 0),
      (call_script, "script_cf_pick_random_lord", "fac_kingdom_3", 1, 21),
      (call_script, "script_give_center_to_lord", "p_town_14", reg60, 0),
      (call_script, "script_cf_pick_random_lord", "fac_kingdom_3", 1, 21),
      (call_script, "script_give_center_to_lord", "p_town_17", reg60, 0),
      (call_script, "script_cf_pick_random_lord", "fac_kingdom_3", 1, 21),
      (call_script, "script_give_center_to_lord", "p_town_18", reg60, 0),
     
      # Sargot / Capital
      (call_script, "script_give_center_to_lord", "p_town_1",  "trp_kingdom_4_lord", 0),
      (call_script, "script_cf_pick_random_lord", "fac_kingdom_4", 1, 21),
      (call_script, "script_give_center_to_lord", "p_town_2",  reg60, 0),
      (call_script, "script_cf_pick_random_lord", "fac_kingdom_4", 1, 21),
      (call_script, "script_give_center_to_lord", "p_town_12", reg60, 0),
     
      # Jelkala / Capital
      (call_script, "script_give_center_to_lord", "p_town_5",  "trp_kingdom_5_lord", 0),
      (call_script, "script_cf_pick_random_lord", "fac_kingdom_5", 1, 21),
      (call_script, "script_give_center_to_lord", "p_town_3",  reg60, 0),
      (call_script, "script_cf_pick_random_lord", "fac_kingdom_5", 1, 21),
      (call_script, "script_give_center_to_lord", "p_town_15", reg60, 0),
     
      # Shariz / Capital
      (call_script, "script_give_center_to_lord", "p_town_19", "trp_kingdom_6_lord", 0),
      (call_script, "script_cf_pick_random_lord", "fac_kingdom_6", 1, 21),
      (call_script, "script_give_center_to_lord", "p_town_20", reg60, 0),
      (call_script, "script_cf_pick_random_lord", "fac_kingdom_6", 1, 21),
      (call_script, "script_give_center_to_lord", "p_town_21", reg60, 0),
      (call_script, "script_cf_pick_random_lord", "fac_kingdom_6", 1, 21),
      (call_script, "script_give_center_to_lord", "p_town_22", reg60, 0),    
...


"script_cf_pick_random_lord" that i created:
Code:
 # script_cf_pick_random_lord
 # Input: faction, 1, 21
 # Output: random faction lord troop at reg60
("cf_pick_random_lord",
[
      (store_script_param, ":kingdom", 1),
      (store_script_param, ":min", 2),
      (store_script_param, ":max", 3),
     
      #(call_script, "script_cf_get_random_number", ":min", ":max"), Disabled - 28 march 2022
      (store_random_in_range, ":random_lord", ":min", ":max"),
      (assign, ":chosen_one", 0), # if it fails, it will return player's id. so that game does not crash?
      (try_begin),
         (eq, ":kingdom", "fac_kingdom_1"),
         (try_begin),
            (eq, ":random_lord", 1),
            (assign, ":chosen_one", "trp_knight_1_1"),
         (else_try),
            (eq, ":random_lord", 2),
            (assign, ":chosen_one", "trp_knight_1_2"),
         (else_try),
            (eq, ":random_lord", 3),
            (assign, ":chosen_one", "trp_knight_1_3"),
         (else_try),
            (eq, ":random_lord", 4),
            (assign, ":chosen_one", "trp_knight_1_4"),
         (else_try),
            (eq, ":random_lord", 5),
            (assign, ":chosen_one", "trp_knight_1_5"),
         (else_try),
            (eq, ":random_lord", 6),
            (assign, ":chosen_one", "trp_knight_1_6"),
         (else_try),
            (eq, ":random_lord", 7),
            (assign, ":chosen_one", "trp_knight_1_7"),
         (else_try),
            (eq, ":random_lord", 8),
            (assign, ":chosen_one", "trp_knight_1_8"),
         (else_try),
            (eq, ":random_lord", 9),
            (assign, ":chosen_one", "trp_knight_1_9"),
         (else_try),
            (eq, ":random_lord", 10),
            (assign, ":chosen_one", "trp_knight_1_10"),
         (else_try),
            (eq, ":random_lord", 11),
            (assign, ":chosen_one", "trp_knight_1_11"),
         (else_try),
            (eq, ":random_lord", 12),
            (assign, ":chosen_one", "trp_knight_1_12"),
         (else_try),
            (eq, ":random_lord", 13),
            (assign, ":chosen_one", "trp_knight_1_13"),
         (else_try),
            (eq, ":random_lord", 14),
            (assign, ":chosen_one", "trp_knight_1_14"),
         (else_try),
            (eq, ":random_lord", 15),
            (assign, ":chosen_one", "trp_knight_1_15"),
         (else_try),
            (eq, ":random_lord", 16),
            (assign, ":chosen_one", "trp_knight_1_16"),
         (else_try),
            (eq, ":random_lord", 17),
            (assign, ":chosen_one", "trp_knight_1_17"),
         (else_try),
            (eq, ":random_lord", 18),
            (assign, ":chosen_one", "trp_knight_1_18"),
         (else_try),
            (eq, ":random_lord", 19),
            (assign, ":chosen_one", "trp_knight_1_19"),
         (else_try),
            (eq, ":random_lord", 20),
            (assign, ":chosen_one", "trp_knight_1_20"),
         (try_end),
      (else_try),
         (eq, ":kingdom", "fac_kingdom_2"),
         (try_begin),
            (eq, ":random_lord", 1),
            (assign, ":chosen_one", "trp_knight_2_1"),
         (else_try),
            (eq, ":random_lord", 2),
            (assign, ":chosen_one", "trp_knight_2_2"),
         (else_try),
            (eq, ":random_lord", 3),
            (assign, ":chosen_one", "trp_knight_2_3"),
         (else_try),
            (eq, ":random_lord", 4),
            (assign, ":chosen_one", "trp_knight_2_4"),
         (else_try),
            (eq, ":random_lord", 5),
            (assign, ":chosen_one", "trp_knight_2_5"),
         (else_try),
            (eq, ":random_lord", 6),
            (assign, ":chosen_one", "trp_knight_2_6"),
         (else_try),
            (eq, ":random_lord", 7),
            (assign, ":chosen_one", "trp_knight_2_7"),
         (else_try),
            (eq, ":random_lord", 8),
            (assign, ":chosen_one", "trp_knight_2_8"),
         (else_try),
            (eq, ":random_lord", 9),
            (assign, ":chosen_one", "trp_knight_2_9"),
         (else_try),
            (eq, ":random_lord", 10),
            (assign, ":chosen_one", "trp_knight_2_10"),
         (else_try),
            (eq, ":random_lord", 11),
            (assign, ":chosen_one", "trp_knight_2_11"),
         (else_try),
            (eq, ":random_lord", 12),
            (assign, ":chosen_one", "trp_knight_2_12"),
         (else_try),
            (eq, ":random_lord", 13),
            (assign, ":chosen_one", "trp_knight_2_13"),
         (else_try),
            (eq, ":random_lord", 14),
            (assign, ":chosen_one", "trp_knight_2_14"),
         (else_try),
            (eq, ":random_lord", 15),
            (assign, ":chosen_one", "trp_knight_2_15"),
         (else_try),
            (eq, ":random_lord", 16),
            (assign, ":chosen_one", "trp_knight_2_16"),
         (else_try),
            (eq, ":random_lord", 17),
            (assign, ":chosen_one", "trp_knight_2_17"),
         (else_try),
            (eq, ":random_lord", 18),
            (assign, ":chosen_one", "trp_knight_2_18"),
         (else_try),
            (eq, ":random_lord", 19),
            (assign, ":chosen_one", "trp_knight_2_19"),
         (else_try),
            (eq, ":random_lord", 20),
            (assign, ":chosen_one", "trp_knight_2_20"),
         (try_end),
      (else_try),
         (eq, ":kingdom", "fac_kingdom_3"),
         (try_begin),
            (eq, ":random_lord", 1),
            (assign, ":chosen_one", "trp_knight_3_1"),
         (else_try),
            (eq, ":random_lord", 2),
            (assign, ":chosen_one", "trp_knight_3_2"),
         (else_try),
            (eq, ":random_lord", 3),
            (assign, ":chosen_one", "trp_knight_3_3"),
         (else_try),
            (eq, ":random_lord", 4),
            (assign, ":chosen_one", "trp_knight_3_4"),
         (else_try),
            (eq, ":random_lord", 5),
            (assign, ":chosen_one", "trp_knight_3_5"),
         (else_try),
            (eq, ":random_lord", 6),
            (assign, ":chosen_one", "trp_knight_3_6"),
         (else_try),
            (eq, ":random_lord", 7),
            (assign, ":chosen_one", "trp_knight_3_7"),
         (else_try),
            (eq, ":random_lord", 8),
            (assign, ":chosen_one", "trp_knight_3_8"),
         (else_try),
            (eq, ":random_lord", 9),
            (assign, ":chosen_one", "trp_knight_3_9"),
         (else_try),
            (eq, ":random_lord", 10),
            (assign, ":chosen_one", "trp_knight_3_10"),
         (else_try),
            (eq, ":random_lord", 11),
            (assign, ":chosen_one", "trp_knight_3_11"),
         (else_try),
            (eq, ":random_lord", 12),
            (assign, ":chosen_one", "trp_knight_3_12"),
         (else_try),
            (eq, ":random_lord", 13),
            (assign, ":chosen_one", "trp_knight_3_13"),
         (else_try),
            (eq, ":random_lord", 14),
            (assign, ":chosen_one", "trp_knight_3_14"),
         (else_try),
            (eq, ":random_lord", 15),
            (assign, ":chosen_one", "trp_knight_3_15"),
         (else_try),
            (eq, ":random_lord", 16),
            (assign, ":chosen_one", "trp_knight_3_16"),
         (else_try),
            (eq, ":random_lord", 17),
            (assign, ":chosen_one", "trp_knight_3_17"),
         (else_try),
            (eq, ":random_lord", 18),
            (assign, ":chosen_one", "trp_knight_3_18"),
         (else_try),
            (eq, ":random_lord", 19),
            (assign, ":chosen_one", "trp_knight_3_19"),
         (else_try),
            (eq, ":random_lord", 20),
            (assign, ":chosen_one", "trp_knight_3_20"),
         (try_end),
      (else_try),
         (eq, ":kingdom", "fac_kingdom_4"),
         (try_begin),
            (eq, ":random_lord", 1),
            (assign, ":chosen_one", "trp_knight_4_1"),
         (else_try),
            (eq, ":random_lord", 2),
            (assign, ":chosen_one", "trp_knight_4_2"),
         (else_try),
            (eq, ":random_lord", 3),
            (assign, ":chosen_one", "trp_knight_4_3"),
         (else_try),
            (eq, ":random_lord", 4),
            (assign, ":chosen_one", "trp_knight_4_4"),
         (else_try),
            (eq, ":random_lord", 5),
            (assign, ":chosen_one", "trp_knight_4_5"),
         (else_try),
            (eq, ":random_lord", 6),
            (assign, ":chosen_one", "trp_knight_4_6"),
         (else_try),
            (eq, ":random_lord", 7),
            (assign, ":chosen_one", "trp_knight_4_7"),
         (else_try),
            (eq, ":random_lord", 8),
            (assign, ":chosen_one", "trp_knight_4_8"),
         (else_try),
            (eq, ":random_lord", 9),
            (assign, ":chosen_one", "trp_knight_4_9"),
         (else_try),
            (eq, ":random_lord", 10),
            (assign, ":chosen_one", "trp_knight_4_10"),
         (else_try),
            (eq, ":random_lord", 11),
            (assign, ":chosen_one", "trp_knight_4_11"),
         (else_try),
            (eq, ":random_lord", 12),
            (assign, ":chosen_one", "trp_knight_4_12"),
         (else_try),
            (eq, ":random_lord", 13),
            (assign, ":chosen_one", "trp_knight_4_13"),
         (else_try),
            (eq, ":random_lord", 14),
            (assign, ":chosen_one", "trp_knight_4_14"),
         (else_try),
            (eq, ":random_lord", 15),
            (assign, ":chosen_one", "trp_knight_4_15"),
         (else_try),
            (eq, ":random_lord", 16),
            (assign, ":chosen_one", "trp_knight_4_16"),
         (else_try),
            (eq, ":random_lord", 17),
            (assign, ":chosen_one", "trp_knight_4_17"),
         (else_try),
            (eq, ":random_lord", 18),
            (assign, ":chosen_one", "trp_knight_4_18"),
         (else_try),
            (eq, ":random_lord", 19),
            (assign, ":chosen_one", "trp_knight_4_19"),
         (else_try),
            (eq, ":random_lord", 20),
            (assign, ":chosen_one", "trp_knight_4_20"),
         (try_end),
      (else_try),
         (eq, ":kingdom", "fac_kingdom_5"),
         (try_begin),
            (eq, ":random_lord", 1),
            (assign, ":chosen_one", "trp_knight_5_1"),
         (else_try),
            (eq, ":random_lord", 2),
            (assign, ":chosen_one", "trp_knight_5_2"),
         (else_try),
            (eq, ":random_lord", 3),
            (assign, ":chosen_one", "trp_knight_5_3"),
         (else_try),
            (eq, ":random_lord", 4),
            (assign, ":chosen_one", "trp_knight_5_4"),
         (else_try),
            (eq, ":random_lord", 5),
            (assign, ":chosen_one", "trp_knight_5_5"),
         (else_try),
            (eq, ":random_lord", 6),
            (assign, ":chosen_one", "trp_knight_5_6"),
         (else_try),
            (eq, ":random_lord", 7),
            (assign, ":chosen_one", "trp_knight_5_7"),
         (else_try),
            (eq, ":random_lord", 8),
            (assign, ":chosen_one", "trp_knight_5_8"),
         (else_try),
            (eq, ":random_lord", 9),
            (assign, ":chosen_one", "trp_knight_5_9"),
         (else_try),
            (eq, ":random_lord", 10),
            (assign, ":chosen_one", "trp_knight_5_10"),
         (else_try),
            (eq, ":random_lord", 11),
            (assign, ":chosen_one", "trp_knight_5_11"),
         (else_try),
            (eq, ":random_lord", 12),
            (assign, ":chosen_one", "trp_knight_5_12"),
         (else_try),
            (eq, ":random_lord", 13),
            (assign, ":chosen_one", "trp_knight_5_13"),
         (else_try),
            (eq, ":random_lord", 14),
            (assign, ":chosen_one", "trp_knight_5_14"),
         (else_try),
            (eq, ":random_lord", 15),
            (assign, ":chosen_one", "trp_knight_5_15"),
         (else_try),
            (eq, ":random_lord", 16),
            (assign, ":chosen_one", "trp_knight_5_16"),
         (else_try),
            (eq, ":random_lord", 17),
            (assign, ":chosen_one", "trp_knight_5_17"),
         (else_try),
            (eq, ":random_lord", 18),
            (assign, ":chosen_one", "trp_knight_5_18"),
         (else_try),
            (eq, ":random_lord", 19),
            (assign, ":chosen_one", "trp_knight_5_19"),
         (else_try),
            (eq, ":random_lord", 20),
            (assign, ":chosen_one", "trp_knight_5_20"),
         (try_end),
      (else_try),
         (eq, ":kingdom", "fac_kingdom_6"),
         (try_begin),
            (eq, ":random_lord", 1),
            (assign, ":chosen_one", "trp_knight_6_1"),
         (else_try),
            (eq, ":random_lord", 2),
            (assign, ":chosen_one", "trp_knight_6_2"),
         (else_try),
            (eq, ":random_lord", 3),
            (assign, ":chosen_one", "trp_knight_6_3"),
         (else_try),
            (eq, ":random_lord", 4),
            (assign, ":chosen_one", "trp_knight_6_4"),
         (else_try),
            (eq, ":random_lord", 5),
            (assign, ":chosen_one", "trp_knight_6_5"),
         (else_try),
            (eq, ":random_lord", 6),
            (assign, ":chosen_one", "trp_knight_6_6"),
         (else_try),
            (eq, ":random_lord", 7),
            (assign, ":chosen_one", "trp_knight_6_7"),
         (else_try),
            (eq, ":random_lord", 8),
            (assign, ":chosen_one", "trp_knight_6_8"),
         (else_try),
            (eq, ":random_lord", 9),
            (assign, ":chosen_one", "trp_knight_6_9"),
         (else_try),
            (eq, ":random_lord", 10),
            (assign, ":chosen_one", "trp_knight_6_10"),
         (else_try),
            (eq, ":random_lord", 11),
            (assign, ":chosen_one", "trp_knight_6_11"),
         (else_try),
            (eq, ":random_lord", 12),
            (assign, ":chosen_one", "trp_knight_6_12"),
         (else_try),
            (eq, ":random_lord", 13),
            (assign, ":chosen_one", "trp_knight_6_13"),
         (else_try),
            (eq, ":random_lord", 14),
            (assign, ":chosen_one", "trp_knight_6_14"),
         (else_try),
            (eq, ":random_lord", 15),
            (assign, ":chosen_one", "trp_knight_6_15"),
         (else_try),
            (eq, ":random_lord", 16),
            (assign, ":chosen_one", "trp_knight_6_16"),
         (else_try),
            (eq, ":random_lord", 17),
            (assign, ":chosen_one", "trp_knight_6_17"),
         (else_try),
            (eq, ":random_lord", 18),
            (assign, ":chosen_one", "trp_knight_6_18"),
         (else_try),
            (eq, ":random_lord", 19),
            (assign, ":chosen_one", "trp_knight_6_19"),
         (else_try),
            (eq, ":random_lord", 20),
            (assign, ":chosen_one", "trp_knight_6_20"),
         (try_end),
      (try_end),
     
      (assign, reg60, ":chosen_one"),
]),

Also do you have any suggestions on how should i refactor my code? Specifically "cf_pick_random_lord" function. Its too bulky and long at the moment.
 
Solution
Out of the chapter 'Module Scripts' of the Modding Guide (see my signatures):

Can-fail (cf\_x) Scripts
You have either noticed some scripts in module_scripts.py with the prefix cf_ or gotten some warning at compiling your module with the following content:
Code:
WARNING: Script can fail at operation #x. Use cf_ at the beginning of its name: some_script_name
The prefix cf_ indicates a script that can fail. MaBL/MBScript requires that every command (line) is true or it jumps to the next block (scope). cf_-scripts are a handy way to use this (Source).
Code:
top level scope

    | second level scope
    |
(try_begin)
    (call_script, "cf_something"),  # goes to line 2 (true) or 4 (false)...
Out of the chapter 'Module Scripts' of the Modding Guide (see my signatures):

Can-fail (cf\_x) Scripts
You have either noticed some scripts in module_scripts.py with the prefix cf_ or gotten some warning at compiling your module with the following content:
Code:
WARNING: Script can fail at operation #x. Use cf_ at the beginning of its name: some_script_name
The prefix cf_ indicates a script that can fail. MaBL/MBScript requires that every command (line) is true or it jumps to the next block (scope). cf_-scripts are a handy way to use this (Source).
Code:
top level scope

    | second level scope
    |
(try_begin)
    (call_script, "cf_something"),  # goes to line 2 (true) or 4 (false)
    (assign, ":true", 1),
    (display_message, "@ololol"),
(else_try),
    (assign, ":true", 0), # if cf_ fails (is false)
(try_end),
You can read the warning as a recommendation, since you have a conditional operation that would cause the script to fail within the top level scope of the script rather than inside a try block. Therefore, if that operation causes the script to fail, the scope where the call_script operation calls this script would also fail. This means that scripts (or triggers) calling this cf_-script at the top level scope can also fail.
cf_-scripts are usually used as complex conditionals, you can use them to write your own conditional functions (Source and Source).

To give a short example for a complex conditional: cf_-script can be used as a part of a this_or_next operation:
Code:
Example 1:
(this_or_next|eq, 1, 0),
(call_script, "script_cf_eq_1_1"),

Example 2:
(this_or_next|call_script, "script_cf_eq_1_1"),
(eq, reg1, 0),
Example 1 will work as a cf\_-script can be used as the last case. Example 2 on the contrary does not work as intended, it just fails or continues as with a normal call_script operation (Source and Source).

Coming back to the warning message mentioned above. Two ways have been now indicated on how to deal with it. The first option is to add the prefix cf_ infront of the script name, not because you simply want the warning message to disappear but because you understood the effect of it and how this script might affect your work. The second option is nearly as simple: If you don't want your script to behave like a can-fail one, wrap the entire script code between try_begin and try_end (Source).

I hope it helps :grin:
 
Upvote 1
Solution
Out of the chapter 'Module Scripts' of the Modding Guide (see my signatures):

Can-fail (cf\_x) Scripts
You have either noticed some scripts in module_scripts.py with the prefix cf_ or gotten some warning at compiling your module with the following content:
Code:
WARNING: Script can fail at operation #x. Use cf_ at the beginning of its name: some_script_name
The prefix cf_ indicates a script that can fail. MaBL/MBScript requires that every command (line) is true or it jumps to the next block (scope). cf_-scripts are a handy way to use this (Source).
Code:
top level scope

    | second level scope
    |
(try_begin)
    (call_script, "cf_something"),  # goes to line 2 (true) or 4 (false)
    (assign, ":true", 1),
    (display_message, "@ololol"),
(else_try),
    (assign, ":true", 0), # if cf_ fails (is false)
(try_end),
You can read the warning as a recommendation, since you have a conditional operation that would cause the script to fail within the top level scope of the script rather than inside a try block. Therefore, if that operation causes the script to fail, the scope where the call_script operation calls this script would also fail. This means that scripts (or triggers) calling this cf_-script at the top level scope can also fail.
cf_-scripts are usually used as complex conditionals, you can use them to write your own conditional functions (Source and Source).

To give a short example for a complex conditional: cf_-script can be used as a part of a this_or_next operation:
Code:
Example 1:
(this_or_next|eq, 1, 0),
(call_script, "script_cf_eq_1_1"),

Example 2:
(this_or_next|call_script, "script_cf_eq_1_1"),
(eq, reg1, 0),
Example 1 will work as a cf\_-script can be used as the last case. Example 2 on the contrary does not work as intended, it just fails or continues as with a normal call_script operation (Source and Source).

Coming back to the warning message mentioned above. Two ways have been now indicated on how to deal with it. The first option is to add the prefix cf_ infront of the script name, not because you simply want the warning message to disappear but because you understood the effect of it and how this script might affect your work. The second option is nearly as simple: If you don't want your script to behave like a can-fail one, wrap the entire script code between try_begin and try_end (Source).

I hope it helps :grin:

Wrapping the code block in a try block worked like a charm. Also thanks for detailed help. It was very useful.
 
Upvote 0
Back
Top Bottom