Specific debug info now showing up even with debug -all (Rebirth own script)

The place to discuss scripting and game modifications for X Rebirth.

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

Browser_ice
Posts: 488
Joined: Sun, 5. Feb 06, 17:15
x4

Specific debug info now showing up even with debug -all (Rebirth own script)

Post by Browser_ice »

Hi, I was just trying to check something out but it is not happening like I expected. I am not modifying anything. I am simply enabling debug (-debug all -logfile rebirth.log ) and looking for specific debug messages from scripts trade.performplayertraderun and trade.performtraderun.

I am looking for these specific debug infos:

performplayertraderun:
<debug_text text="player.age + ' CONGRATULATIONS, QUEUED TRADE RUN COMPLETE!'" chance="$debugchance" />

performtraderun:
<debug_text text="player.age + ' CONGRATULATIONS, TRADE RUN COMPLETE!'" chance="$debugchance" />


The only MOD I have that is related to trades is station push wares v2. It does not change these 2 scripts.

I let the game play for 20-30 min and I cannot find these debut messages in the enabled log file. I does not make sense. I have like 20 ships so either my ships or NPC's should have made some successfull trades in that time. I even have one ship that I sent doing 7 queued trades and it is down to 5 out of 7 but none of those debug messages show up.

About the only debug messages I see related to trading are those saying the ship is returning:
ex:
[Scripts] 386361.86 *** aicontext<trade.findtraderun,0x7f93>: returning to AL.AS.5-Staple Farmery 2 - Gigurum (Container)

This one is most probably from the Station push wares script.
Ubuntu 24.04 playing with ProtonDB
Intel I7-12700K
32Gb Memory
Nvgidia RTX-3060
UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader »

this is the "problem":
<debug_text text="player.age + ' CONGRATULATIONS, QUEUED TRADE RUN COMPLETE!'" chance="$debugchance" />

$debugchance is usually set to 0 / null so there is no chance these lines are executed at all.
And this is a good thing since it prevents the Debuglog from getting spammed with Messages irrelevant to you.

If you want to track a specific Script Instance you have to add some Code which changes this Var to a value of 100 - or, if you want to Track Player Stuff only, change the related Script with this diff file (written from head; may contain typos):

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<diff>
  <replace sel="/aiscript/params/param[@name='debugchance']/@default">this.container.isplayerowned * 100</replace>
</diff>
This Diff File should work for all AIScripts which contain an debugchance param, just name the File accordingly ;) (should also work to enable Debugging on Managers)
note that the change is not immediate, but the Script has to (re)start itself first to set the Var.
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)
Browser_ice
Posts: 488
Joined: Sun, 5. Feb 06, 17:15
x4

Post by Browser_ice »

Thx

I thought the replace command was only to replace a whole script.

Exactly which parts/sections of any script can be replaced in this manner ?
Ubuntu 24.04 playing with ProtonDB
Intel I7-12700K
32Gb Memory
Nvgidia RTX-3060
UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader »

everything you can Adress via XPath ;) so the smallest part would be the Attribute Value or the Character Data inside a Node:

<node attribute="value">character Data</node>

if there are specific Questions how to adress something best feel free to ask me directly ;) cannt easily explain this Stuff, but i have a good hang of it by now :)


and regarding the replace replacing everything: thats probably because its used mostly in this manner - its simpler to change a Script as whole than to cut your changes into small parts (especially its easier to keep track of that) - but the possibility is there ;) i personally recommend for extensive changes to copy the related Script into a new File and call it from within the original Script though (or change all references for it to the new Script) - this way you can also use xsd verification in an uncomplicated manner and you cannt break stuff as easily / simply remove it if problems arise ^^
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)
Browser_ice
Posts: 488
Joined: Sun, 5. Feb 06, 17:15
x4

Post by Browser_ice »

But replacing something in this manner suggest you can only target something that is named unique/once.

Otherwise if you have something you want to replace but it is created/existing/reinitialized more then once, then you cannot. Weather a variable or block of something.

Am I right in my assumption ?
Ubuntu 24.04 playing with ProtonDB
Intel I7-12700K
32Gb Memory
Nvgidia RTX-3060
UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader »

you need an unique identifier, yes.. but there are enough to choose from, here the Order i usually try to use them:

0. (MD only)
All my MD XPaths start with
//cue[@name="****"]
since that one is inherently unique in the File and for locating the change therefore a very good starting point



1. Attributes/Sub-Notes of previous Nodes:
given this example structure (irrelevant items omited to keep it short):

Code: Select all

<do_if>
  <do_if/>
  <do_else/>
</do_if>
<do_elseif>
  <do_if/>
  <do_else/>
</do_elseif>
<do_else>
  <do_if/>
  <do_else/>
</do_else>
you can Adress each <do_else/> with these:
//do_if/do_else
//do_elseif/do_else
//do_else/do_else
in the do_elseif case there might be a clarification needed which do_else is meant (usually with [@value='******'] )



2. Using Sub-Nodes and their Attributes (i think this is the case you refer to)
given the following Code:

Code: Select all

<do_if/>
<do_else>
  <do_something>
</do_else>
<do_if/>
<do_else>
  <do_something_else>
</do_else>
you can adress the first do_else with one of these:
//do_else/do_something/..
//do_else[do_something]

and the second with these two:
//do_else/do_something_else/..
//do_else[do_something_else]



9999. Extrem fallback when everything fails:
given these identical nodes (extreme case, didnt see something like this yet but could make sense for some things):

Code: Select all

<do_if value="$sucess">
  <continue/>
</do_if>
**** some code ***
<do_if value="$sucess">
  <continue/>
</do_if>
**** some code ***
<do_if value="$sucess">
  <continue/>
</do_if>
and you want to adress a specific do_if (for example the second) you can also use the Order in the File. I strongly discourage this method since it may break easily (referenced node logically changes) but this can always identify a specific node:
//do_if[@value='$sucess'][2]
not really pretty but it works as last resort


these are just as some general pointers, further reading available elsewhere:
http://www.w3schools.com/xsl/xpath_syntax.asp
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)
Browser_ice
Posts: 488
Joined: Sun, 5. Feb 06, 17:15
x4

Post by Browser_ice »

Hummmm, interesting.

THx for the info and the link too.
Ubuntu 24.04 playing with ProtonDB
Intel I7-12700K
32Gb Memory
Nvgidia RTX-3060
w.evans
Posts: 2963
Joined: Tue, 18. Nov 14, 16:23
x4

Post by w.evans »

Browser_ice wrote:But replacing something in this manner suggest you can only target something that is named unique/once.
You could either specify a very precise path to the node or attribute you wanted to change, or specify which subnode of that type it is in the script or within a node. Or sometimes, some combination of the two.

For example:

Code: Select all

<do_if value="false">
  <set_value name="$something"/>
  <set_value name="$nothing" exact="null"/>
  <do_if value="$nothing">
    <debug_text text="'UH OH: nothing is something!'" filter="error"/>
  </do_if>
  <do_else>
    <debug_text text="'all is well so far'" filter="$debugchance"/>
    <set_value name="$or_other"/>
  </do_else>
  <do_if value="$something and $or_other">
    <debug_text text="'still nothing broken'" chance="$debugchance"/>
    <do_if value="not $nothing">
      <debug_text text="'still good'" chance="$debugchance"/>
    </do_if>
    <do_else>
      <debug_text text="'UH OH: something and other, but nothing is something too!'" filter="error"/>
    </do_else>
  </do_if>
  <do_elseif value="$something">
    <debug_text text="'UH OH: something but no other!'" filter="error"/>
  </do_elseif>
  <do_elseif value="$or_other">
    <debug_text text="'UH OH: other but no something!'" filter="error"/>
  </do_elseif>
  <do_else>
    <!-- we're missing something here. what could that be? -->

  </do_else>
</do_if>
If you wanted to add something to that do_else with the space where someone forgot something:

Code: Select all

<add sel="//do_else">
  <debug_text text="'UH OH: something and other, but nothing is something too!'" filter="error"/>
</add>
won't work because there are multiple nodes called do_else.

What would work (or should. getting rusty with diff patches):

Code: Select all

<add sel="//do_if[@value='false']/do_else[2]">
    <debug_text text="'UH OH: there was something we did not think about. this should be unreachable.'" filter="error"/>
</add>
That is, the second <do_else> within <do_if value="false"></do_if>

ps. wonder if simply sel="do_else[3]" would work.

.....
Sorry got long. Had fun and got a bit carried away.

edit: whoops! missed Uni's post. his is clearer.
Browser_ice
Posts: 488
Joined: Sun, 5. Feb 06, 17:15
x4

Post by Browser_ice »

Lets say I want to change the debug default value for 3 diff scripts, would this do it ?


<?xml version="1.0" encoding="UTF-8"?>
<diff>
<replace sel="/aiscript[@name='trade.performtraderun']/params/param[@name='debugchance']/@default">100</replace>
<replace sel="/aiscript[@name='trade.performtraderun']/params/param[@name='debugchance2']/@default">100</replace>
<replace sel="/aiscript[@name='trade.performplayertraderun']/params/param[@name='debugchance']/@default">100</replace>
<replace sel="/aiscript[@name='trade.findtraderun']/params/param[@name='debugchance']/@default">100</replace>
</diff>

I though it would be simpler in one single overriting file.

Note: I have not coded any X scripts before, therefore do not assume I know stuffs that is granted by knowledge to you.
Ubuntu 24.04 playing with ProtonDB
Intel I7-12700K
32Gb Memory
Nvgidia RTX-3060
UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader »

you have to create a seperate file for each xml file you want to change (same path and name as the original file, but its located in your extension, not in the game root/extracted files), and i usually leave the root node without further identifiers since this way i can copy the file to change the same thing in other files to simplyfy stuff.

now to your specific case: you have to create 3 files inside your Extension (best make only one first and copy that then):
aiscripts/trade.performtraderun
aiscripts/trade.performplayertraderun
aiscripts/trade.findtraderun

and you can cover the change you want with this Code in each file:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<diff>
  <replace sel="/aiscript/params/param[@name='debugchance']/@default">100</replace>
  <replace sel="/aiscript/params/param[@name='debugchance2']/@default" optinal="true">100</replace><!-- also set second debugchance to 100 if present, dont print error if not present ( optional="true" ) -->
</diff>

be aware that this might quickly spam the debuglog with info you are not interested in (since NPC Ships in the whole universe use the first and last script)
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)
Browser_ice
Posts: 488
Joined: Sun, 5. Feb 06, 17:15
x4

Post by Browser_ice »

Hi again, it did not work like expected.
First I found out you did an error in your optional command.
Second, even using what I thought was the right syntax it does not recognize it.
ex:
[=ERROR=] 392321.69 When calling script trade.performtraderun on entity 0x1b4a - script parameter "debugchance2" was not provided!
[General] 392321.69 ======================================
[General] 392321.69 ======================================
[=ERROR=] 392321.69 Error in AI script trade.performtraderun on entity 0x1b4a: Property lookup failed: $debugchance2
* Expression: $debugchance2

I did a search in all aiscripts from vanilla and found no such commands in any PARMAMS nodes. Because of this, I have messages that are no longer displayed.

One of the missing message is something I need to understand why it is happening so often :
<do_if value="$amount == 0">
<set_value name="$failreason" exact="'ERR_NO_CARGO_SPACE'" />
<resume label="finish" />
</do_if>

I also discovered error messages related to some MODs I have. I think they just did not get updated properly with v4 of Rebirth.
Ubuntu 24.04 playing with ProtonDB
Intel I7-12700K
32Gb Memory
Nvgidia RTX-3060
UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader »

sounds to me like you changed the <replace/> into <remove/> - and with that removed the initial value this Var is supposed to have if nothing else is passed as a param (now the Var does not exist and the related <debug_text/> lines print an error because they cannot resolve the chance value.. )

also are there any
Cannot match path
errors in the beginning of the Log? that usually means there are none or more than one Node the Path resolves to. there shouldnt be ( i just checked in trade.performtraderu and both paths have exactly one result
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)
Browser_ice
Posts: 488
Joined: Sun, 5. Feb 06, 17:15
x4

Post by Browser_ice »

Forgot to mention somethin. I was tired so I did not finish my thread with all the infos.

1) I figured the most probably cause of not having the debug info processed was probably because its variable debugchance already had a value upon entering the scripts. So just putting default="0" would actualy do nothing in my opinion if it had been set before.

2) thinking about the above mention, I thought it would be better to just put in the value 100. So I tried to use exact="100" but again because I was tired I resorted to do the following instead.

ex for trade.findtraderun.xml

<?xml version="1.0" encoding="UTF-8"?>
<diff>
<replace sel="/aiscript/params">

<params>
<param name="warelist" />
<param name="range" />
<!--TODO: Support sellrange and buyrange for station working trade ships-->
<param name="sellrange" default="null" comment="TODO"/>
<param name="buyrange" default="null" comment="TODO"/>
<param name="lasttrade" default="null" comment="list: [$buyoffer, $ware, $tradepartner]"/>
<param name="debugchance" exact="100"/>
<param name="debugchance2" optional="true" exact="100" comment="more spammy"/>
</params>
</replace>
</diff>


3) with the above that is when I started to have error messages bout debugchance2. Could not find optional="" anywhere in any aiscript. So it must be a wrong command.

4) I checked for any error path in the log and found none for the 3 scripts I changed. There were some but for other MODs I had installed.
Ubuntu 24.04 playing with ProtonDB
Intel I7-12700K
32Gb Memory
Nvgidia RTX-3060
jth
Posts: 296
Joined: Tue, 3. Jan 06, 23:31
x3

Post by jth »

What I do to debug trade.performtraderun is to find a unique identifier in the script, in this case a label, and tack some code after it to change $debugchance and $debugchance2 for player ships only.

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<diff>
  <!-- Turn on trade debug -->
  <add sel="/aiscript[@name='trade.performtraderun']['Turn on debug']/attention[@min='unknown']/actions/label[@name='perform trade']" pos="after">
    <do_if value="this.ship.owner == faction.player">
      <set_value name="$debugchance" exact="100" />
      <set_value name="$debugchance2" exact="100" />
    </do_if>
  </add>

</diff>
I created a mini mod of this code on Nexus so that Steam players could add the debug without having to run a different version of the main mod.

Instructions from my [MOD] Free player to player trades v0.01 23 August 2016 say

To enable full debuging of trade transactions install the optional trade_performtraderun_debug mini mod from Nexus

http://www.nexusmods.com/xrebirth/download/2220

jth
PS Yes you are right that
[Scripts] 386361.86 *** aicontext<trade.findtraderun,0x7f93>: returning to AL.AS.5-Staple Farmery 2 - Gigurum (Container)
comes from Station push wares

Return to “X Rebirth - Scripts and Modding”