Modding question

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

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

Assailer
Posts: 478
Joined: Sun, 25. May 14, 17:45
x4

Modding question

Post by Assailer »

Is it possible to check whether a specific ship name contains a certain text?

I'd like to find all ships with name starting with [WING1].

Not familiar what kind of string operations X:RB implements...


Thanks!
UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader »

with a workaround of abusing substitute_text yes, but thats the only supproted one. locating the position of a sub-string is sadly missing as i noticed lately.
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 ;)
Assailer
Posts: 478
Joined: Sun, 25. May 14, 17:45
x4

Post by Assailer »

<substitute_text> only replaces matched texts with a specified one, not sure how to recognize patterns with this.

I need function to see whether a certain sub-string is contained in the original text which will be part of a condition/filter.

My exact use case is:
"Find all the player ships in zone with [WING2] in their names."
I'm thinking about wing management through naming the ships.


Could we request the addition of such atomic function?
UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader »

well, as i said its a non-obvious workaround:

<substitute_text text="$check" source="$name">
<replace text="'[Wing1]'" with="''"/>
</substitute_text>
<do_if value="$check != $name"/>
..........




i would also need such functions for my Name Managment Script Project, but currently they are neither in ai/md nor in lua


EDIT: Corrected code (was on typing on originally)
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 ;)
Assailer
Posts: 478
Joined: Sun, 25. May 14, 17:45
x4

Post by Assailer »

Thanks!

Hopefully it's not a big performance hit to analyze ~100 ships names.

Return to “X Rebirth - Scripts and Modding”