Editing the 'Leave Faction' Script, and a Syntax Error

Users who are viewing this thread

Druidic

Knight
So, I've got some ideas on a list, and the first one I want to try out is a modification to the "lord_ask_leave_service" bit in module_dialogs.py, which if successful, would allow the player to secede, or retain their fiefs when leaving the service of the king, but will initiate war between the player faction and the faction the player is leaving.

Keep in mind I am no master at coding. In fact you could say I just started and you'd be semi-accurate. But I know about what the functions do to a basic extent. Anyways, here is the code I am using compared to the vanilla Module System code:
Code:
  [anyone,"lord_ask_leave_service", [(ge, "$g_talk_troop_relation", 1)], "Hrm.\
 Has your oath become burdensome, {playername}? It is unusual to request release from homage,\
 but in respect of your fine service, I will not hold you if you truly wish to end it.\
 Though you would be sorely missed.", "lord_ask_leave_service_verify",[]],
  [anyone,"lord_ask_leave_service", [], "Release from homage? Hmm, perhaps it would be for the best...\
 However, {playername}, you must be sure that release is what you desire. This is not a thing done lightly.", "lord_ask_leave_service_verify",[]],

  [anyone|plyr ,"lord_ask_leave_service_verify", [], "It is something I must do, {s65}.", "lord_ask_leave_service_2",[]],
  [anyone|plyr ,"lord_ask_leave_service_verify", [], "You are right, {s65}. My place is here.", "lord_ask_leave_service_giveup",[]],

  [anyone,"lord_ask_leave_service_giveup", [], "I am pleased to hear it, {playername}.\
 I hope you'll banish such unworthy thoughts from your mind from now on.", "lord_pretalk",[]],

  [anyone,"lord_ask_leave_service_2", [], "Then you are sure? Also, be aware that if you leave my services, you will be surrendering to me all the fiefs which you hold in my name.", "lord_ask_leave_service_verify_again",[]],
  [anyone|plyr ,"lord_ask_leave_service_verify_again", [], "Yes, {s65}.", "lord_ask_leave_service_3",[]],
  [anyone|plyr ,"lord_ask_leave_service_verify_again", [], "Of course not, {s65}. I am ever your loyal vassal.", "lord_ask_leave_service_giveup",[]],

  [anyone,"lord_ask_leave_service_3", [], "As you wish. I hereby declare your oaths to be null and void.\
 You will no longer hold land or titles in my name, and you are released from your duties to my house.\
 You are free, {playername}.", "lord_ask_leave_service_end",
   [
        (call_script, "script_add_log_entry", logent_renounced_allegiance,   "trp_player",  -1, "$g_talk_troop", "$g_talk_troop_faction"),
        (call_script, "script_player_leave_faction", 1), #1 means give back fiefs
    ]],

  [anyone|plyr ,"lord_ask_leave_service_end", [], "Thank you, sir. It was an honour to serve you..", "lord_ask_leave_service_end_2",[]],
  [anyone|plyr ,"lord_ask_leave_service_end", [], "My thanks. It feels good to be {a free man/free} once again.", "lord_ask_leave_service_end_2",[]],

  [anyone ,"lord_ask_leave_service_end_2", [], "Farewell then, {playername}, and good luck go with you.", "close_window",
   [(assign, "$g_leave_encounter", 1)]],
Code:
#SECESSION MOD BEGIN
#INITIAL QUESTION ON LEAVING THE FACTION
  [anyone,"lord_ask_leave_service", [(ge, "$g_talk_troop_relation", 1)], "Hrm.\
 Has your oath become burdensome, {playername}? It is unusual to request release from homage,\
 but in respect of your fine service, I will not hold you if you truly wish to end it.\
 Though you would be sorely missed.", "lord_ask_leave_service_verify",[]],
  [anyone,"lord_ask_leave_service", [], "Release from homage? Hmm, perhaps it would be for the best...\
 However, {playername}, you must be sure that release is what you desire. This is not a thing done lightly.", "lord_ask_leave_service_verify",[]],

  [anyone|plyr ,"lord_ask_leave_service_verify", [], "It is something I must do, {s65}.", "lord_ask_leave_service_2",[]],
  [anyone|plyr ,"lord_ask_leave_service_verify", [], "You are right, {s65}. My place is here.", "lord_ask_leave_service_giveup",[]],
# IF PLAYER REFUSES TO LEAVE
  [anyone,"lord_ask_leave_service_giveup", [], "I am pleased to hear it, {playername}.\
 I hope you'll banish such unworthy thoughts from your mind from now on.", "lord_pretalk",[]],

  [anyone,"lord_ask_leave_service_2", [], "Then you are sure? Also, be aware that if you leave my services, you will be surrendering to me all the fiefs which you hold in my name.", "lord_ask_leave_service_verify_again",[]],
  [anyone|plyr ,"lord_ask_leave_service_verify_again", [], "Yes, {s65}.", "lord_ask_leave_service_3",[]],
  [anyone|plyr ,"lord_ask_leave_service_verify_again", [], "Oh I will leave your service, but those fiefs belong to me, {s65}.", "lord_ask_leave_service_secede",[]], #SECESSION START
  [anyone|plyr ,"lord_ask_leave_service_verify_again", [], "Of course not, {s65}. I am ever your loyal vassal.", "lord_ask_leave_service_giveup",[]],
# IF YOU LEAVE PEACEFULLY AND GIVE UP YOUR FIEFS
  [anyone,"lord_ask_leave_service_3", [], "As you wish. I hereby declare your oaths to be null and void.\
 You will no longer hold land or titles in my name, and you are released from your duties to my house.\
 You are free, {playername}.", "lord_ask_leave_service_end",
   [
        (call_script, "script_add_log_entry", logent_renounced_allegiance,   "trp_player",  -1, "$g_talk_troop", "$g_talk_troop_faction"),
        (call_script, "script_player_leave_faction", 1), #1 means give back fiefs. 0, I assume, means to keep them.
    ]],

  [anyone|plyr ,"lord_ask_leave_service_end", [], "Thank you, sir. It was an honour to serve you..", "lord_ask_leave_service_end_2",[]],
  [anyone|plyr ,"lord_ask_leave_service_end", [], "My thanks. It feels good to be {a free man/free} once again.", "lord_ask_leave_service_end_2",[]],

  [anyone ,"lord_ask_leave_service_end_2", [], "Farewell then, {playername}, and good luck go with you.", "close_window",
   [(assign, "$g_leave_encounter", 1)]],
#IF YOU CHOOSE TO SECEDE
  [anyone,"lord_ask_leave_service_3_alt", [], "How dare you, {playername}! You do realize that secession is illegal in my realm,\
 and that this is equivalent to an act of war against me? Surely I misheard you, perhaps?\", "lord_ask_leave_service_secede",[]],
  [anyone|plyr ,"lord_ask_leave_service_secede", [], "You did not mishear. I stand by my words, and I am seceding.", "lord_ask_leave_service_secede_2",[]],
  [anyone|plyr ,"lord_ask_leave_service_secede", [], "Um... yes you did mishear me, my apologies.", "lord_ask_leave_service_secede_giveup",[]],

  [anyone ,"lord_ask_leave_service_secede_2", [], "Then it is war, {playername}. I hope you rethink your actions when the lands you own are burned to the ground.", "close_window",
   [(assign, "$g_leave_encounter", 1)]],
   [
        (call_script, "script_add_log_entry", logent_renounced_allegiance,   "trp_player",  -1, "$g_talk_troop", "$g_talk_troop_faction"),
        (call_script, "script_player_leave_faction", 0), #1 means give back fiefs. 0, I assume, means to keep them. If script fails, input "fac_player_supporters_faction" to align the fiefs to player.
    ]],
  [anyone ,"lord_ask_leave_service_secede_giveup", [], "Good, {playername}! You had me worried there, I had thought you were attempting to betray me! But enough of that matter.", "start",
#SECESSION MOD END 

This is what I have so far, and I won't make any further changes until the issue I am about to bring up is dealt with. I get a syntax error when compiling the mod using the Module System's native build_module.bat file, which is below:
Code:
Initializing...
Traceback (most recent call last):
  File "process_global_variables.py", line 9, in <module>
    from module_dialogs import *
  File "C:\Users\<MyName>\Desktop\Warband Module Tools\WarbandModuleSystem\Module_sy
stem 1.166\module_dialogs.py", line 13633
    and that this is equivalent to an act of war against me? Surely I misheard y
ou, perhaps?\", "lord_ask_leave_service_secede",[]],

                                             ^
SyntaxError: invalid syntax
Exporting strings...
Exporting skills...
Exporting tracks...
Exporting animations...
Exporting meshes...
Exporting sounds...
Exporting skins...
Exporting map icons...
Creating new tag_uses.txt file...
Creating new quick_strings.txt file...
Exporting faction data...
Exporting item data...
Exporting scene data...
Exporting troops data
Exporting particle data...
Exporting scene props...
Exporting tableau materials data...
Exporting presentations...
Exporting party_template data...
Exporting parties
Exporting quest data...
Exporting info_page data...
Exporting scripts...
Exporting mission_template data...
Exporting game menus data...
exporting simple triggers...
Traceback (most recent call last):
  File "process_dialogs.py", line 9, in <module>
    from module_dialogs import *
  File "C:\Users\<MyName>\Desktop\Warband Module Tools\WarbandModuleSystem\Module_sy
stem 1.166\module_dialogs.py", line 13633
    and that this is equivalent to an act of war against me? Surely I misheard y
ou, perhaps?\", "lord_ask_leave_service_secede",[]],

                                             ^
SyntaxError: invalid syntax
Checking global variable usages...
Exporting postfx_params...

______________________________

Script processing has ended.
Press any key to exit. . .
guvzEzc.png
From what I see of the code, I'm doing nothing wrong, save for that particular line the compiler is pointing out, which happens to be highlighted. What's odd is that that bit is in the same context as one below it, same code, brackets, commas, everything, if that makes sense. Basically, on the dialog option below, there's no problem, even if the exact same conditions apply where the text is.

So, any ideas? Is it a simple character I'm missing or some strange setting that I must've misclicked? Thanks in advance!

EDIT: I Forgot to remove a slash in the dialog sentence for the original error. However, now there is an IndentationError right after it:
Code:
Initializing...
Traceback (most recent call last):
  File "process_global_variables.py", line 9, in <module>
    from module_dialogs import *
  File "C:\Users\Ryan\Desktop\Warband Module Tools\WarbandModuleSystem\Module_sy
stem 1.166\module_dialogs.py", line 13643
    [anyone ,"lord_ask_leave_service_secede_giveup", [], "Good, {playername}! Yo
u had me worried there, I had thought you were attempting to betray me! But enou
gh of that matter.", "start",
    ^
IndentationError: unexpected indent
Exporting strings...
Exporting skills...
Exporting tracks...
Exporting animations...
Exporting meshes...
Exporting sounds...
Exporting skins...
Exporting map icons...
Creating new tag_uses.txt file...
Creating new quick_strings.txt file...
Exporting faction data...
Exporting item data...
Exporting scene data...
Exporting troops data
Exporting particle data...
Exporting scene props...
Exporting tableau materials data...
Exporting presentations...
Exporting party_template data...
Exporting parties
Exporting quest data...
Exporting info_page data...
Exporting scripts...
Exporting mission_template data...
Exporting game menus data...
exporting simple triggers...
Traceback (most recent call last):
  File "process_dialogs.py", line 9, in <module>
    from module_dialogs import *
  File "C:\Users\Ryan\Desktop\Warband Module Tools\WarbandModuleSystem\Module_sy
stem 1.166\module_dialogs.py", line 13643
    [anyone ,"lord_ask_leave_service_secede_giveup", [], "Good, {playername}! Yo
u had me worried there, I had thought you were attempting to betray me! But enou
gh of that matter.", "start",
    ^
IndentationError: unexpected indent
Checking global variable usages...
Exporting postfx_params...

______________________________

Script processing has ended.
Press any key to exit. . .

And this time I genuinely have no idea what I'm missing.
 
Last line. You began with a bracket, you don't finish with one. It misses the consequence of the choice.

Basically, you're missing "[(assign, "$g_leave_encounter", 1)]],"
 
snouz said:
Last line. You began with a bracket, you don't finish with one. It misses the consequence of the choice.

Basically, you're missing "[(assign, "$g_leave_encounter", 1)]],"

Well, I tried fixing brackets, changing the end state to "close_window" instead of "start" and even inputting "[(assign, "$g_leave_encounter", 1)]]," below the last line of code, as you implied, and the indentation error still occurs. All the brackets seem to be matched and this line is the only line that seems to be giving this error.

Code:
  [anyone ,"lord_ask_leave_service_secede_giveup", [], "Good, {playername}! You had me worried there, I had thought you were attempting to betray me! But enough of that matter. Good travels.", "close_window",
   [(assign, "$g_leave_encounter", 1)]],

What I don't get is that even though the line before it has some code in between it and the "[(assign, "$g_leave_encounter", 1)]]," bit, the function is pretty much the same if you gut the code, and that bit works fine.

  [anyone ,"lord_ask_leave_service_secede_2", [], "Then it is war, {playername}. I hope you rethink your actions when the lands you own are burned to the ground.", "close_window",
  [
        (call_script, "script_add_log_entry", logent_renounced_allegiance,  "trp_player",  -1, "$g_talk_troop", "$g_talk_troop_faction"),
        (call_script, "script_player_leave_faction", 0), #1 means give back fiefs. 0, I assume, means to keep them.
    ]],

  [(assign, "$g_leave_encounter", 1)]],

  [anyone,"lord_ask_leave_service_secede_giveup", [], "Good, {playername}! You had me worried there, I had thought you were attempting to betray me! But enough of that matter. Good travels.", "close_window",
  [(assign, "$g_leave_encounter", 1)]],
 
Back
Top Bottom