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 » 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

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:56

You shouldn't wait in signal scripts generally, especially if they are secondary signals.

Instead you create a seperate script with a wait in and run that

$task = [THIS] -> get next available task: starting=[Task.Custom]
[THIS] -> start task ....

Then in that script you add the wait and do the rest

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:59

The reason for not moving it is that the jobs engine is not the only place that creates ships.

So to move it elsewhere would require finding and adding it in all places that creates the ships, and also mean it wouldn't work with any scripts that also create ships

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

Re: Script Engine Changes

Post by Deniskos » Tue, 4. Jul 23, 09:29

The script command

Code: Select all

<t id="2429">%1%0get all tasks with script on stack=%2</t>
returns task numbers one greater.
Does this mean that 1 must be subtracted from the returned value, or is this a bug in the code?

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

Re: Script Engine Changes

Post by Deniskos » Thu, 13. Jul 23, 07:27

What flags does this command use?

Code: Select all

<t id="2972">%0set override name flags: %1</t>

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

Re: Script Engine Changes

Post by Deniskos » Tue, 8. Aug 23, 08:47

I don’t understand how I can assign several hot keys to one executable script?
This used to work with register hotkey 'String' to call script name 'String' but doesn't work now.

Post Reply

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