What is the variable for the player ship?

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

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

Post Reply
User avatar
Black_Sails
Posts: 95
Joined: Wed, 1. Aug 07, 06:35
x3tc

What is the variable for the player ship?

Post by Black_Sails » Tue, 19. Nov 13, 03:54

I'm playing with adding commands such as protect me, for my own learning (I don't expect what I produce here to be stable as I'm still learning :P)

In my player.default.xml file, I've been working with Jack's manual commands script as a starting place to learn. Here's a snip of what I've added (I also added the relevant commands to Orders and the t\ file.

Code: Select all

<do_if value="event.param == 'gEC_EscortMe'">
  <set_value name=$srcMoveMode" exact="'mode.escort'" /> 
I tested it, then checked what I'm assuming is the error log file, uidata.xml. Obviously, as I expected (I read through the move.escort script) its complaining about the lack of a target.

Code: Select all

["timestamp"]=1384741465.000000,
["message"]="Error: When calling script move.escort on entity 0x15EFB - script parameter \"target\" was not provided!",}, 
I'm trying to figure out how to pass the target through to the script as the player ship. What is the variable for the player ship? Any suggestions?

Also..on a side note, upon checking the uidata file-I'm not sure if anyone else has noticed this, but I'm seeing this error repeatedly-back from when I started with a plain vanilla rebirth:

Code: Select all

["message"]="Error: Error in AI script move.seekenemies on entity 0x14571: Property lookup failed: this.ship.distanceto.[component.{0x2e39L},position.[3620.742188m, 3875.796875m, -6926.882813m]]\
* Expression: this.ship.distanceto.[$destination, $pos]",},

andrewas
Posts: 1498
Joined: Thu, 10. Mar 05, 21:04
x3tc

Post by andrewas » Tue, 19. Nov 13, 04:06

Reading the existing scripts, I think you're looking for player.primaryship, though I swear I've seen player.ship appear as well.

Tyrant597
Posts: 299
Joined: Wed, 9. Apr 08, 05:52
x4

Post by Tyrant597 » Tue, 19. Nov 13, 04:53

I would agree with player.primaryship
You don't talks about X:Rebirth...
X4 Mods: Collect Inventory Wares Stations Supply Build Storage Mass Move Marines

User avatar
Observe
Posts: 5079
Joined: Fri, 30. Dec 05, 17:47
xr

Post by Observe » Tue, 19. Nov 13, 05:06

For the record, for enquiring minds, player.ship is the "ship context". This could be a landing platform or it could be the Skunk. On the other hand, "player.primaryship" always refers to the Albion Skunk.
Last edited by Observe on Tue, 19. Nov 13, 05:26, edited 1 time in total.

MutantDwarf
Posts: 711
Joined: Tue, 20. Jun 06, 02:29
x4

Post by MutantDwarf » Tue, 19. Nov 13, 05:07

I believe player.entity can work, too, though I think it refers to both the ship and the player in first-person mode.

User avatar
enenra
Posts: 7150
Joined: Fri, 8. Apr 05, 19:09
x4

Post by enenra » Tue, 19. Nov 13, 12:21

There is a list of variables that is searchable included in the game.

You'll find the "scriptproperties.html" in your main folder. It sadly only works with IE because of ActiveX, but it's very useful.

Xenon_Slayer
EGOSOFT
EGOSOFT
Posts: 13094
Joined: Sat, 9. Nov 02, 11:45
x4

Post by Xenon_Slayer » Tue, 19. Nov 13, 12:29

Yes, scriptproperties.html is useful (and I have it working in firefox somehow).

But basically:
player.entity = the player (Ren Otani)
player.ship = the players current ship e.g. the Albion Skunk or a Drone when remote controlling or null when on a platform
player.primaryship = the Albion Skunk
Come watch me on Twitch where I occasionally play several of the X games

User avatar
enenra
Posts: 7150
Joined: Fri, 8. Apr 05, 19:09
x4

Post by enenra » Tue, 19. Nov 13, 12:42

Xenon_Slayer wrote:Yes, scriptproperties.html is useful (and I have it working in firefox somehow).

But basically:
player.entity = the player (Ren Otani)
player.ship = the players current ship e.g. the Albion Skunk or a Drone when remote controlling or null when on a platform
player.primaryship = the Albion Skunk
Well, listen to him people. That's one of the guys who created the scripting language and the scripts. :D

Owen - is player.primaryship hardcoded to the Skunk or would it be possible to add a second flyable ship and have it somehow refer to that?

Xenon_Slayer
EGOSOFT
EGOSOFT
Posts: 13094
Joined: Sat, 9. Nov 02, 11:45
x4

Post by Xenon_Slayer » Tue, 19. Nov 13, 13:46

That value is hardcoded to the skunk.

However I suppose if you want a place to store a new variable many scripts could reference you could save it to the player.

Similar to local variables in the old Script Editor you can save values to NPCs. e.g. player.entity.$OtherPlayerShip

edit: Actually, you can just have a global variable (writeable and accessable from both MD and AI scripts).
global.$Var
Come watch me on Twitch where I occasionally play several of the X games

User avatar
Jack08
Posts: 2993
Joined: Sun, 25. Dec 05, 10:42
x3tc

Post by Jack08 » Tue, 19. Nov 13, 13:52

Awesome! im guessing that works for just about any type of object?

i know you can get and set values, but is there a way to know if a value exists? apparently getting a value that doesn't exist gives you an error in the logs.

jarlrmai
Posts: 6
Joined: Mon, 18. Nov 13, 10:36

Post by jarlrmai » Tue, 19. Nov 13, 13:57

Hey Xenon, any chance of being able to mess with the LUAJit files?

:D

Xenon_Slayer
EGOSOFT
EGOSOFT
Posts: 13094
Joined: Sat, 9. Nov 02, 11:45
x4

Post by Xenon_Slayer » Tue, 19. Nov 13, 14:03

Just so you all know, we hope to get some documentation to you at some point. Hopefully not too far in the future.

As for value exist checks, yes.
<do_if value="$MyVal?">
The ? will check if the value has been defined, it will return a bool.

Another one which can be useful is @
@player.ship.position.x
The @ will suppress any debug errors in the logs. For example if the player is on a platform and player.ship returns null, the expression will fail without errors.

As for Lua files, I don't know much about them to be honest. If something's decided about them it'll be made known here.
Come watch me on Twitch where I occasionally play several of the X games

jarlrmai
Posts: 6
Joined: Mon, 18. Nov 13, 10:36

Post by jarlrmai » Tue, 19. Nov 13, 14:38

Thanks for your time, looking forward to it.

Realspace
Posts: 1396
Joined: Wed, 15. Nov 06, 10:21
x4

Post by Realspace » Tue, 19. Nov 13, 15:39

Just for the record (not intentioned to mess with it at moment but who knows)..what is the file regulating player's ship physics, movement? I only found the engines so is the physics hardcoded exept for the engines??

Post Reply

Return to “X Rebirth - Scripts and Modding”