• Welcome to the forums on our new hosting setup. Everything should be working the same, but if you run into any problems, please let us know over here.

unassigned local variable & Error injecting code (among a few others)

Users who are viewing this thread

Calabanar

Sergeant at Arms
Hi everyone,

I have been working on a personal mod for a while now, despite having basically 0 skill in Python and coding in general.

I managed to get everything working up to a point where I tried incorporating a few new elements, and now it's giving me the following error when compiling:

*** Warband Refined & Enhanced Compiler Kit (W.R.E.C.K.) version 1.0.0 ***
Please report errors, problems and suggestions at http://lav.lomskih.net/wreck/

Loading module...C:\Program Files (x86)\Steam\steamapps\common\MountBlade Warband\Modules\MOD! - UNIT TEST\Source Files\util_scripts.py:84: UserWarning: Error injecting code into: party_give_xp_and_gold
warnings.warn("Error injecting code into: %s" % (cur_directive[1]) )
DONE.
Loading plugins... DONE.
Checking module syntax... DONE.
Allocating identifiers... DONE.
Compiling module... DONE.
Exporting module... DONE.

COMPILATION SUCCESSFUL.

The following errors were generated during compilation:
unassigned local variable <l.final_price_for_secondary_input[@1224979098644774926]> used by operation store_div in script.process_player_enterprise on line 48

The following notifications were generated during compilation:
local l.unused declared but never used in script.game_get_troop_wage
local l.unused declared but never used in script.debug_variables
local l.unused_2 declared but never used in script.debug_variables
local l.unused declared but never used in script.party_inflict_attrition

Appuyez sur une touche pour continuer...

And this big list when trying to build the module:

C:\Program Files (x86)\Steam\steamapps\common\MountBlade Warband\Modules\MOD! - UNIT TEST\Source Files\util_scripts.py:84: UserWarning: Error injecting code into: party_give_xp_and_gold
warnings.warn("Error injecting code into: %s" % (cur_directive[1]) )
Initializing...
C:\Program Files (x86)\Steam\steamapps\common\MountBlade Warband\Modules\MOD! - UNIT TEST\Source Files\util_scripts.py:84: UserWarning: Error injecting code into: party_give_xp_and_gold
warnings.warn("Error injecting code into: %s" % (cur_directive[1]) )
Compiling all global variables...
Exporting strings...
Exporting skills...
Exporting tracks...
Exporting animations...
Exporting meshes...
Exporting sounds...
Exporting skins...
C:\Program Files (x86)\Steam\steamapps\common\MountBlade Warband\Modules\MOD! - UNIT TEST\Source Files\util_scripts.py:84: UserWarning: Error injecting code into: party_give_xp_and_gold
warnings.warn("Error injecting code into: %s" % (cur_directive[1]) )
Exporting map icons...
Creating new tag_uses.txt file...
Creating new quick_strings.txt file...
Exporting faction data...
Exporting item data...
C:\Program Files (x86)\Steam\steamapps\common\MountBlade Warband\Modules\MOD! - UNIT TEST\Source Files\util_scripts.py:84: UserWarning: Error injecting code into: party_give_xp_and_gold
warnings.warn("Error injecting code into: %s" % (cur_directive[1]) )
Exporting scene data...
C:\Program Files (x86)\Steam\steamapps\common\MountBlade Warband\Modules\MOD! - UNIT TEST\Source Files\util_scripts.py:84: UserWarning: Error injecting code into: party_give_xp_and_gold
warnings.warn("Error injecting code into: %s" % (cur_directive[1]) )
Exporting troops data
Exporting particle data...
C:\Program Files (x86)\Steam\steamapps\common\MountBlade Warband\Modules\MOD! - UNIT TEST\Source Files\util_scripts.py:84: UserWarning: Error injecting code into: party_give_xp_and_gold
warnings.warn("Error injecting code into: %s" % (cur_directive[1]) )
Exporting scene props...
C:\Program Files (x86)\Steam\steamapps\common\MountBlade Warband\Modules\MOD! - UNIT TEST\Source Files\util_scripts.py:84: UserWarning: Error injecting code into: party_give_xp_and_gold
warnings.warn("Error injecting code into: %s" % (cur_directive[1]) )
Exporting tableau materials data...
C:\Program Files (x86)\Steam\steamapps\common\MountBlade Warband\Modules\MOD! - UNIT TEST\Source Files\util_scripts.py:84: UserWarning: Error injecting code into: party_give_xp_and_gold
warnings.warn("Error injecting code into: %s" % (cur_directive[1]) )
Exporting presentations...
Exporting party_template data...
C:\Program Files (x86)\Steam\steamapps\common\MountBlade Warband\Modules\MOD! - UNIT TEST\Source Files\util_scripts.py:84: UserWarning: Error injecting code into: party_give_xp_and_gold
warnings.warn("Error injecting code into: %s" % (cur_directive[1]) )
Exporting parties
Exporting quest data...
Exporting info_page data...
C:\Program Files (x86)\Steam\steamapps\common\MountBlade Warband\Modules\MOD! - UNIT TEST\Source Files\util_scripts.py:84: UserWarning: Error injecting code into: party_give_xp_and_gold
warnings.warn("Error injecting code into: %s" % (cur_directive[1]) )
Exporting scripts...
WARNING: Script can fail at operation #69. Use cf_ at the beginning of its name: game_receive_network_message
WARNING: Script can fail at operation #85. Use cf_ at the beginning of its name: game_receive_network_message
WARNING: Script can fail at operation #113. Use cf_ at the beginning of its name: game_receive_network_message
WARNING: Script can fail at operation #121. Use cf_ at the beginning of its name: game_receive_network_message
WARNING: Script can fail at operation #141. Use cf_ at the beginning of its name: game_receive_network_message
WARNING: Script can fail at operation #149. Use cf_ at the beginning of its name: game_receive_network_message
WARNING: Script can fail at operation #157. Use cf_ at the beginning of its name: game_receive_network_message
WARNING: Script can fail at operation #165. Use cf_ at the beginning of its name: game_receive_network_message
WARNING: Script can fail at operation #173. Use cf_ at the beginning of its name: game_receive_network_message
WARNING: Script can fail at operation #181. Use cf_ at the beginning of its name: game_receive_network_message
WARNING: Script can fail at operation #189. Use cf_ at the beginning of its name: game_receive_network_message
WARNING: Script can fail at operation #197. Use cf_ at the beginning of its name: game_receive_network_message
WARNING: Script can fail at operation #205. Use cf_ at the beginning of its name: game_receive_network_message
WARNING: Script can fail at operation #207. Use cf_ at the beginning of its name: game_receive_network_message
WARNING: Script can fail at operation #208. Use cf_ at the beginning of its name: game_receive_network_message
WARNING: Script can fail at operation #216. Use cf_ at the beginning of its name: game_receive_network_message
WARNING: Script can fail at operation #223. Use cf_ at the beginning of its name: game_receive_network_message
WARNING: Script can fail at operation #236. Use cf_ at the beginning of its name: game_receive_network_message
WARNING: Script can fail at operation #244. Use cf_ at the beginning of its name: game_receive_network_message
WARNING: Script can fail at operation #257. Use cf_ at the beginning of its name: game_receive_network_message
WARNING: Script can fail at operation #270. Use cf_ at the beginning of its name: game_receive_network_message
WARNING: Script can fail at operation #278. Use cf_ at the beginning of its name: game_receive_network_message
WARNING: Script can fail at operation #286. Use cf_ at the beginning of its name: game_receive_network_message
WARNING: Script can fail at operation #294. Use cf_ at the beginning of its name: game_receive_network_message
WARNING: Script can fail at operation #302. Use cf_ at the beginning of its name: game_receive_network_message
WARNING: Script can fail at operation #310. Use cf_ at the beginning of its name: game_receive_network_message
WARNING: Script can fail at operation #318. Use cf_ at the beginning of its name: game_receive_network_message
WARNING: Script can fail at operation #326. Use cf_ at the beginning of its name: game_receive_network_message
WARNING: Script can fail at operation #332. Use cf_ at the beginning of its name: game_receive_network_message
WARNING: Script can fail at operation #338. Use cf_ at the beginning of its name: game_receive_network_message
WARNING: Script can fail at operation #353. Use cf_ at the beginning of its name: game_receive_network_message
WARNING: Script can fail at operation #395. Use cf_ at the beginning of its name: game_receive_network_message
WARNING: Script can fail at operation #444. Use cf_ at the beginning of its name: game_receive_network_message
WARNING: Script can fail at operation #572. Use cf_ at the beginning of its name: game_receive_network_message
WARNING: Script can fail at operation #588. Use cf_ at the beginning of its name: game_receive_network_message
WARNING: Script can fail at operation #596. Use cf_ at the beginning of its name: game_receive_network_message
WARNING: Script can fail at operation #604. Use cf_ at the beginning of its name: game_receive_network_message
WARNING: Script can fail at operation #612. Use cf_ at the beginning of its name: game_receive_network_message
WARNING: Script can fail at operation #626. Use cf_ at the beginning of its name: game_receive_network_message
WARNING: Script can fail at operation #640. Use cf_ at the beginning of its name: game_receive_network_message
WARNING: Script can fail at operation #653. Use cf_ at the beginning of its name: game_receive_network_message
WARNING: Script can fail at operation #666. Use cf_ at the beginning of its name: game_receive_network_message
WARNING: Script can fail at operation #679. Use cf_ at the beginning of its name: game_receive_network_message
WARNING: Script can fail at operation #692. Use cf_ at the beginning of its name: game_receive_network_message
WARNING: Script can fail at operation #700. Use cf_ at the beginning of its name: game_receive_network_message
WARNING: Script can fail at operation #708. Use cf_ at the beginning of its name: game_receive_network_message
WARNING: Script can fail at operation #748. Use cf_ at the beginning of its name: game_receive_network_message
WARNING: Script can fail at operation #24. Use cf_ at the beginning of its name: cstm_cf_troop_stats_are_different
WARNING: Script can fail at operation #21. Use cf_ at the beginning of its name: cstm_cf_troop_equipments_are_different
WARNING: Script can fail at operation #10. Use cf_ at the beginning of its name: cstm_cf_troop_has_horse
WARNING: Script can fail at operation #11. Use cf_ at the beginning of its name: cstm_cf_troop_has_bow_or_crossbow
WARNING: Script can fail at operation #19. Use cf_ at the beginning of its name: cstm_cf_item_is_eligible_equipment_option
C:\Program Files (x86)\Steam\steamapps\common\MountBlade Warband\Modules\MOD! - UNIT TEST\Source Files\util_scripts.py:84: UserWarning: Error injecting code into: party_give_xp_and_gold
warnings.warn("Error injecting code into: %s" % (cur_directive[1]) )
Exporting mission_template data...
C:\Program Files (x86)\Steam\steamapps\common\MountBlade Warband\Modules\MOD! - UNIT TEST\Source Files\util_scripts.py:84: UserWarning: Error injecting code into: party_give_xp_and_gold
warnings.warn("Error injecting code into: %s" % (cur_directive[1]) )
Exporting game menus data...
C:\Program Files (x86)\Steam\steamapps\common\MountBlade Warband\Modules\MOD! - UNIT TEST\Source Files\util_scripts.py:84: UserWarning: Error injecting code into: party_give_xp_and_gold
warnings.warn("Error injecting code into: %s" % (cur_directive[1]) )
exporting simple triggers...
C:\Program Files (x86)\Steam\steamapps\common\MountBlade Warband\Modules\MOD! - UNIT TEST\Source Files\util_scripts.py:84: UserWarning: Error injecting code into: party_give_xp_and_gold
warnings.warn("Error injecting code into: %s" % (cur_directive[1]) )
exporting triggers...
exporting dialogs...
C:\Program Files (x86)\Steam\steamapps\common\MountBlade Warband\Modules\MOD! - UNIT TEST\Source Files\util_scripts.py:84: UserWarning: Error injecting code into: party_give_xp_and_gold
warnings.warn("Error injecting code into: %s" % (cur_directive[1]) )
Checking global variable usages...
WARNING: Global variable never used: cstm_selected_troop
WARNING: Global variable never used: cstm_customise_button
WARNING: Global variable never used: cstm_finalise_button
Imported 25 global variables for saved-game compatability that are not used.
Exporting postfx_params...

______________________________

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

I'm just kind of stuck here, which sucks because I added the Perfect Troop Tree Presentation but can't use it since the game crashes, which drastically slows down thebalancing and creation of units. If there is anything I should add to help you help me, I'll gladly oblige.

Edit: I have read "The Ultimate Introduction to Modding", which has greatly helped up to this point.
 
Last edited:
It is great you have read that thread containing a lot of useful resources; the more you learn on your own, the less time you will spend on asking others around about modding.

I recommend that you go back to working on your backed up ModSys (if you have one) and once again carefully implement the set of scripts by Rubik. If you do not have any copy of your ModSys, remove those scripts and start over again; they are fine so it is guaranteed you made a mistake somewhere.
 

Vetrogor

Squire
You have messed python code unless you are trying to use modmerger with WRECK wich are not compatible. Do you have a backup? What code causes to break?

I managed to get everything working up to a point where I tried incorporating a few new elements

You need to clarify you steps. We are not mediums.
 

Iron Sight

Sergeant
Hi.
With that out the way, down to buisiness.

1.)
unassigned local variable <l.final_price_for_secondary_input[@1224979098644774926]> used by operation store_div in script.process_player_enterprise on line 48

This is saying that the local variable ":final_price_for_secondary_input" isn't assigned before it's used. Being "assigned" is the same thing as initializing a variable in other coding languages. To fix it, simply put (assign, ":final_price_for_secondary_input", 0), at the top of the script it's in. Since you're using ModMerger, as evident by some of the issues further along, you can inject this code with ModMerger or just search for the script in the source and put the code in that way. This won't cause issues as is, that I know of, but It's good practice to initialize variables.

2.)
local l.unused declared but never used in script.game_get_troop_wage
local l.unused declared but never used in script.debug_variables
local l.unused_2 declared but never used in script.debug_variables
local l.unused declared but never used in script.party_inflict_attrition

This is saying that these local variables are declared (assigned / initialized) but not used in their respective script. To fix these, simple find the script they're in and use them. Since they aren't originally used you can use them however you like. I simply multiplied them by 1. For example:
(val_mul, ":unused", 1), (val_mul, ":unused_2", 1), You can do this with either ModMerger or manually. These won't cause issues as is but again, good practice to keep everything clean.

From here your situation is a bit confusing which is probably why the other repliers are suggesting you to go back and learn some of the basics of modding M&BW with the Module System. Your first spoiler indicates you are using W.R.E.C.K and your second spoiler indicates you are still using build_module.bat. It's also indicated that you're using ModMerger. All of these are good tools to use but you need to decide which compiler you will be using, either W.R.E.C.K or build_module.bat. You can use ModMerger with build_module.bat and the "copy_n_forget" version of W.R.E.C.K. You cannot use ModMerger with WRECK if you are using full integration of WRECK. My suggestion is to use the "copy_n_forget" version of W.R.E.C.K because it's faster, has better error detection in some ways, provides hints to fix missing commas, color to help differentiate the compiling process and my favorite reason, because it can use ModMerger. Whichever compiler you choose, stick with it and it only. After you've chosen a compiler and have looked over your code using the forum as a means to reference, then post again with the issues you're having and maybe someone will be more inclined to help you.
 

Calabanar

Sergeant at Arms
You have messed python code unless you are trying to use modmerger with WRECK wich are not compatible. Do you have a backup? What code causes to break?



You need to clarify you steps. We are not mediums.
I wish I could tell, I tried using the source files of another mod (CTT), I suppose this is where the WRECK compiling comes from since I didn't install WRECK.

I think I'll try to salvage some of the files I made and start from scratch trying to use only one module builder, as you pointed (if I understood correctly).


Hi.
With that out the way, down to buisiness.

1.)
unassigned local variable <l.final_price_for_secondary_input[@1224979098644774926]> used by operation store_div in script.process_player_enterprise on line 48

This is saying that the local variable ":final_price_for_secondary_input" isn't assigned before it's used. Being "assigned" is the same thing as initializing a variable in other coding languages. To fix it, simply put (assign, ":final_price_for_secondary_input", 0), at the top of the script it's in. Since you're using ModMerger, as evident by some of the issues further along, you can inject this code with ModMerger or just search for the script in the source and put the code in that way. This won't cause issues as is, that I know of, but It's good practice to initialize variables.

2.)
local l.unused declared but never used in script.game_get_troop_wage
local l.unused declared but never used in script.debug_variables
local l.unused_2 declared but never used in script.debug_variables
local l.unused declared but never used in script.party_inflict_attrition

This is saying that these local variables are declared (assigned / initialized) but not used in their respective script. To fix these, simple find the script they're in and use them. Since they aren't originally used you can use them however you like. I simply multiplied them by 1. For example:
(val_mul, ":unused", 1), (val_mul, ":unused_2", 1), You can do this with either ModMerger or manually. These won't cause issues as is but again, good practice to keep everything clean.

From here your situation is a bit confusing which is probably why the other repliers are suggesting you to go back and learn some of the basics of modding M&BW with the Module System. Your first spoiler indicates you are using W.R.E.C.K and your second spoiler indicates you are still using build_module.bat. It's also indicated that you're using ModMerger. All of these are good tools to use but you need to decide which compiler you will be using, either W.R.E.C.K or build_module.bat. You can use ModMerger with build_module.bat and the "copy_n_forget" version of W.R.E.C.K. You cannot use ModMerger with WRECK if you are using full integration of WRECK. My suggestion is to use the "copy_n_forget" version of W.R.E.C.K because it's faster, has better error detection in some ways, provides hints to fix missing commas, color to help differentiate the compiling process and my favorite reason, because it can use ModMerger. Whichever compiler you choose, stick with it and it only. After you've chosen a compiler and have looked over your code using the forum as a means to reference, then post again with the issues you're having and maybe someone will be more inclined to help you.
Thank you, I really didn't know what steps to take when such errors come up, this was extremely useful advice!

I am aware my post is pretty hard to work with, I tried to show what I thought was relevant, thanks for soldiering through!

I will follow your advice. At first I thought I could frankenstein parts of mods I enjoyed that weren't truly OSP using what code looked complete (and probably some source files requiring different compilers that I didn't check properly at the time). I will try again nice and steady.

Thank your for your post, it was concise and easy to understand, which helps a ton!

I would do as Velendella advises, but it's a mod I started working on 1-2 years ago so I doubt I still have the right backups.

Back to square A! At least I know what to look for now!

Take care o/
 

Iron Sight

Sergeant
I wish I could tell, I tried using the source files of another mod (CTT), I suppose this is where the WRECK compiling comes from since I didn't install WRECK.
I understand the lure of using Custom Troop Trees as a base for your mod, I mean, just about every M&B player wishes to create their own troops in game at some point. HOWEVER: Please understand, that very specific mini-mod (CTT) is not beginner friendly. CTT is almost completely written in Python, which is related to, but not the same as the language used in the ModSys. If you use CTT source as a base you should expect issues when using just about any other mod, as it is not very compatible friendly. Honestly, I would advise to start with just about any other base source for understanding how this all works. If you insist on using CTT's source as a base, you will be mostly on your own because you won't know how to explain which details are necessary to fix what is broken because their is a lot you won't realize you need to know. With all these things being said, if you are like me, you've just accepted the challenge, with your hard-headed ass, lol. But for real, CTT has a steeper learning curve than most other mod sources. So expect headaches, learning, confusion, learning, "start over remarks", learning, maybe some help, learning and taking plenty of breaks to keep from being confused with headaches. Regardless, all the best to you, good luck. Cheers! 07
 

Calabanar

Sergeant at Arms
If you know what scripts you added to the ModSys, you may delete them and start once again. Alternatively, you may check this out to find a mod with that set of scripts implemented in order to refer to its codebase: https://forums.taleworlds.com/index.php?threads/list-osp-lsp-modifications.377920/.
Will do, thanks!
I understand the lure of using Custom Troop Trees as a base for your mod, I mean, just about every M&B player wishes to create their own troops in game at some point. HOWEVER: Please understand, that very specific mini-mod (CTT) is not beginner friendly. CTT is almost completely written in Python, which is related to, but not the same as the language used in the ModSys. If you use CTT source as a base you should expect issues when using just about any other mod, as it is not very compatible friendly. Honestly, I would advise to start with just about any other base source for understanding how this all works. If you insist on using CTT's source as a base, you will be mostly on your own because you won't know how to explain which details are necessary to fix what is broken because their is a lot you won't realize you need to know. With all these things being said, if you are like me, you've just accepted the challenge, with your hard-headed ass, lol. But for real, CTT has a steeper learning curve than most other mod sources. So expect headaches, learning, confusion, learning, "start over remarks", learning, maybe some help, learning and taking plenty of breaks to keep from being confused with headaches. Regardless, all the best to you, good luck. Cheers! 07
I'm starting to feel the curve's steepness! :grin:

I suppose I'll try to use an easier mod base to train with and make the troops I want using Morgh's Editor until the next pain striving brings me back to this mod held with sticks and glue (I just love CTT too much :p). In any case your feedback was incredibly helpful so I cannot thank you enough!

Have a good one and cheers! :party:
 
Top Bottom