[Discussion] Generic X3TC S&M questions II

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

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

Iseeyouseemeseeyou
Posts: 29
Joined: Thu, 10. Feb 11, 18:20

Post by Iseeyouseemeseeyou »

:laffo:

thank you
User avatar
Gazz
Posts: 13244
Joined: Fri, 13. Jan 06, 16:39
x4

Post by Gazz »

The first script editor screen - the one you always skip over - has a haaaaaalp page with all those commands.
My complete script download page. . . . . . I AM THE LAW!
There is no sense crying over every mistake. You just keep on trying till you run out of cake.
Bishop149
Posts: 7232
Joined: Fri, 9. Apr 04, 21:19
x3

Post by Bishop149 »

This is also a very good "idiots" guide by Cycrow. . . .

http://cycrow.thexuniverse.us/scripts/help/

I'm happy calling it that because I myself have used it liberally to learn the basics!!


Another question from me.

Ideally I want to try and return an array of all the missiles fired by the player in sector, those that are still active / in the air, ie on their way to the target.

I was going to treat them the same way I'd recall say an array of all of a certain ship type such as an M5 but have become a bit confused about missiles.

"Missile" appears to be a perfectly valid object type (It's whats returned when I query a missiles type after all) and yet its not on the list of object types called by the script editor. . . pretty sure anyway, I did go through the list very slowly about 3 times thinking "I must just be missing it. . . . " :roll:
"Shoot for the Moon. If you miss, you'll end up co-orbiting the Sun alongside Earth, living out your days alone in the void within sight of the lush, welcoming home you left behind." - XKCD
HotSake
Posts: 472
Joined: Sun, 3. Jan 10, 22:15
x3tc

Post by HotSake »

I've seen this come up before. It seems the only way to get missiles in flight is to get the array of incoming missiles for a specific ship.
User avatar
Gazz
Posts: 13244
Joined: Fri, 13. Jan 06, 16:39
x4

Post by Gazz »

Bishop149 wrote:Ideally I want to try and return an array of all the missiles fired by the player in sector, those that are still active / in the air, ie on their way to the target.
No can do.
You have to check every single ship and grab the missiles incoming to it.

Missiles do have a race, though.
My complete script download page. . . . . . I AM THE LAW!
There is no sense crying over every mistake. You just keep on trying till you run out of cake.
Bishop149
Posts: 7232
Joined: Fri, 9. Apr 04, 21:19
x3

Post by Bishop149 »

Thank you, thats messy.

I think I'll limit the script to working on a single target for now!
"Shoot for the Moon. If you miss, you'll end up co-orbiting the Sun alongside Earth, living out your days alone in the void within sight of the lush, welcoming home you left behind." - XKCD
User avatar
s9ilent
Posts: 2033
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent »

Interesting fun fact:


Everyone knows that scripts that run on objects, stop when the object is destroyed. OOOOooOOOrrr do they!!

The statement is partially true (I thought I'd stress test it)

A script STARTED on an object, will terminate when the object dies.


A script that was started on a different object (ship2), that is told to call another script on the first object (ship1), will not stop if ship1 dies.

i.e.
i start on ship2
(no start) $ship -> call script
Ship 1 dies

But the script on ship2 is still running. and [THIS] has become an unknown object.




Any way, I hope this isn't too confusing...
Here are the scripts I used:


I called script2 globally, then called script 3 globally
script2 calls (not starts) a script on my target, then script 3 blows up the target, some seconds later, script 2 should send a second message (and it actually does send it)


Script a....test2
001 $var = get player tracking aim
002 @ = $var -> call script 'a....testmsg' :
003
004
005 return null




Script a....test3
001 $var = get player tracking aim
002 $var -> destruct: show no explosion=[FALSE]
003
004
005 return null



Script a....testmsg
001 $time = playing time
002 $msg = 'start' + $time + [THIS]
003 [THIS] -> send incoming message: text=$msg temporary=[FALSE]
004
005 @ = wait 10123 ms
006 $time = playing time
007 $msg = 'finish' + $time + [THIS]
008 [THIS] -> send incoming message: text=$msg temporary=[FALSE]
009
010
011
012 return null


output was

1. start447Terracorp...freighter
2. finish457UnknownObject

(I'm guessing unknown object means dead object)
User avatar
ScRaT_GER
Posts: 1962
Joined: Tue, 8. Jan 08, 18:19
x3tc

Post by ScRaT_GER »

Interesting. I guess because the calling script waits for a return value, the called script continues to execute. It's is a bit surprising, but when you think about it, I guess it's the only sensible way, because how else should you proceed?

Greetings,
ScRaT
User avatar
Gazz
Posts: 13244
Joined: Fri, 13. Jan 06, 16:39
x4

Post by Gazz »

Of course scripts on Object 2 do not automatically terminate when Object 1 is destroyed.
Some scripts "deal with" many objects so it would get silly pretty quickly if the script would terminate as soon as any of the queried objects was destroyed. =P

That's what (if) exist is for and it should be used liberally.
My complete script download page. . . . . . I AM THE LAW!
There is no sense crying over every mistake. You just keep on trying till you run out of cake.
jlehtone
Posts: 22569
Joined: Sat, 23. Apr 05, 21:42
x4

Post by jlehtone »

This thread is getting long. The discussion should continue here.

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