Help with a string comparison issue

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

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

User avatar
YorrickVander
Posts: 2774
Joined: Tue, 29. Oct 13, 21:59
x4

Help with a string comparison issue

Post by YorrickVander »

Hey all,

I've hit on an issue, which isn't crucial to the mod, but would be nice to solve all the same.

Code: Select all

<do_if value="$lBuys.{$i}.ware.tags.{$j} == 'economy'">
   <show_help custom="'rawr'" /> 
</do_if>
Now with a normal string comparison this works fine. In this case the string returned from the indexed .tag list fails the comparison with the printed result of that tag.

if i print the .tag attribute i see for example [tag.economy,tag.liquid] result. If I print tag.{1} i see economy as expected. when i if tag.{1} == 'economy' it comes out false which is not expected :(

Any ideas as to what's happening here?
X Rebirth - A Sirius Cybernetics Corporation Product

Split irritate visiting pilot with strange vocal patterns.
UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader »

there are no strings in that list but tags ;) use tag.economy without ' ' ;)

or better try this:

Code: Select all

<do_if value="$lBuys.{$i}.ware.tags.indexof.{tag.economy} > 0">
   <show_help custom="'rawr'" />
</do_if>
simpler solution than testing each entry of the list by itself ;) (it returns the index no. of tag.economy in the list; it may be possible to omit the '> 0' but not sure)
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 ;)
User avatar
YorrickVander
Posts: 2774
Joined: Tue, 29. Oct 13, 21:59
x4

Post by YorrickVander »

Hah! nice one, most appreciated :D

EDIT : working perfectly, and yes can omit the > 0 -hug-
X Rebirth - A Sirius Cybernetics Corporation Product

Split irritate visiting pilot with strange vocal patterns.

Return to “X Rebirth - Scripts and Modding”