Warband Refined & Enhanced Compiler Kit (v1.0.0 @ Mar 01, 2015)

Users who are viewing this thread

mercury19 said:
On that note, would it be more efficient to create a "header_constants" file and use that rather than a "module_constants" file, so that all constants get imported with the rest of the headers?

some of those constants came from header_XXX.py files (see Native), so they were already there. Example: knows_riding_1. WRECK moved them to dynamic code inside the compiler (hence why the import order matters).

you can decide what to do with the other constants (like the utility ones from module_troops and module_items). I would move them to their respective headers_XXXX.
 
kalarhan said:
you can decide what to do with the other constants (like the utility ones from module_troops and module_items). I would move them to their respective headers_XXXX.

Tried that with the troops ones, but got an error on knows_riding_1, so I think I'll just leave it as is. Functions can go to headers files, but I'll leave constants in their origin file or in module_constants for now. Thanks for all your help!
 
kalarhan said:
mercury19 said:
Wrecker v0.1 Beta
a suggestion: you can put your code on Github,... Then add it to your signature.

consider using regex (instead of the find function)

I'm back to working on this, I've got a proper github repository set up for it, link is in my sig  :grin:

What's the advantage of using regex over what I have now for finding the prefixes? In general regex looks a little beyond my level of knowledge atm, what's their purpose in general?

EDIT: got the import replacer working! Next I'll look into using a dict or second list so string can be replaced. I'll also include a full list of prefixes in the next release, so people don't have to remember/hunt for them all :razz:
 
mercury19 said:

kalarhan said:
and use a dict or a second array for the replacement (so you can include str_ to s.)

# using two arrays (lists)
old_identifier = ["str_", "itm_", ....]
new_identifier = ["s.", "itm.", ...]

# using a dict (key:value)
identifier = { "str_":"s." , "itm_":"itm." , ...)

couple examples on how you can connect different values (like "str" and "s") using arrays or a dict
 
kalarhan said:
# using two arrays (lists)
old_identifier = ["str_", "itm_", ....]
new_identifier = ["s.", "itm.", ...]

# using a dict (key:value)
identifier = { "str_":"s." , "itm_":"itm." , ...)

couple examples on how you can connect different values (like "str" and "s") using arrays or a dict

Ooh, I didn't think of that. I have a dict in there for the base prefix without the "_" or ".", but that looks way cleaner. Thanks for the tip!

As for regex I ended up using it to fix the issue where things like "up_" would get replaced with "up." because "p_" is an identifier, so now all I have left to do for full functionality is find a way to avoid all of the "str_" objects that aren't strings. Mostly the operations.
 
mercury19 said:
so now all I have left to do for full functionality is find a way to avoid all of the "str_" objects that aren't strings. Mostly the operations.

operations are numeric, so what you have is a variable name without any quotes like str_store_party_name. A quick way to distinct them from strings is using a regex/find string that uses the quote too. You can simple escape the special character using a slash like \"

once your tool is ready for release you should create a new thread (like this one) on the Forge, and PM the moderators to move it to the tools section

Cheers
 
kalarhan said:
operations are numeric, so what you have is a variable name without any quotes like str_store_party_name. A quick way to distinct them from strings is using a regex/find string that uses the quote too. You can simple escape the special character using a slash like \"

once your tool is ready for release you should create a new thread (like this one) on the Forge, and PM the moderators to move it to the tools section

Cheers

Turns out I was a bit off in my estimation of my progress, and how many exceptions to the rule there were. I was originally actually going to change all the quoted references to the WRECK style, but that turned out to be impossible due to special characters so I left them alone. I did end up finishing the tool though, it works perfectly for native (as far as I've tested), so I'm satisfied with that at least.

Which opens me up for my next idea...

Long story short, I want to see if there's a way to expand the WRECK injection system to work like modmerger.

I switched to the WRECK plugin system for the faster compiler, and its great, but the downside is that injections still require editing the source file, which means every time I install a plugin I have to do it again. Which is a lot because I have a tiny attention span and start new projects at least once a week. And I use a lot of plugins.

However, I'm a bit stumped. I figure that plugins are run through the same process as the module files, but I can't figure out how the compiler does it, or how mod merger does it for that matter. I've only done a little digging but I'm thinking this is way beyond "use google and ask questions to learn". Doesn't mean I won't try but I figured I'd ask if anyone who checks this thread would be willing to help?

I've set up a GitHub repository just in case anyone's interested: https://github.com/mercury19/A-study-in-modmerging
If not, well, I'm studying comp sci in school so at least I'll be getting practice :razz:

EDIT: On the off chance that someone sees this, I've moved the idea to this thread: https://forums.taleworlds.com/index.php/topic,361392.0.html
 
mercury19 said:
Long story short, I want to see if there's a way to expand the WRECK injection system to work like modmerger.

you can, but understand that there is a huge difference between implicit and explicit code injection. The first (modmerger style) may look easier to install, but leads to several bugs and maintenance issues if you intend to extend the mod further (not just install a few OSP, tweak some variables, and then move on). Explicit injection (WRECK style) is a safer choice for long term projects.

Think this way:

Native compiler ->    MBScript files -> compiles -> .txt files (for engine)
Modmerger      ->  Plugin files  ->  injects into modsys ->  MBScript files (in memory, usually you don't print them as files) -> compiles -> .txt files (for engine)
WRECK            ->  WRECK code -> process custom compiler -> MBScript files (in memory, same as above)  -> compiles -> .txt files (for engine)

you can combine the tools if you understand the process above. But I think you should create a new thread to discuss that.

Cheers



Vrishnak92 said:
What is the compatibility like with mods that utilize Warband Script Enhancer?

Should work fine, as the difference is that WSE extends the header_XXX.py files, which you can use with WRECK without any issues. Easy to test as well. Just convert a copy of your modsys to WRECK (10 minutes work), generate the .txt files and compare them using WinMerge (or other tool)
 
Hello! I'm having a problem figuring out one of WRECK's compilation errors.

I use WRECK to compile the module system, but it gives me these errors (note: the module system gets a "compilation successful" still):
Code:
  try/end operations do not match in mt.multiplayer_tdm(#38).repeat_trigger(1.0).body: 1 try_end(s) extra
  try/end operations do not match in mt.multiplayer_hq(#39).repeat_trigger(1.0).body: 1 try_end(s) extra
  try/end operations do not match in mt.multiplayer_cf(#40).repeat_trigger(1.0).body: 1 try_end(s) extra
  try/end operations do not match in mt.multiplayer_sg(#41).repeat_trigger(1.0).body: 1 try_end(s) extra
  try/end operations do not match in mt.multiplayer_bt(#42).repeat_trigger(1.0).body: 1 try_end(s) extra
  try/end operations do not match in mt.multiplayer_fd(#43).repeat_trigger(1.0).body: 1 try_end(s) extra
I've made a comparison of the version I used before I added a few scripts, comparing the mission_templates files in WinMerge. I cannot find any extra try_end's in my mission_templates files, as the files have no difference between them.

Even after I've read this explanation, it doesn't help me. So I got a few questions:
What does the "(#3:cool:" in the error mean? I'd guess it's the template value (as in, multiplayer_tdm is the 38th template).
Also, what does the ".repeat_trigger(1.0).body" part mean? A guess is that a repeat_trigger is either a trigger that's repeated (try_for_range etc). I can't figure out what the (1.0).body part means, not even guess :cry:

Thanks for any help! WRECK's awesome :party:
 
The #38 refers to its relative position inside the list of triggers for that mission template. triggers have a repeat interval, it's probably code that looks something like the following where the body is contained in the second set of square brackets, it could be a common trigger included in the multiplayer mission templates which would be defined at the top.
Code:
(1, 0, 0, [], []),
 
Somebody said:
The #38 refers to its relative position inside the list of triggers for that mission template. triggers have a repeat interval, it's probably code that looks something like the following where the body is contained in the second set of square brackets, it could be a common trigger included in the multiplayer mission templates which would be defined at the top.
Code:
(1, 0, 0, [], []),
Managed to find and add an extra try_begin where it was missing. Thank you! :smile:
 
Code:
*** 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... DONE.
Loading plugins... DONE.
Checking module syntax... DONE.
Allocating identifiers... DONE.
Compiling module... DONE.
Exporting module... FAILED.
COMPILER INTERNAL ERROR WHILE WRECKING tableaus:
Traceback (most recent call last):
  File "compile.py", line 392, in <module>
    with open('%s/%s' % (folder, filename[1]), 'w+b') as f: f.write(contents)
IOError: [Errno 2] No such file or directory: 'E:/steamapps/common/MountBlade Wa
rband/Modules/Bandit Wars/tableau_materials.txt'


COMPILATION FAILED.
Now, I just downloaded the thing, copied a native folder, and "tableau_materials" is right there, and it's a txt file. Moreover, line 392 just says:
Code:
with open('%s/%s' % (folder, filename[1]), 'w+b') as f: f.write(contents)
So, what?
 
Code:
*** 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... DONE.
Loading plugins... DONE.
Checking module syntax... FAILED.
MODULE `map_icons` ERROR:
failed to parse element #59
  cannot convert value -0.04 to integer


COMPILATION FAILED.

Press any key to continue . . .


how do i fix this ?
 
zidozido said:
Checking module syntax... FAILED.
MODULE `map_icons` ERROR:
failed to parse element #59
  cannot convert value -0.04 to integer

COMPILATION FAILED.

start by reading the error message
line 1: syntax has issues (failed validation)
line 2: it was checking file for map_icons, which is module_map_icons.py
line 3: it failed on element 59th, which means the 60th in the file. In other words, your 60th map icon has a syntax issue
line 4: you put the value "-0.04" in the wrong place

find your 60th map icon, fix the code, recompile
 
Madijeis said:
Code:
*** 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... DONE.
Loading plugins... DONE.
Checking module syntax... DONE.
Allocating identifiers... DONE.
Compiling module... DONE.
Exporting module... FAILED.
COMPILER INTERNAL ERROR WHILE WRECKING tableaus:
Traceback (most recent call last):
  File "compile.py", line 392, in <module>
    with open('%s/%s' % (folder, filename[1]), 'w+b') as f: f.write(contents)
IOError: [Errno 2] No such file or directory: 'E:/steamapps/common/MountBlade Wa
rband/Modules/Bandit Wars/tableau_materials.txt'


COMPILATION FAILED.
Now, I just downloaded the thing, copied a native folder, and "tableau_materials" is right there, and it's a txt file. Moreover, line 392 just says:
Code:
with open('%s/%s' % (folder, filename[1]), 'w+b') as f: f.write(contents)
So, what?

Double check your target file name is the same as what is in the code; I had that same problem, but apparently my target file name was different by one space.
 
I love this tool, but unfortunately the last update killed it. Please update! :/

It throws this strange error, while the default compiler is fine.

Code:
  unassigned local variable <l.final_price_for_secondary_input[@1224979098644774926]> used by operation store_div in script.process_player_enterprise on line 35
 
Innocuous said:
It throws this strange error, while the default compiler is fine.

you are missing the point. This tool adds more security layers to validate your code, so it will catch more errors than the Native compilers. Above is a example. The error is there, the compiler did not warn you about it, just that.

just add a assign 0 before that code to fix it.
 
Lav said:
You can do even more, though this is purely optional. See, while you have already enabled support for all W.R.E.C.K. advanced features, a lot of vanilla module system limitations still apply. Namely, you're still fully dependent on  ID_*.py files as module system code contains a lot of references to constants declared in those files. So you might want to replace all those references with W.R.E.C.K.-style dynamic references instead.

Once that is done, you can remove ALL other import directives from module_*.py files, leaving from compiler import * as the only import directive.
How do we do this? I'd really like to just copy the integrated ms but the module system version is 1.171 now.
 
Back
Top Bottom