Overwriting scripts

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

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

Post Reply
oxylos
Posts: 32
Joined: Sat, 2. Aug 08, 19:45

Overwriting scripts

Post by oxylos » Sat, 11. Sep 21, 17:27

hi,

im new to this, but read tutorials etc. I'm trying to modify the mining.collect.drone.xml script, to fix some mining drone faults on player ships.
I made a new version of this script and put it into Extensions/mymod/aiscripts. Content.xml is correct and the extensions is shown in settings.
But somehow the new script seems not to be executed. To test, (bad tast method) i added at start label <destroy_object object="this.ship" explosion="true" /> :D
so every mining drone should explode, but nothing happens.
Looks like i'm on a wrong way. Any ideas?

User avatar
euclid
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 13288
Joined: Sun, 15. Feb 04, 20:12
x4

Re: Overwriting scripts

Post by euclid » Sat, 11. Sep 21, 17:56

If a script is already running then a new version will not do anything. Try to purchase a miner or at least a few mining drones. Your script should run on those.

Cheers Euclid
"In any special doctrine of nature there can be only as much proper science as there is mathematics therein.”
- Immanuel Kant (1724-1804), Metaphysical Foundations of the Science of Nature, 4:470, 1786

oxylos
Posts: 32
Joined: Sat, 2. Aug 08, 19:45

Re: Overwriting scripts

Post by oxylos » Sun, 12. Sep 21, 22:44

Thank you! But after trying many things, it still doesn't work. I did read, there is a console command to reload ai scripts, could this reduce testing time?
Another question: i did manage to create logs of the game, but there are no script entries visible, is for default scripts debug_to_file needed?
For existing log commands in scripts like <debug_text text="'input destination, %s %s %s, does not exist.'.[$destination.{1}.class, $destination.{1}.knownname, $destination.{1}]" filter="error"/>
where goes this "debug_text" in which file?

User avatar
euclid
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 13288
Joined: Sun, 15. Feb 04, 20:12
x4

Re: Overwriting scripts

Post by euclid » Mon, 13. Sep 21, 13:15

Scripts run on NPCs, board computers etc. and leave a corresponding trace in you saved game. To run a modified script you would need to restart the existing. For example, if you run a script on the captain of a ship you need to stop it and then start it again. This can be tricky in your case as the mining script is running on many NPCs.

Concering the debug output, you should find it in the document folder where your saved games are stored. Personally I prefer the "debug_to_file" command as it provides a better overview. For example

Code: Select all

<debug_to_file name="$name" directory="'Euclid'" text="'Number of Stations:' + $Twares.count + ' faction:' + $factions.{$k} " output="false" append="true" /> 
which is executed over a loop over "$k". It will generate a directory "Euclid" in the debug folder with a file "$name" and append all outputs into it. However, in any case you need an extended executable to enable the debug output which should look like this

Code: Select all

"E:\Games\Steam\SteamApps\common\X4 Foundations\X4.exe" -logfile debuglog.txt  -scriptlogfiles 
Hope that helps,

Cheers Euclid
"In any special doctrine of nature there can be only as much proper science as there is mathematics therein.”
- Immanuel Kant (1724-1804), Metaphysical Foundations of the Science of Nature, 4:470, 1786

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

Re: Overwriting scripts

Post by SirNukes » Mon, 13. Sep 21, 20:01

oxylos wrote:
Sat, 11. Sep 21, 17:27
I made a new version of this script and put it into Extensions/mymod/aiscripts. Content.xml is correct and the extensions is shown in settings.
But somehow the new script seems not to be executed.
Did you format the edited script as a full replacement diff patch?

oxylos
Posts: 32
Joined: Sat, 2. Aug 08, 19:45

Re: Overwriting scripts

Post by oxylos » Wed, 15. Sep 21, 18:10

Oh no, i didnt use the diff style. Sorry for asking a question that is discussed here for years. I said i'm new to it :)
With diff i could replace the whole script with my version, drones are exploding like fireworks now :D

Now i can debug why sometimes drones disappear when they try to land on an occupied pad.

oxylos
Posts: 32
Joined: Sat, 2. Aug 08, 19:45

Re: Overwriting scripts

Post by oxylos » Thu, 16. Sep 21, 21:22

Thank you for your help, i found the reason for the bug, why mining drones sometimes vanish (from ship inventory too) whey they land on a captial ship pad.
This happens when the ship is player controlled.

I'm not sure how to properly fix it, should i start new thread about this or discuss it here?

User avatar
euclid
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 13288
Joined: Sun, 15. Feb 04, 20:12
x4

Re: Overwriting scripts

Post by euclid » Fri, 17. Sep 21, 14:03

If it's an issue with a vanilla game then you should post a bug report it in the Public Test Forum. But please follow the formal requirements (game version, steps to reproduce etc.). Otherwise feel free to open a new post here.

Cheers Euclid
"In any special doctrine of nature there can be only as much proper science as there is mathematics therein.”
- Immanuel Kant (1724-1804), Metaphysical Foundations of the Science of Nature, 4:470, 1786

oxylos
Posts: 32
Joined: Sat, 2. Aug 08, 19:45

Re: Overwriting scripts

Post by oxylos » Fri, 17. Sep 21, 15:29

There are now other people discovered this bug:
https://www.reddit.com/r/X4Foundations/ ... ng_in_410/

I got a fix for that (not sure i did it the properly way) so i'll post it as mod.

Post Reply

Return to “X4: Foundations - Scripts and Modding”