[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

Logain Abler
Posts: 2255
Joined: Mon, 31. Oct 05, 08:44
x4

Post by Logain Abler »

Gazz wrote:If you must open the menu on task 0 of the ship, make it an interrupt instead of start task.
Cheers Gazz,

I'm using a simple : <RetVar/IF/START><RefObj> call script <Script Name> : <Parameter>
not a task call.

So if opening a custom menu against a ship object goes in at 0:
= $ship->call script 'scritp.name' :

What is the best way to call it?
User avatar
Gazz
Posts: 13244
Joined: Fri, 13. Jan 06, 16:39
x4

Post by Gazz »

That depends. If you don't want task0 to be killed instantly, you make it an interrupt instead of a START.

Or you simply use a different task ID... unless you must run this on task 0.
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.
Logain Abler
Posts: 2255
Joined: Mon, 31. Oct 05, 08:44
x4

Post by Logain Abler »

Gazz wrote:That depends. If you don't want task0 to be killed instantly, you make it an interrupt instead of a START.

Or you simply use a different task ID... unless you must run this on task 0.
Your a star :)

Changed from:

Code: Select all

START $val->call script 'plugin.LI.PM.PM.Menu.D' :
= $val->call script 'plugin.LI.PM.PM.Menu' :
To:

Code: Select all

if $val->is of class {Ship 2004}
  $task = $val -> get next available task: starting=$PageID
  $val -> start named script: task=$task scriptname='plugin.LI.PM.PM.Menu.D' prio=0, null, null, null, null, null
  $task = $val -> get next available task: starting=$PageID
  $val -> start named script: task=$task scriptname='plugin.LI.PM.PM.Menu' prio=0, null, null, null, null, null
else
  START $val->call script 'plugin.LI.PM.PM.Menu.D' :
  = $val->call script 'plugin.LI.PM.PM.Menu' :
end
Works a treat, thanks for the pointer.

LA
Bishop149
Posts: 7232
Joined: Fri, 9. Apr 04, 21:19
x3

Post by Bishop149 »

If I want a target ship to behave exactly as if I'd attacked it, whould this do the job:

Code: Select all

001   $target =  get player tracking aim
002   skip if $target -> exists
003     return null
004   $target -> set relation against Player to Foe
005   $target -> set attacker to [PLAYERSHIP]
007   return null
Seems to work but not quite perfectly I feel, Any improvements?
"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
Gazz
Posts: 13244
Joined: Fri, 13. Jan 06, 16:39
x4

Post by Gazz »

Try sending SIGNAL_ATTACKED for this target.
The game should take over from there.
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 »

Gazz wrote:Try sending SIGNAL_ATTACKED for this target.
The game should take over from there.
Like this?

Code: Select all

001   $target =  get player tracking aim
002   skip if $target -> exists
003   |return null
004   $target -> set ship command/signal SIGNAL_ATTACKED to global default behaviour
005   return null
Sorry, dunno what a signal is?
"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
catman_94
Posts: 6
Joined: Sat, 12. Dec 09, 17:01
x3tc

Post by catman_94 »

is it possible to get a free roaming camera ?
Bishop149
Posts: 7232
Joined: Fri, 9. Apr 04, 21:19
x3

Post by Bishop149 »

Code: Select all

001   $target =  get player tracking aim
002   skip if $target -> exists
003   |return null
004   $target -> set ship command/signal SIGNAL_ATTACKED to global default behaviour
005   return null
Nope that doesn't seem to do anything, I can't figure this out I've looked at all the "signal" commands and can't find one to do as suggested, except the one I tried.
"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
ScRaT_GER
Posts: 1962
Joined: Tue, 8. Jan 08, 18:19
x3tc

Post by ScRaT_GER »

I can't figure this out I've looked at all the "signal" commands and can't find one to do as suggested
That's because it's located in the Flight Commands. The command is called "Send Signal" and it is crucial that it is started with exactly the right arguments.
If the argument type or number of arguments does not match, the signal will not be raised.

I don't no exactly which arguments SIGNAL_ATTACKED needs, to be raised manually, but you can easily find that out, by connecting some ships SIGNAL_ATTACKED to a logging script, which takes five arguments and prints them in the logbook. Then attack the object and see, which arguments are passed.

Greetings,
ScRaT
Bishop149
Posts: 7232
Joined: Fri, 9. Apr 04, 21:19
x3

Post by Bishop149 »

ScRaT_GER wrote: That's because it's located in the Flight Commands. The command is called "Send Signal" and it is crucial that it is started with exactly the right arguments.
If the argument type or number of arguments does not match, the signal will not be raised.

I don't no exactly which arguments SIGNAL_ATTACKED needs, to be raised manually, but you can easily find that out, by connecting some ships SIGNAL_ATTACKED to a logging script, which takes five arguments and prints them in the logbook. Then attack the object and see, which arguments are passed.

Greetings,
ScRaT
Many thanks, but I'm very new to all this and I don't know how to do what you suggest.
I'm pretty sure i've written a script to attach the signal to another script:

Code: Select all

001   $target =  get player tracking aim
002   skip if $target -> exists
003   |return null
004   $target -> connect ship command/signal SIGNAL_ATTACKED to script 'aa.log.sign' with prio 100
005   return null
What I don't know how to do is write the aa.log.sign script. My (very limited) understanding of arguments is that they are things entered manually by the player.

Edit: Holy Hell, I think I may actually have done it!

Code: Select all

Arguments
1: arg1 , Number , 'Argument 1' 
2: arg2 , Number , 'Argument 2' 
3: arg3 , Number , 'Argument 3' 
4: arg4 , Number , 'Argument 4' 
5: arg5 , Number , 'Argument 5' 

001   write to player logbook $arg1
002   write to player logbook $arg2
003   write to player logbook $arg3
004   write to player logbook $arg4
005   write to player logbook $arg5
006   return null
Is it really that simple

This returns: [PLAYERSHIP], 0, null, null, null
"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
ScRaT_GER
Posts: 1962
Joined: Tue, 8. Jan 08, 18:19
x3tc

Post by ScRaT_GER »

Edit: Holy Hell, I think I may actually have done it!
Yes, you did. :)
This returns: [PLAYERSHIP], 0, null, null, null
Well, now you know what arguments you need to send the signal manually.

The first one is the attacking ship, the second one some integer.

In this case you could also have taken a look at a built-in script like "!ship.signal.attacked", which is used by Egosoft to respond to an attack. But not every signal is used by Egosoft, so I think it's good to know where to get the right arguments.

Btw: The integer passed as second argument is one of the ACTION_* constants (eg. ACTION_AVOID, ACTION_KILL, etc.).

Greetings,
ScRaT
Bishop149
Posts: 7232
Joined: Fri, 9. Apr 04, 21:19
x3

Post by Bishop149 »

ScRaT_GER wrote:
Btw: The integer passed as second argument is one of the ACTION_* constants (eg. ACTION_AVOID, ACTION_KILL, etc.).
Brilliant thanks for the help, where could I find a list of these ACTION_* constants?

I did notice that the second argument changed depending on what the target was!
"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
ScRaT_GER
Posts: 1962
Joined: Tue, 8. Jan 08, 18:19
x3tc

Post by ScRaT_GER »

where could I find a list of these ACTION_* constants?
I don't know any other lists than the ingame list (under constants) and the list of constants in the exscriptor. None of them explains what the constants stand for, but most of them are self-explanatory.

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

Post by Gazz »

If you write a constant to a variable, you can print the integer value it puts there.
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 »

Hell, becoming a regular in this thread!

How do I apply colour to text to be written in the player logbook that is called from a t-file.

I've tried all sorts
\033YHello (and variations upon)
<font color="ffff00">Hello</font>
<font color="yellow">Hello</font>

None seem to work. . . . some give just no colour, others lead to ReadFile errors
"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
jlehtone
Posts: 22575
Joined: Sat, 23. Apr 05, 21:42
x4

Post by jlehtone »

[url=http://forum.egosoft.com/viewtopic.php?t=216693]TC Tutorials[/url] points to:

[yellow]Hello[/yellow]


Note: There at least has been problems, since different parts of GUI parse different tags, and wrong tags lead to trouble (as you already know).
Bishop149
Posts: 7232
Joined: Fri, 9. Apr 04, 21:19
x3

Post by Bishop149 »

Thank you. . . . . I'm sure I tried that. . . . . Oh well obviously not, I tried so many variations I lost track!
"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
ScRaT_GER
Posts: 1962
Joined: Tue, 8. Jan 08, 18:19
x3tc

Post by ScRaT_GER »

When using the "call named script" command, I noticed that in the ingame SE the option "START" is not available.
However, in the Exscriptor it is possible to use that startoption and it works perfectly well, as long as you START the script on an object.
If you START it globally, it will call the script in an infinite loop which can crash your game:

Code: Select all

* works perfectly well:
START [PLAYERSHIP]->call named script: script='a.test', null, null, null, null, null

* crashes your game:
$null = null
START $null->call named script: script='a.test', null, null, null, null, null
So was the START option forgotten or left out on purpose? If the latter applies, why was it left out?

Greetings,
ScRaT
User avatar
eldyranx3
Posts: 2178
Joined: Sat, 14. Jan 06, 21:29
xr

Post by eldyranx3 »

Ties into the last question. I saw LV post in Cadius' ship pack thread, and I was wondering what it means / does:
LV wrote:Script setup.Sart.SafeUndocking

Code: Select all

009 @  = $null -> call script 'plugin.Sart.Misc.SafeUndocking' :  target=$shipyard
018 @  = $null -> call script 'plugin.Sart.Misc.SafeUndocking' :  target=$dock
change those = to START, your creating a major setup traffic jam while the plugin holds all other setup scripts up, even better would be calling those undocking via another script instead of a setup and then we have [ external image ] ;)
So will changing

Code: Select all

$Mars = get sector from universe index: x=12, y=3
$MarsEastGate = $Mars->get east warp gate
if not $MarsEastGate->exists
  = [THIS]->call script 'main.toa.gate' :
end
return null
to

Code: Select all

$Mars = get sector from universe index: x=12, y=3
$MarsEastGate = $Mars->get east warp gate
if not $MarsEastGate->exists
  START[PLAYERSHIP]->call script 'main.toa.gate' :
end
speed up things?
User avatar
ScRaT_GER
Posts: 1962
Joined: Tue, 8. Jan 08, 18:19
x3tc

Post by ScRaT_GER »

So will changing ... to .. speed up things?
Not how you've written it.

The "->call script" command start the script directly on the objects task 0*, which is the main task. Doing this on the [PLAYERSHIP] will switch your ship into autopilot until the called script has finished.

The only difference between "<RetValue> = [THIS] -> call script..." and "START [THIS] -> call script" is, that the last command doesn't wait for a returnvalue but directly continues executing the calling script.
If the calling script and the called script both run on task 0 of the same object (which might be the case in your example, if [THIS] == [PLAYERSHIP]) using the START option will most likely cause a problem, since you are overwriting the calling script with the called script, but at the same time, START makes the SE execute the calling script directly.

So, as a solution, I'd simply run the script globally with START or start a seperate task on the [PLAYERSHIP].

*More precisely the "->call script..." commands will start the called script on the same task that the command was given in.
So, when you're running a script on task 20 of an object and use a "->call script..." command in this script, the called script will also run on task 20.

--------------------------------------------------------

Just to make sure that my questions are not left unanswered:
ScRaT_GER wrote:I have a short question concerning the RegEx Engine used by X3:TC.

I want to match roman digits I, V and X. So only if a string consists of these digits, I want a match.

The regular expression which should fullfill this need should be the following one: ^(I|V|X)+$
According to an online RegEx checker this works.

However it does not work with X3:TC.
I'm reading the RegEx from a T-File, where it is defined like this:

Code: Select all

<t id=10003">\^\(I\|V\|X\)+\$</t>
Reading this text from the T-File and logging it to the logbook shows, that everything is unescaped correctly.

But unfortunately it just won't match any romand digits. So XVII is not a match for ^(I|V|X)+$ - at least not in X3:TC.

Is it a mistake on my side - and if so, how can I make it work - or is the X3:TC RegEx Engine not capable of processing this RegEx?
ScRaT_GER wrote:When using the "call named script" command, I noticed that in the ingame SE the option "START" is not available.
However, in the Exscriptor it is possible to use that startoption and it works perfectly well, as long as you START the script on an object.
If you START it globally, it will call the script in an infinite loop which can crash your game:

Code: Select all

* works perfectly well:
START [PLAYERSHIP]->call named script: script='a.test', null, null, null, null, null

* crashes your game:
$null = null
START $null->call named script: script='a.test', null, null, null, null, null
So was the START option forgotten or left out on purpose? If the latter applies, why was it left out?

Greetings,
ScRaT

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