How do I get a list of player stations?

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

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

cupoma
Posts: 12
Joined: Fri, 15. Nov 24, 09:13

How do I get a list of player stations?

Post by cupoma »

Hello. I'm trying to compile a list of the player's stations into a table. I watched how others do it, I watched the unpacked scripts, but it doesn't work. I need a hint.

It doesn't work that way:
Spoiler
Show

Code: Select all

<find_station name="$station" owner="faction.player" space="player.galaxy" multiple="true"/>
<debug_text text="$station + ' ' + $station.name"/>
It doesn't work that way either:
Spoiler
Show

Code: Select all

<find_station name="$station" owner="faction.player" space="player.galaxy" multiple="true"/>
<debug_text text="$station + ' ' + $station.knownname"/>
And it doesn't work that way either:
Spoiler
Show

Code: Select all

<find_station name="$station" owner="faction.player" space="player.galaxy" multiple="true"/>
<debug_text text="$station + ' ' + $station.debugname"/>
in all variants $station.name, $station.knownname, $station.debugname - it is equal to null
Debug:

Code: Select all

 Property lookup failed: name
[=ERROR=] 53.27 Error in MD cue md.{'xxxr'}.xxx<inst:155cf3>: Property lookup failed: $station.[null]
[Scripts] 65.24 *** Context:md.{'xxx'}.xxx<inst:1588db>: [component.{0x5301bL},component.{0x5355eL}] null
User avatar
euclid
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 13486
Joined: Sun, 15. Feb 04, 20:12
x4

Re: How do I get a list of player stations?

Post by euclid »

In your case $station is an array and needs counter For example $station.{1}.knownname will give the name of the first station in the array. You could do it in a loop with counter $i$ as $station.{$i$},knownname but If you want to generate a table then you need to define one first and then fill it.

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
cupoma
Posts: 12
Joined: Fri, 15. Nov 24, 09:13

Re: How do I get a list of player stations?

Post by cupoma »

euclid wrote: Tue, 26. Nov 24, 22:11 In your case $station is an array and needs counter For example $station.{1}.knownname will give the name of the first station in the array. You could do it in a loop with counter $i$ as $station.{$i$},knownname but If you want to generate a table then you need to define one first and then fill it.

Cheers Euclid
Thank you for the answer, you are the first person who has answered at least one of my questions at all. With a few changes to your advice, I managed to do what I needed.

Return to “X4: Foundations - Scripts and Modding”