Did you know OpenAi/ChatGTP can create X4 mods?

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

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

Post Reply
User avatar
Hero77
Posts: 169
Joined: Tue, 29. Aug 17, 23:55
x4

Did you know OpenAi/ChatGTP can create X4 mods?

Post by Hero77 » Sun, 22. Jan 23, 20:26

I haven’t tested the mods, but the results appear pretty solid.

You can type: “ Write a mod for X4 foundations that …”

It defaults to replacing, but you can force it to use the cue-system as well if you specify it, e.g. “rewrite this mod using the cue system”.

https://beta.openai.com/playground
i7-5960X @4Ghz 8 Cores, RTX 2080 Founders Edition, 64GB DDR4 RAM

Newinger
Posts: 249
Joined: Mon, 11. Mar 19, 11:18
x4

Re: Did you know OpenAi/ChatGTP can create X4 mods?

Post by Newinger » Sun, 22. Jan 23, 22:47

At a first glance, GPT results are exciting, but in my experience with other programming and modding experiments with ChatGPT, the results were often quite wrong, incomplete and also often "invented" - the language model does not necessarily generate what is correct, but only what is "probable" in the text context, so it made up stuff out of thin air.

In another example, I asked it to generate source code for a quest mod for Daggerfall Unity (another game I like) and it did without any hesitation, but the result was mostly made up and nowhere in a usable state.

This said, a specialized language model could be created by training it with lots of real X4 script code.

User avatar
Hero77
Posts: 169
Joined: Tue, 29. Aug 17, 23:55
x4

Re: Did you know OpenAi/ChatGTP can create X4 mods?

Post by Hero77 » Fri, 27. Jan 23, 20:05

I think you are right.

At first glance it looks plausible, especially for small things, but the results are partly made up and dont work.

Still, would be cool to be able to train the AI further on this, maybe even generate some documentation.
i7-5960X @4Ghz 8 Cores, RTX 2080 Founders Edition, 64GB DDR4 RAM

magitsu
Posts: 402
Joined: Wed, 12. Dec 18, 21:59
x4

Re: Did you know OpenAi/ChatGTP can create X4 mods?

Post by magitsu » Fri, 27. Jan 23, 21:39

It has great potential for generating small talk and background stories. Proofreading one takes much less time than writing it from scratch.
This Bannerlord test with chatgpt gives some ideas:
https://youtu.be/qZCJsS4p380?t=50

Non-chatgtp Chatbots are also great. For example Stellaris mod Gigastructural Engineering (400k subscribers) has had them running for several months (not in the game but available for offline lore building). They are scary good, but with the usual flaws of being very overconfidently wrong in certain matters.

billw
Posts: 53
Joined: Wed, 1. Oct 08, 19:19
xr

Re: Did you know OpenAi/ChatGTP can create X4 mods?

Post by billw » Sat, 4. Mar 23, 19:35

I used ChatGPT today to generate a Powershell script that would create a wares.xml patch scaling all the module build costs, it did it: https://gist.github.com/billw2012/83544 ... 67e1dbc525
(I specified the Xml template to use in the output myself)

My prompts (run yourself to see output, I won't bother putting it here):
write a powershell script to process an xml. it should find nodes called "ware" with an attribute "id" that starts with the string "module_", then take the "time" attribute of the sub-node "production" and output it
...
okay now make it output instead a new xml file with the root node "diff", which then contains one "replace" node for each output item, where the "sel" attribute is of the form "//ware[@id='(ware.id)']/production/@time" and the content is the production time divided by 4
...
okay now assume there may be more than one production node differentiated by their "method" attribute, and output for each of them with the sel attribute formatted like "//ware[@id='(ware.id)']/production[@method='(method)']/@time"
...
modify it to take multiple input files, still producing one output
...
okay have it use all files called "wares.xml" anywhere under a specified directory (recursively) as input
...
okay modify so that it will find the "ware" nodes under any other nodes in the input
...
modify so it ignores nodes that have no id attribute
(final script here, although I modified it by hand to target /wares/ware instead of //wares while trying to fix an issue)


After this I tried to have it simply make the mod directly, rather than a script to help me make it, and it made stuff that isn't valid.
write me a mod xml for x4 foundations that changes the build times for all modules to be 90% of their original values
resulted in

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<modification>
    <name>Module Build Time Reduction Mod</name>
    <author>Your Name Here</author>
    <description>This mod reduces the build times for all modules to 90% of their original values.</description>

    <include file="types/ware.xml">
        <replace xpath="/ware[@tags='module']">
            <attribute name="buildTime" value="{round(@buildTime * 0.9)}" />
        </replace>
    </include>
</modification>
Which looks much better but isn't valid as far as I can tell.

magitsu
Posts: 402
Joined: Wed, 12. Dec 18, 21:59
x4

Re: Did you know OpenAi/ChatGTP can create X4 mods?

Post by magitsu » Sat, 4. Mar 23, 22:26

billw wrote:
Sat, 4. Mar 23, 19:35
I used ChatGPT today to generate a Powershell script
Pleasant surprise. This might cut a few corners, but it probably still requires most of the knowledge to test/fix. Perhaps not so much time saved as potentially another way to code it than one might do.

billw
Posts: 53
Joined: Wed, 1. Oct 08, 19:19
xr

Re: Did you know OpenAi/ChatGTP can create X4 mods?

Post by billw » Sun, 5. Mar 23, 18:59

magitsu wrote:
Sat, 4. Mar 23, 22:26
billw wrote:
Sat, 4. Mar 23, 19:35
I used ChatGPT today to generate a Powershell script
Pleasant surprise. This might cut a few corners, but it probably still requires most of the knowledge to test/fix. Perhaps not so much time saved as potentially another way to code it than one might do.
Well, I just pasted it into Powershell ISE and it worked, it didn't make any errors (ChatGPT seems especially good at Powershell, not sure why). I have done lots of Powershell before, but it would have taken me about 5 times as long if I had to look everything up that I couldn't remember, and develop it from scratch, as it was it only took 20 minutes or so and was very un-stressful. Of course it requires the knowledge of how the Xml files should be structured, I had to spend a bit of time learning that, as ChatGPT has no idea about X Foundation mods!

Post Reply

Return to “X4: Foundations - Scripts and Modding”