[TOOL] X4 Customizer 1.23

The place to discuss scripting and game modifications for X4: Foundations.

Moderators: Moderators for English X Forum, Scripting / Modding Moderators

Nebulaewolf
Posts: 15
Joined: Thu, 3. Mar 11, 12:19
x3

Re: [TOOL] X4 Customizer 1.9

Post by Nebulaewolf » Thu, 31. Jan 19, 22:28

G'day SirNukes, I am usually only a humble texture/model modder and know very little about scripts or why they don't work when they don't work, but would there be any chance of building in an export command/button to the GUI, so that one could export the various tabs to csv/html as one went along? To either get baseline or diff/updated statistics onto a spread sheet as you went along?

Input:
# X4 Customizer input script.
from Plugins import *

# Write modified files to the output extension.
Write_To_Extension()

Print_Object_Stats(
Ships,
Ship_Stats,
None)

Output:
New script started
Saved script to "D:\Grant Downloads\Game Downloads\X4\Moddinig\Tools\X4 Customiser Tool\X4_Customizer_v1.9\Scripts\Ships_Print.py"
Saved Live Editor patches
Starting thread: Run(D:\Grant Downloads\Game Downloads\X4\Moddinig\Tools\X4 Customiser Tool\X4_Customizer_v1.9\Scripts\Ships_Print.py -argpass)
Calling D:\Grant Downloads\Game Downloads\X4\Moddinig\Tools\X4 Customiser Tool\X4_Customizer_v1.9\Scripts\Ships_Print.py
Cleaning up old files
Writing output files (diff encoded)
Successfully ran Write_To_Extension
Exception of type "NameError" encountered.

name 'Ship_Stats' is not defined
Script run completed

I've tried upper and lower case (Uppercase matches category) but file_name i can't get to work with either lower/uppercase, version not sure?
Print_Object_Stats(
category,
file_name,
version = None,
We have learned from our mistakes, and can now repeat them almost perfectly.

SirNukes
Posts: 546
Joined: Sat, 31. Mar 07, 23:44
x4

Re: [TOOL] X4 Customizer 1.9

Post by SirNukes » Fri, 1. Feb 19, 02:23

Nebulaewolf wrote:
Thu, 31. Jan 19, 22:28
would there be any chance of building in an export command/button to the GUI, so that one could export the various tabs to csv/html as one went along? To either get baseline or diff/updated statistics onto a spread sheet as you went along?
I put it on my todo list.

This function requires python string arguments, so an example might look like:

Code: Select all

from Plugins import *
Print_Object_Stats('ships', 'ship_stats')

Nebulaewolf
Posts: 15
Joined: Thu, 3. Mar 11, 12:19
x3

Re: [TOOL] X4 Customizer 1.9

Post by Nebulaewolf » Fri, 1. Feb 19, 06:13

G'day SirNukes, thank you again, the 'apostrophes' d'oh. Worked and I learnt something :)

One minor thing with the csv output, I think that because the data in the name, description etc fields in the xml are in the format {xxxxx, yyyyyy}; the output gets split over the T Name Entry and T Desc. Entry data fields in the output csv. I think it might be because the output is reading the comma as a separation: (please see example below)

Name---------------------------------T Name Entry---T Desc. Entry--- Codename--------Class
M Dumbfire Launcher Mk1 ----------{20105-------------2124}-----------{20105----------2122}
sorry about the dashes but it was the quickest way to tab out the info so that you could see where it is going


This not the same in the html output where it gets tabulated correctly:

Name--------------------------T Name Entry---T Desc. Entry-------------------------Codename------------------------Class
S Dumbfire Launcher Mk1--{20105,1124}----{20105,1122}---weapon_gen_s_dumbfire_01_mk1_macro---missilelauncher

This is a really great tool, I am still sorting out the spread sheets, but am looking forwarded to using your tool for some re-balancing and overhaul modding :)
We have learned from our mistakes, and can now repeat them almost perfectly.

Whatever0815
Posts: 45
Joined: Wed, 6. Mar 19, 06:02
x4

Re: [TOOL] X4 Customizer 1.9

Post by Whatever0815 » Sun, 10. Mar 19, 14:55

SirNukes,

just want to give you a pretty big Kudo for creating and sharing your X4 Customizer.

I've never used any mods for X4 before, let alone created one. In fact, the first time I ever saw the data structures was in your Customizer.

Pure gold being able to explore these structures, hack away at them using Python and your swiss army knife pms, then have the Customizer take care of the details of turning the results into a working mod.

Much appreciated :)

bobchocolat@gmx.fr
Posts: 5
Joined: Wed, 13. Mar 19, 11:37

Re: [TOOL] X4 Customizer 1.9

Post by bobchocolat@gmx.fr » Fri, 15. Mar 19, 09:35

Thanks you for your excellent ... thing ;)
I'm noob in python but I'm starting to understand how it works ...
On the other hand, the Cat_Pack does not pack the folder "index" that contain macro.xml with all mods ... I put the extensions folder that I previously Unpack (with you Cat_Unpack.bat) in the Cat_Pack.bat and it packs everything except the index folder and it does not indicate any error, just the number of less files that I had with the Unpack...
MapMarker is an exemple:
https://www.nexusmods.com/x4foundations ... ?tab=files
I imagine, perhaps wrongly, that there must be another script with the list of folders to pack ... that I can not find ...
If not, how to do it then ...
Sorry for googleTrad ;)
@+

SirNukes
Posts: 546
Joined: Sat, 31. Mar 07, 23:44
x4

Re: [TOOL] X4 Customizer 1.9

Post by SirNukes » Fri, 15. Mar 19, 20:42

1.9.1 is uploaded with fixes for the csv commas and the missed index folder. It should also detect script changes from outside the gui environment, if you prefer to edit scripts elsewhere.

I've actually been sitting on the "index" fix for a while, but have been neglecting to update this tool, for which I apologize. A couple months ago, I ported the gui framework from the Customizer over to my tool flow at work (where I have designed a couple many-core chips along with support tools for app development, compilation, simulation, chip testing, etc.). The drawback there is that the gui brought in more users to support, leaving less time available for X4 modding.

bobchocolat@gmx.fr
Posts: 5
Joined: Wed, 13. Mar 19, 11:37

Re: [TOOL] X4 Customizer 1.9.1

Post by bobchocolat@gmx.fr » Fri, 15. Mar 19, 22:55

Thank you Bro,
If someone has to apologize here, it's me who is not able to understand alone;)
Otherwise, I do not remember which mod I did not arrive at Unpack, it seems to me that it contained .sig, I will look later ...
Thanks again for the fix ...

SirNukes
Posts: 546
Joined: Sat, 31. Mar 07, 23:44
x4

Re: [TOOL] X4 Customizer 1.9.1

Post by SirNukes » Sat, 16. Mar 19, 02:19

The code currently skips sig files, to avoid cluttering up the files being tracked and on the assumption no one would ever need them. Though it sounds like some mods are using them, so I can look into adding support for them (perhaps only when packing catalogs).

SirNukes
Posts: 546
Joined: Sat, 31. Mar 07, 23:44
x4

Re: [TOOL] X4 Customizer 1.15.2

Post by SirNukes » Sat, 18. Apr 20, 03:31

Updated to 1.15.2. Lots of changes since the last post to this thread, but the more recent ones:

Scale_Sector_Size transform will dynamically rescale sectors, adjusting positions of zones, highways, god-placed objects, and the player hq. Highways remain functional.

Generate_Diffs is a new utility which can automatically create diff patch files by comparing a pair of input files, an original and a modded version. This works on individual files, or recursively over a directory.

Ferîx
Posts: 94
Joined: Thu, 12. Apr 12, 08:35
xr

Re: [TOOL] X4 Customizer 1.15.2

Post by Ferîx » Tue, 21. Apr 20, 10:26

SirNukes wrote:
Sat, 18. Apr 20, 03:31
Updated to 1.15.2. Lots of changes since the last post to this thread, but the more recent ones:
Thank you A LOT for this tool, really the one I've been missing all this time. Just began to explore the possibilities and I must say this thing is DEEP

edit:
I got something that looks like a bug: when I try to use print_weapon_stats plugin through the GUI I get this

Code: Select all

Could not print objects, error obtaining tree view for category "weapons".
but at the same time, when I fire the print_ware_stats it works fine and prints all I want.
The thing is, I managed to get the weapons print once, but deleted the files (as I didn't need them at the moment). Since then I get this error.

Win 10 up to date, x4 3.10 HF1 + split dlc, no modified game files (except extensions folder with mods, ofc)

edit2: the above seems to be resolved through deleting the extracted X4_Customizer_v1.15.3 folder completely except settings.json, restoring it from .zip and putting the settings.json back.

SirNukes
Posts: 546
Joined: Sat, 31. Mar 07, 23:44
x4

Re: [TOOL] X4 Customizer 1.15.2

Post by SirNukes » Tue, 21. Apr 20, 19:02

Ferîx wrote:
Tue, 21. Apr 20, 10:26
edit2: the above seems to be resolved through deleting the extracted X4_Customizer_v1.15.3 folder completely except settings.json, restoring it from .zip and putting the settings.json back.
If it happens again I can try looking into it. Also, there is a developer mode flag in the settings which will trigger a printout with more information on errors, such as a stack trace, which could help me track down an issue.

Ferîx
Posts: 94
Joined: Thu, 12. Apr 12, 08:35
xr

Re: [TOOL] X4 Customizer 1.15.2

Post by Ferîx » Wed, 22. Apr 20, 08:29

SirNukes wrote:
Tue, 21. Apr 20, 19:02
If it happens again I can try looking into it. Also, there is a developer mode flag in the settings which will trigger a printout with more information on errors, such as a stack trace, which could help me track down an issue.
I'll upload the folder if this happens again, everything works fine so far tho. Thanks again for the awesome tool!

Ferîx
Posts: 94
Joined: Thu, 12. Apr 12, 08:35
xr

Re: [TOOL] X4 Customizer 1.15.2

Post by Ferîx » Thu, 23. Apr 20, 07:37

Is it possible to add custom transforms to the list in the left window of the Script tab in GUI? I tried to modify Ships.py to only alter mass and inertia and save it as a separate script, but couldn't figure out how to make it work alongside with the original. I found some info on this in 'plugins/__init__' but messing with import here leads to errors starting the tool.

SirNukes
Posts: 546
Joined: Sat, 31. Mar 07, 23:44
x4

Re: [TOOL] X4 Customizer 1.15.2

Post by SirNukes » Thu, 23. Apr 20, 19:41

Ferîx wrote:
Thu, 23. Apr 20, 07:37
Is it possible to add custom transforms to the list in the left window of the Script tab in GUI? I tried to modify Ships.py to only alter mass and inertia and save it as a separate script, but couldn't figure out how to make it work alongside with the original. I found some info on this in 'plugins/__init__' but messing with import here leads to errors starting the tool.
Hm. As far as this goes, it's just a matter of navigating the python package import system. Adding a file to the Transforms plugin folder, and importing the function into the Transforms __init__, should be sufficient. Though it isn't ideal for extensibility, since __init__ would need another edit (or merge if going through git directly) each time the tool is swapped to a new version.

It's probably worth noting that anything done by a plugin transform can be done directly from a user script, maybe with some tweaks to the import paths, except for the gui window update.

Ferîx
Posts: 94
Joined: Thu, 12. Apr 12, 08:35
xr

Re: [TOOL] X4 Customizer 1.15.2

Post by Ferîx » Fri, 24. Apr 20, 13:18

SirNukes wrote:
Thu, 23. Apr 20, 19:41

it's just a matter of navigating the python package import system. Adding a file to the Transforms plugin folder, and importing the function into the Transforms __init__, should be sufficient.
Yeah, in fact it's just my very limited understanding of scripting prevented me from doing this successfully, though I get the basic flow here. Gonna mess with this more during the weekend and will post here in case of any luck. And before that, I'll stick to this method, 'cause I already got it working :arrow:
It's probably worth noting that anything done by a plugin transform can be done directly from a user script, maybe with some tweaks to the import paths, except for the gui window update.

alexu4326
Posts: 9
Joined: Mon, 7. Jan 19, 18:34
x2

Re: [TOOL] X4 Customizer 1.15.2

Post by alexu4326 » Fri, 1. May 20, 19:21

Writing output files
Skipped Write_To_Extension due to KeyError: "'virtual_path'".


trying to edit ships

so click edit ship
edit ships i want
click run script bang that error


what i do wrong ? ( expecting anithing because i am a moonkey and a noob same time )

SirNukes
Posts: 546
Joined: Sat, 31. Mar 07, 23:44
x4

Re: [TOOL] X4 Customizer 1.15.2

Post by SirNukes » Fri, 1. May 20, 20:05

Try clearing the "path_to_source_folder"; that shouldn't be needed in your case, and your error report helped me notice a bug in it anyway (will push a fix later today). Normally, the tool grabs everything it needs from the cat/dat files and other extensions.

alexu4326
Posts: 9
Joined: Mon, 7. Jan 19, 18:34
x2

Re: [TOOL] X4 Customizer 1.15.2

Post by alexu4326 » Fri, 1. May 20, 20:29

glad to help

so i edited some ships stats

done #Apply_Live_Editor_Patches()

but it not look like i do a mod ...

what is the next step to finish what i edited

sorry for me dumb head but is my first mod that i am working

SirNukes
Posts: 546
Joined: Sat, 31. Mar 07, 23:44
x4

Re: [TOOL] X4 Customizer 1.15.2

Post by SirNukes » Fri, 1. May 20, 20:36

I just uploaded 1.18.1 with a fix for the prior issue, and another one I noticed that showed up in 1.18 (which can cause diff generation to fail).

Just to clarify, the "#" character in python starts a comment line. So "#Apply_Live_Editor_Patches()" would be skipped, but "Apply_Live_Editor_Patches()" should generate the mod files based on your custom edits.

Realspace
Posts: 1342
Joined: Wed, 15. Nov 06, 10:21
x4

Re: [TOOL] X4 Customizer 1.15.2

Post by Realspace » Tue, 19. May 20, 20:08

Hi SirNukes, thanks a lot for this great tool, I am using the diff creator since editing a lot of entries in the material_library for this mod viewtopic.php?f=181&t=427042&p=4955974
It really solved my headache in the diff creation. Problem is, if I use a material_library containing only the entries I want to modify, then the patch that is created also deletes all the entries from the original matarial_library that I left untouched. Is there a command to add to avoid the originals being deleted if not edited by the mod?
Here the commands I used:

Code: Select all

# X4 Customizer input script.
from Plugins import *

# Example assumes xml files are in a "work" folder.
source_folder = r'E:\DATA_02\GAMES\X4 Foundations\EXTENSIONS\STARS\libraries'

# Single file example.
Generate_Diff(
    original_file_path = source_folder + r'/material_library_VANILLA.xml',
    modified_file_path = source_folder + r'/material_library_MYMOD.xml',
    output_file_path   = source_folder + r'/patch.xml',
    )
The resulting patch is ok but it deletes the parts I simply did not touch and did not put in mymod.xml, resulting as:

Code: Select all

<remove sel="/materiallibrary/collection[@name='p1']/material[@name='icecocoon2']"/>
  <remove sel="/materiallibrary/collection[@name='p1']/material[@name='pa_face_01_01b']"/>
  etc.
  etc
  
then comes the <replace> which is ok, works well. Only I have to delete all the <remove>, I am sure there must be a cleaner way to create the diff patch without this.
Thanks! :mrgreen:

Post Reply

Return to “X4: Foundations - Scripts and Modding”