String and class name problem

The place to discuss scripting and game modifications for X³: Terran Conflict and X³: Albion Prelude.

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

Post Reply
NewtSoup
Posts: 1405
Joined: Wed, 16. Nov 05, 13:33
x4

String and class name problem

Post by NewtSoup » Thu, 28. Aug 14, 01:03

why doesn't this work?

Code: Select all

$station.class= $station ->get object class
$isShipyard = find position of pattern 'Shipyard' in $station.class
the snippet always returns -1 even when get object class returns "Big Shipyard"
I am a rock in the wind, watch how I plummet!
Gamer Girl since 1981 Mistress of Heavy Landings since 1984 (BBC-B Elite)

Corei7 7700, 16GB Ram, MSI RX6700XT, Sidewinder FFB2, Kubuntu 22.04

User avatar
Joubarbe
Posts: 4796
Joined: Tue, 31. Oct 06, 12:11
xr

Post by Joubarbe » Thu, 28. Aug 14, 08:44

get object class does not return a string, so you cannot do that.

Code: Select all

do if $station.class == [Big Shipyard]
  $isShipyard = [TRUE]

NewtSoup
Posts: 1405
Joined: Wed, 16. Nov 05, 13:33
x4

Post by NewtSoup » Thu, 28. Aug 14, 09:08

Thank you, I thought that was probably it - I just couldn't work out how to get around it.

Thanks again.
I am a rock in the wind, watch how I plummet!
Gamer Girl since 1981 Mistress of Heavy Landings since 1984 (BBC-B Elite)

Corei7 7700, 16GB Ram, MSI RX6700XT, Sidewinder FFB2, Kubuntu 22.04

Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22229
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow » Mon, 1. Sep 14, 12:15

of course, you can convert any data type into a string if you wish to use string functions

Code: Select all

$station.class.string = sprintf: fmt='%s', $station.class
However, if you goal is to check if a station is a shipyard, then you can use,
$station -> is of class [Shipyard]

as classes are a hierarchy, so both Big and Small shipyards are also shipyard classes.

the get object class only returns the top level class, whereas the is of class function checks the whole hierarchy

Post Reply

Return to “X³: Terran Conflict / Albion Prelude - Scripts and Modding”