scriptproperties.html vs usage of this.ship.*

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

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

Post Reply
Browser_ice
Posts: 231
Joined: Sun, 5. Feb 06, 18:15

scriptproperties.html vs usage of this.ship.*

Post by Browser_ice » Sun, 1. Oct 17, 20:19

Hi, I am having difficulties to find out in the scriptproperties.html which section covers usages of this.ship.commander & this.ship.knownname. I mean I cannot find which basic keyword has both them in its property list.

I thought maybe it is because this.ship was derived from an object, so I went looking at the properties of Object and both above properties are not in it.

Its neither ship.*, nor container.*, nor component.*

Is it because this.ship.commander and this.ship.knowname are considered two different objects/entities?

I was hoping that by finding to which basic keyword they refer to, I could then see what other properties I can use (this.ship.*).
Steam X-Superbox, playing XR
WIndows-7
Intel I5
16Gb Memory
Nvgidia GT 960

UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 13817
Joined: Sun, 20. Nov 05, 23:45

Post by UniTrader » Mon, 2. Oct 17, 00:04

first clarify if you mean ai scripts or md scripts because the meaning of "this." is diffrent in both:
MD: the current cue
AI: the Entity which executes the Script

in the former case this.ship makes no sense and resolves to null with an error in the log i think.
in the latter case this.ship is the Ship on which the npc executing the script is currently on.

then next what knownname and commander means in aforementoined context:
.commander refers to the Superior Object, like the Station a Ship is assigned to.
.knownname results in the Name of the Ship, and always the real name regardless of wheter the player knows it or not (just .name can resullt in "Unknown Object" if the player currently doesnt know the real name)

i am also confused a bit by this question:
Is it because this.ship.commander and this.ship.knowname are considered two different objects/entities?
because one of them results in another Object, and the other results in a text/string, which are both completely diffrent things...

also "this." itself is a base keyword, there is no other keyword where it acts as sub-keword.


and regarding the usage of the scriptproperties.html: it is not aware of * or other placeholders. if you want to see all sub-keywords of this.ship then just type this.ship.
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 ;)

Browser_ice
Posts: 231
Joined: Sun, 5. Feb 06, 18:15

Post by Browser_ice » Mon, 2. Oct 17, 00:53

Thx for the reply.

I meant for AI scripts, related to ship actions.

if you take the AI script mining.ship.station.xml and look at the following code from it:

Code: Select all

      <do_if value="this.ship.cargo.capacity" max="0">
        <debug_text text="'%1 has cargo capacity of %2!'.[this.ship.knownname, this.ship.cargo.capacity]" chance="$debugchance" />
        <set_value name="$failreason" exact="'ERR_NO_CARGOSPACE'" />
        <resume label="finish" />
      </do_if>
      <do_if value="not this.ship.commander.exists">
        <debug_text text="'%1 in %2: mining without commander not supported!'.[this.ship.knownname, this.ship.zone.knownname]" chance="$debugchance" />
        <set_value name="$failreason" exact="'ERR_NO_HOMEBASE'" />
        <resume label="finish" />
      </do_if>
you can see that this.ship.knownname, this.ship.cargo.capacity, this.ship.commander, this.ship.zone.knownname are 4 properties of the object/entity this.ship. Then I ad assume that these 4 this.ship.* are referencing the same object/entity.

Then why can't I find those 4 properties in the same property box in scriptproperties.html ?

Which property box contains properties knownname, cargo.*, commander and zone.*? Not in the ship, container or object's property listed box.

This is so I can understand what is the nature of the this.ship and therefore, finding out what other properties are available with it
.
I do not know all technical terms. So sorry for lengthy explanations.
Steam X-Superbox, playing XR
WIndows-7
Intel I5
16Gb Memory
Nvgidia GT 960

UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 13817
Joined: Sun, 20. Nov 05, 23:45

Post by UniTrader » Mon, 2. Oct 17, 02:37

said properties are shared each with other stuff. if you want all properties of a certain variable type you can type it like $ship or $station at the top (just checked, but this.ship doesnt work for some reason, i guess because of the md-context for this which seems to have higer prio than the ai-specific stuff)
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 ;)

w.evans
Posts: 2954
Joined: Tue, 18. Nov 14, 17:23

Post by w.evans » Mon, 2. Oct 17, 08:19

knownname is an attribute (or a property, i always confuse the two) of class component,
commander, of class controllable,
cargo, of container,
zone, of component

which you probably already know since you're working with scriptproperties.html. What isn't readily apparent in that document is which subclasses are derived from which classes.

In this case:
ship is a subclass of container,
which is a subclass of defensible,
which is a subclass of controllable,
which is a subclass of object,
which is a subclass of destructible,
which is a subclass of component.

So this.ship would have attributes of all of those classes.

Browser_ice
Posts: 231
Joined: Sun, 5. Feb 06, 18:15

Post by Browser_ice » Mon, 2. Oct 17, 16:14

That is cool to be able to access all the properties of all the subclass the current object/entity/... is based on.

However, how can I find out easily for anyone, what subclasses it is based on without having to reverse engeneering through script codes ?
Steam X-Superbox, playing XR
WIndows-7
Intel I5
16Gb Memory
Nvgidia GT 960

w.evans
Posts: 2954
Joined: Tue, 18. Nov 14, 17:23

Post by w.evans » Mon, 2. Oct 17, 16:24

i looked them up via scriptproperties.xml. for example:

<datatype name="ship" type="container">

<datatype name="container" type="defensible">

etc.

don't think there's an easy way to look them up in the html file.

UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 13817
Joined: Sun, 20. Nov 05, 23:45

Post by UniTrader » Mon, 2. Oct 17, 16:58

UniTrader wrote:...
if you want all properties of a certain variable type you can type it like $ship or $station at the top.
...
if it wasnt clear enough: the Expression Field at the top filters for what is currently available in your expression chain. and if you begin with a pseudo-var like $ship you can get all valid properties for a var which contains a ship (or a property which refers to a ship)

begin typing for example this:
$ship.zone.adjacentzones.count
anf look for each letter/property how the available expressions change.
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 ;)

Xenon_Slayer
EGOSOFT
EGOSOFT
Posts: 10863
Joined: Sat, 9. Nov 02, 12:45

Post by Xenon_Slayer » Mon, 2. Oct 17, 17:01

If you type in the class in the search bar e.g. "$ship", it will show you the base class and the derived class on the left side. These are clickable but whether it takes you to those classes may depend on the browser.

And no, there is no full class breakdown view.

Post Reply

Return to “X Rebirth - Scripts and Modding”