.
Go to solution
I'm trying to get a date/time string to use in my debug filename in an aiscript but it keeps causing "illegal filename" errors in the debug log.
First I tried:
<set_value name="$debugFile" exact="md.$SystemTimeAtGamestart + '_' + this.ship.name + ' (' + this.ship.idcode + ')' + '_log.txt'"
and it resulted in "Invalid property lookup: md.$SystemTimeAtGamestart"
Then I tried:
<set_value name="$debugFile" exact="player.systemtime.{'%Y-%m-%d_%H-%M-%S'} + '_' + this.ship.name + ' (' + this.ship.idcode + ')' + '_log.txt'"
and it resulted in "illegal filename: null_Elite Vanguard (NPC-168)_log.txt"
According to scriptproperties.xml, player.systemtime.{$string} uses standard C++ formatting options %Y = 4-digit year, %m = 2-digit month, etc.
Invalid filename (formerly: player.systemtime returns null) [SOLVED]
Moderators: Moderators for English X Forum, Scripting / Modding Moderators
Invalid filename (formerly: player.systemtime returns null) [SOLVED]
Last edited by user1679 on Wed, 31. Aug 22, 05:00, edited 2 times in total.
Re: player.systemtime returns null
I suspect the ship's details causing trouble here because both, md.$SystemTimeAtGamestart and player.systemtime.{'%Y-%m-%d_%H-%M-%S'}, working fine for me. Btw. both are related (see md>setup.xml line 78) via
Cheers Euclid
Code: Select all
<set_value name="md.$SystemTimeAtGamestart" exact="player.systemtime.{'%Y-%m-%d_%H-%M-%S'}" />
"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
- Immanuel Kant (1724-1804), Metaphysical Foundations of the Science of Nature, 4:470, 1786
Re: player.systemtime returns null
Thanks, that's where I got the idea when md.$SystemTimeAtGamestart didn't work.euclid wrote: ↑Tue, 30. Aug 22, 14:50I suspect the ship's details causing trouble here because both, md.$SystemTimeAtGamestart and player.systemtime.{'%Y-%m-%d_%H-%M-%S'}, working fine for me. Btw. both are related (see md>setup.xml line 78) viaCheers EuclidCode: Select all
<set_value name="md.$SystemTimeAtGamestart" exact="player.systemtime.{'%Y-%m-%d_%H-%M-%S'}" />
You're right, the ship info was causing an illegal filename. Though I don't know why since there are
no illegal characters for a Windows filesystem in null_Elite Vanguard (NPC-168)_log.txt
This works:
<set_value name="$debugFile" exact="player.systemtime.{'%Y-%m-%d_%H-%M-%S'} + '_log.txt'" />
Not sure why md.$SystemTimeAtGamestart can't be invoked from an aiscript. The exact error is:
[=ERROR=] 149.31 Error in AI script test_aiscript on entity 0x144223: Property lookup failed: md
* Expression: md.$SystemTimeAtGamestart + '_log.txt'
* Action: <set_value>, line 66
Re: player.systemtime returns null
.
SOLUTION
So it appears that even though () or [] are valid characters for a filename, the filewriter used by X4 doesn't allow it.
This works:
<set_value name="$debugFile" exact="player.systemtime.{'%Y%m%d-%H%M%S'} + '_' + this.ship.name + this.ship.idcode + '.log'"
and results in: 20220830-224509_Elite Sentinel ZDS-839.log
But this doesn't work:
<set_value name="$debugFile" exact="player.systemtime.{'%Y%m%d-%H%M%S'} + '_' + this.ship.name + ' (' + this.ship.idcode + ').log'"
and results in a debug log error:
SOLUTION
So it appears that even though () or [] are valid characters for a filename, the filewriter used by X4 doesn't allow it.
This works:
<set_value name="$debugFile" exact="player.systemtime.{'%Y%m%d-%H%M%S'} + '_' + this.ship.name + this.ship.idcode + '.log'"
and results in: 20220830-224509_Elite Sentinel ZDS-839.log
But this doesn't work:
<set_value name="$debugFile" exact="player.systemtime.{'%Y%m%d-%H%M%S'} + '_' + this.ship.name + ' (' + this.ship.idcode + ').log'"
and results in a debug log error:
[=ERROR=] 142.00 Error in AI script test_aiscript on entity 0x14a03b: Illegal file name '20220830-225443_Elite Sentinel (IZR-477).log'
* Expression: $debugFile
* Action: <debug_to_file>, line 220