Script Engine Changes

The place to discuss scripting and game modifications for X³: Farnham's Legacy

Moderators: Moderators for English X Forum, Scripting / Modding Moderators, Moderators for the X3:FL Forums

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

Re: Script Engine Changes

Post by Cycrow » Fri, 10. Dec 21, 17:41

Deniskos wrote:
Fri, 10. Dec 21, 16:47
As far as I understand, before you extract something using

Code: Select all

$Ret = get abbreviation text: type = 0, key = $Value
$Ret = get abbreviation description: type = 0, key = $Value
need to add something with

Code: Select all

add encyclopedia abbreviation: type = 0, key = $Value, value page = 0, value id = 0, data page = 0, data id = 0
You can also get some of the existing abbreviations as well, as they are added in the same way, you just need to know the key's for them
Deniskos wrote:
Fri, 10. Dec 21, 16:47
For script command

Code: Select all

$Object -> attach event script: events = 0, script = 'ScriptName'
there is really not enough event like [Event.SetHomebase]))
The events are just the existing internal events that are used for things, so it only made these events available via scripts too. the MD uses the same events for some of its cue's as well
Deniskos wrote:
Fri, 10. Dec 21, 16:47
But what this script command is for, I didn't understand something at first glance

Code: Select all

add script event: name = 'String', script = 'ScriptName'
What is it for?
This allows you to create a new event that you can watch for via other scripts and the MD
There is a script command that can trigger these events

the name is the way to identify each event, and you can attach multiple scripts to the same event. So for example, you could trigger some event somewhere, and have any number of scripts that listen for that and do something. This can allow better collaboration between different mods and the MD

its actually used by the explorers guild script to trigger the Terran Plot from the comm script

Deniskos
Posts: 146
Joined: Wed, 11. Jun 08, 21:40
x4

Re: Script Engine Changes

Post by Deniskos » Fri, 10. Dec 21, 18:21

In general, events in SE are a big plus in the performance of the game engine. Rather than creating loops to track events, it is better to use calls or signals in the desired events.
Where were you guys before, respect to you!

Deniskos
Posts: 146
Joined: Wed, 11. Jun 08, 21:40
x4

Re: Script Engine Changes

Post by Deniskos » Tue, 21. Dec 21, 11:42

How do I get the return value in a script command?

Code: Select all

<RetVar> <RefObj> -> open menu script: <scriptname>
It always returns null for me.

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

Re: Script Engine Changes

Post by Cycrow » Tue, 21. Dec 21, 12:01

There is more information here
https://www.egosoft.com:8444/confluence ... =102368099

but you return an array from the "arguments" event, and this becomes the return value

Deniskos
Posts: 146
Joined: Wed, 11. Jun 08, 21:40
x4

Re: Script Engine Changes

Post by Deniskos » Sun, 23. Jan 22, 12:11

What does this script command do?

Code: Select all

<RefObj> get docking port class string: flags=<Var/Number>
Spoiler
Show
Image
Maybe it should look like this -

Code: Select all

<RefVar> get docking port class string: flags=<Var/Number>
Also I can't figure out what this script command does?

Code: Select all

<RetVar/If><RefObj> get ship in docking port: port=<Var/Number>
It always returns null for me.

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

Re: Script Engine Changes

Post by Cycrow » Sun, 23. Jan 22, 17:55

it should be RetVar rather than RefObj. But it basically it converts the dockport.flags into a string. The string is simply read from the text files.

the get ship in docking port command should return the ship thats docked at a given port. Note that this only works for external docks, where the ship physically takes a slot while docked

Deniskos
Posts: 146
Joined: Wed, 11. Jun 08, 21:40
x4

Re: Script Engine Changes

Post by Deniskos » Wed, 11. May 22, 08:43

How to use this script command correctly?

Code: Select all

$asteroid-> add asteroid hidden ware: ware={Ware}, amount=0, discovery points=0
After its execution, when shooting at an asteroid, containers with goods are endlessly created. Is that how it should be?
What does this parameter set?

Code: Select all

discovery points=0

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

Re: Script Engine Changes

Post by Cycrow » Fri, 13. May 22, 14:11

It should just create the crate when the asteroid is destroyed. Are you saying its producing these when you attack but not kill the asteroid?

the discovery points parameter assigns a number of discovery points to the crate when you collect it

Deniskos
Posts: 146
Joined: Wed, 11. Jun 08, 21:40
x4

Re: Script Engine Changes

Post by Deniskos » Sat, 14. May 22, 04:06

Cycrow wrote:
Fri, 13. May 22, 14:11
It should just create the crate when the asteroid is destroyed. Are you saying its producing these when you attack but not kill the asteroid?
Yes.

Deniskos
Posts: 146
Joined: Wed, 11. Jun 08, 21:40
x4

Re: Script Engine Changes

Post by Deniskos » Mon, 10. Apr 23, 04:31

Unoffical Patch : V1.3.5 : 2023-04-01
In x3story.obj code for commands:

Code: Select all

<t id="3180">unregister god event script: script=%0</t>
<t id="3182">unregister god event script: scriptname=%0</t>
incorrect parameters are set. It costs 10(Var/Number), but should be 7(Script Name) and 11(Var/String), respectively.

Deniskos
Posts: 146
Joined: Wed, 11. Jun 08, 21:40
x4

Re: Script Engine Changes

Post by Deniskos » Thu, 13. Apr 23, 17:06

Code: Select all

<t id="3210">%1%0 get sector colour</t>
<t id="3211">%0 set sector colour: %1</t>
Very good thanks!
But I would like these script commands to work here too http://dna.su.kg/images/f/fb/2.png
here http://dna.su.kg/images/4/4a/1.png
and here http://dna.su.kg/images/1/10/3.png
Last edited by X2-Illuminatus on Thu, 13. Apr 23, 18:56, edited 3 times in total.
Reason: Removed img links, as they don't work on urls starting with http. anymore. Must be https now.

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

Re: Script Engine Changes

Post by Cycrow » Thu, 13. Apr 23, 17:10

The images are not displaying?

User avatar
X2-Illuminatus
Moderator (Deutsch)
Moderator (Deutsch)
Posts: 24950
Joined: Sun, 2. Apr 06, 16:38
x4

Re: Script Engine Changes

Post by X2-Illuminatus » Thu, 13. Apr 23, 18:58

Works for me, when clicking on the image links. (I removed the img-tags, since they won't work on http urls, anymore. It must be https now.)
Nun verfügbar! X3: Farnham's Legacy - Ein neues Kapitel für einen alten Favoriten

Die komplette X-Roman-Reihe jetzt als Kindle E-Books! (Farnhams Legende, Nopileos, X3: Yoshiko, X3: Hüter der Tore, X3: Wächter der Erde)

Neuauflage der fünf X-Romane als Taschenbuch

The official X-novels Farnham's Legend, Nopileos, X3: Yoshiko as Kindle e-books!

Deniskos
Posts: 146
Joined: Wed, 11. Jun 08, 21:40
x4

Re: Script Engine Changes

Post by Deniskos » Wed, 17. May 23, 18:21

What are these tags:
\053\062\060
What are they for?

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

Re: Script Engine Changes

Post by Cycrow » Wed, 17. May 23, 18:28

They are ascii escape characters

It equals, +20

The + character doesn't work correctly when exporting from the text dB so it's replaced with \053
When adding a number on the end the game treated the whole thing as an escape character so didn't work correct, so the 20 was also converted

FriendlyFirePhoenix
Posts: 90
Joined: Tue, 14. Feb 17, 10:06
x3ap

Re: Script Engine Changes

Post by FriendlyFirePhoenix » Sun, 28. May 23, 18:19

Hi Cycrow,

I've run into a spot of bother while updating my Colour By Race plugin and I'm hoping you can help.

I'm trying to swap out the old [SIGNAL_CHANGESECTOR] with the new [SIGNAL_CREATED] to save some CPU cycles in Farnham's Legend. [SIGNAL_CREATED] will trigger for newly created stations but not ships. I've tried a few different variations of class, race, priority etc but to no avail. I'm using the command:

Code: Select all

global secondary signal map: add signal
I can't find any documentation on [SIGNAL_CREATED] and couldn't find any examples of it being used to compare with my own code. I'm running your unofficial patch 1.3.8. Is it correct behaviour for [SIGNAL_CREATED] to only trigger for stations? Have I perhaps found a bug? Or am I doing something stupid?

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

On another subject - does the new signal [SIGNAL_OWNERCHANGED] work for sectors? My initial experiments suggest that it doesn't but I'm curious how it works.

Now with the

Code: Select all

%0 set sector colour: %s
command we have an easy way to run through the universe setting race coloured sectors. But I'm wondering if there's a way to trigger the event of a sector's owner changing so it can be immediately recoloured.
I made a couple of X3 mods | Colour By Race | True Relations

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

Re: Script Engine Changes

Post by Cycrow » Wed, 31. May 23, 20:36

SIGNAL_CREATED should work for ships as well. What are you setting as the class ?
setting Class to "Ship" and race to "null" should work for all ships. At least its working fine for me when i tried.

Signals dont work on Sectors as sectors are not event objects.
However, in 1.3.9, you will be able to attach events to sectors. You still wont be able to use signals though (signals only work for objects that scripts can run on, this is limited to ships and stations). But you can use the Event.SetOwner, when used with $sector -> attach event script.
You will have to do it for each sector, just cycle through all sectors and attach the event script, then it'll trigger on any owner change.

FriendlyFirePhoenix
Posts: 90
Joined: Tue, 14. Feb 17, 10:06
x3ap

Re: Script Engine Changes

Post by FriendlyFirePhoenix » Thu, 1. Jun 23, 15:48

Cycrow wrote:
Wed, 31. May 23, 20:36
SIGNAL_CREATED should work for ships as well. What are you setting as the class ?
setting Class to "Ship" and race to "null" should work for all ships. At least its working fine for me when i tried.
Yep that worked. It also works if I set a more specific class such as [M3]. But setting a specific race causes it to fail. That's not the end of the world if it's intended behaviour but setting a specific race works fine for station classes.

As an example I currently have a signal specific to pirate M7s to check for Pirate Guild Mob Bosses. It would waste a few CPU cycles to have to perform this check for every race.

But now a bigger problem reveals itself - SIGNAL_CREATED behaves differently between stations and ships. When triggered for a station I get the owner race along with a fully formed name, sector location etc. When it triggers for a ship it seems to be earlier in the process because the ship has no race applied, no name apart from ship type, no job etc. Is this intended behaviour? Because if so I'll have to stick with SIGNAL_CHANGESECTOR for my use case - I need to be able to query the race and name.
Cycrow wrote:
Wed, 31. May 23, 20:36
Signals dont work on Sectors as sectors are not event objects.
However, in 1.3.9, you will be able to attach events to sectors. You still wont be able to use signals though (signals only work for objects that scripts can run on, this is limited to ships and stations). But you can use the Event.SetOwner, when used with $sector -> attach event script.
You will have to do it for each sector, just cycle through all sectors and attach the event script, then it'll trigger on any owner change.
That's awesome, looking forward to trying it out!
Last edited by FriendlyFirePhoenix on Thu, 1. Jun 23, 16:08, edited 1 time in total.
I made a couple of X3 mods | Colour By Race | True Relations

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

Re: Script Engine Changes

Post by Cycrow » Thu, 1. Jun 23, 16:02

im guessing this is mainly an issue with how the jobs engines creates its ships.

the signal is sent from the ship creation, so it works for all created ships. But the jobs engine creates a default ship, then applies the settings afterwards, so the signal will be fired before this happens.

you could start a new script with a delay to allow those settings to be applied.

i may look into refiring the created signal for job ships so you will get it twice for job ships once for the actual creation and once after the initilisation. This is also why the race filter wasn't working, as its being fired before the race is set.

FriendlyFirePhoenix
Posts: 90
Joined: Tue, 14. Feb 17, 10:06
x3ap

Re: Script Engine Changes

Post by FriendlyFirePhoenix » Thu, 1. Jun 23, 16:18

Thanks, that makes sense. I've tried using waits in signal scripts before and it was a bit of schemozzle. If I opened a sector map, the map would wait to appear on screen about the same amount of time as the sum of the waits for the civilian ships being spawned there. This was in AP, not FL but generally seems likes a bad idea based on that behaviour.

Note that I was simply using the "wait %s ms" and "wait randomly from %s to %s ms" commands. If there's a better way to do it I'm all ears.

Having the signal fire twice would work for me. Is there actually any utility of firing the signal before the jobs engine has gotten to it? Why not just move it?
I made a couple of X3 mods | Colour By Race | True Relations

Post Reply

Return to “X³: Farnham's Legacy - Scripts and Modding”