Help with scripting

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

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

bhorton22
Posts: 53
Joined: Sun, 29. Aug 10, 22:30
x4

Help with scripting

Post by bhorton22 »

I am trying to place a new keywork that has been introduced in 8.0 into the wares.xml file.

In particular the line:

<ware id="modpart_enginefuelinjector_t1" name="{20201,30301}" description="{20201,30302}" transport="inventory" volume="1" tags="crafting equipmentmodpart inventory primarymodpart">

I want to add the following:

group="generalitem"

It goes after the:
<ware id="modpart_enginefuelinjector_t1" name="{20201,30301}" description="{20201,30302}"

and before:

transport="inventory" volume="1" tags="crafting equipmentmodpart inventory primarymodpart">

I have:

<add sel="//ware[@id='modpart_enginefuelinjector_t1' name='{20201,30301}' description='{20201,30302}']" pos="after"> group="generalitem"

but that, obviously, doesn't work.

Can someone point me in the right direction and tell me what I am doing wrong?
User avatar
chew-ie
Posts: 6655
Joined: Mon, 5. May 08, 00:05
x4

Re: Help with scripting

Post by chew-ie »

I'm no "modder", so these are only basic XML pointers:
<add sel="//ware[@id='modpart_enginefuelinjector_t1' name='{20201,30301}' description='{20201,30302}']" pos="after"> group="generalitem"
This is no valid XML. It contains quotation errors and the group attribute is outside of the add tag. There is also an invalid / incomplete sequence in the description attribute (']). The sel attribute is incomplete as well.

Cleaned up version:

Code: Select all


<add 
    sel="//ware[@id='modpart_enginefuelinjector_t1']"
    name="{20201,30301}"
    description="{20201,30302}" 
    pos="after"
    group="generalitem"
/>
Note: I only checked for basic XML errors, not the content itself.

---

edit: since you want to add an attribute to a tag the formal way of doing so is this:

https://datatracker.ietf.org/doc/html/r ... tion-4.3.2

note: again, this is pure XML stuff. Wether or not that new attribute is processed by X4 I do not know.
Image
Spoiler
Show
BurnIt: Boron and leaks don't go well together...
Königinnenreich von Boron: Sprich mit deinem Flossenführer
Nila Ti: Folgt mir, ihr Kavalkade von neugierigen Kreaturen!
Tammancktall: Es ist eine Ehre für sie mich kennenzulernen...
CBJ: Thanks for the savegame. We will add it to our "crazy saves" collection [..]

:idea: Feature request: paint jobs on custom starts
bhorton22
Posts: 53
Joined: Sun, 29. Aug 10, 22:30
x4

Re: Help with scripting

Post by bhorton22 »

The tag is the new tag introduced in 8.0 for the crafting work bench. It is how it decides which tab the item will appear under.

I try your code and run in debug, see if it adds the tag in between the description tag and transport tag
User avatar
ChemODun
Posts: 436
Joined: Mon, 12. Feb 07, 21:58
x4

Re: Help with scripting

Post by ChemODun »

There is a guide how to write a diff files [TUTORIAL] XML Patch Guide

And in case of adding the attribute diff should look like:

Code: Select all

<add sel="//ware[@id='modpart_enginefuelinjector_t1']"  type="@group">generalitem</add>
For may be faster answer welcome to Egosoft Discord, and choose then x4_modding channel :-)
Last edited by ChemODun on Thu, 31. Jul 25, 16:52, edited 1 time in total.
Multiply entropy by absolute zero

Freedom in space
bhorton22
Posts: 53
Joined: Sun, 29. Aug 10, 22:30
x4

Re: Help with scripting

Post by bhorton22 »

No, that didn't add the tag either, it complains that the syntax is wrong. Any other ideas? I've reading the documentation link you posted, but seems to say what you posted is correct, but it isn't (or at least it error's out in the debug log).
bhorton22
Posts: 53
Joined: Sun, 29. Aug 10, 22:30
x4

Re: Help with scripting

Post by bhorton22 »

ChemODun wrote: Thu, 31. Jul 25, 14:45 There is a guide how to write a diff files [TUTORIAL] XML Patch Guide

And in case of adding the attribute diff should look like:

Code: Select all

<add sel="//ware[@id='modpart_enginefuelinjector_t1']"  type="@group">generalitem</>
For may be faster answer welcome to Egosoft Discord, and choose then x4_modding channel :-)
No, that still did not add the tag, still gives a syntax error in the debug log (it didn't like the 'type=') and the statement does not end correctly.
User avatar
ChemODun
Posts: 436
Joined: Mon, 12. Feb 07, 21:58
x4

Re: Help with scripting

Post by ChemODun »

Let's study the guide and do it by own hands.

Only one thing - structure for adding the attribute is right, I simple made error in xml closing tag.
And this is loaded for me without errors ....

Code: Select all

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<diff>
  <add sel="/wares/ware[@id='modpart_enginefuelinjector_t1']" type="@group">generalitem</add>
</diff>
Multiply entropy by absolute zero

Freedom in space
User avatar
ChemODun
Posts: 436
Joined: Mon, 12. Feb 07, 21:58
x4

Re: Help with scripting

Post by ChemODun »

Do you have any progress?
Multiply entropy by absolute zero

Freedom in space

Return to “X4: Foundations - Scripts and Modding”