[Discussion] Generic X3TC S&M questions II
Moderators: Scripting / Modding Moderators, Moderators for English X Forum
-
- Posts: 2033
- Joined: Wed, 29. Jun 05, 01:45
-
- Posts: 458
- Joined: Sun, 4. Jan 09, 17:17
-
- Posts: 851
- Joined: Fri, 13. Jun 08, 13:14
-
- Posts: 458
- Joined: Sun, 4. Jan 09, 17:17
-
- Posts: 2033
- Joined: Wed, 29. Jun 05, 01:45
Interesting fun facts
(I am working on an xml deserializer, and possibly a serializer in x3)
1. It is possible to pass a more or less fully qualified xml string into X3 (doing conversion on special chars where needed, c# does this internally, thank god...)
2. The game is entirely capable of holding large strings read from text files. And you can perform operations on them. (e.g. substring, length)
3. You can crash your game if you logbook, or subtitle, text that is too long
e.g. 48k characters...
I will experiment more and try to find a max char limit
The game crashes at exactly 10,000 character's (when writing that to the log/subtitles)
9,999 is totally cool thou.
(I do find this crash to be unusual thou given the some what ... artificial number)
(I am working on an xml deserializer, and possibly a serializer in x3)
1. It is possible to pass a more or less fully qualified xml string into X3 (doing conversion on special chars where needed, c# does this internally, thank god...)
2. The game is entirely capable of holding large strings read from text files. And you can perform operations on them. (e.g. substring, length)
3. You can crash your game if you logbook, or subtitle, text that is too long
e.g. 48k characters...
I will experiment more and try to find a max char limit
The game crashes at exactly 10,000 character's (when writing that to the log/subtitles)
9,999 is totally cool thou.
(I do find this crash to be unusual thou given the some what ... artificial number)
-
- Posts: 2230
- Joined: Sun, 2. Apr 06, 00:12
Aaah... This explain why i got strange result sometimes...ScRaT_GER wrote:* $someVariable is a variable, which can be null (!)
$num = 12 + $someVariable
On turret script, which are frozen OOS and réinit IS, some variable become null and causes bugs. Now i know why! Thanks!
====================================================
I would like to create a turret commande which is available only if One laser type is mounted. (industrial repair laser)
I know how to add the command on spécific ship only with this command:
Code: Select all
042 |set script command upgrade: command=REPARER_FLOTTE upgrade=[TRUE] script='AA.Pero.TRep.M1.Type.Check'
043 |global script map: set: key=REPARER_FLOTTE, class=M1, race=Player, script='AA.Pero.Tourelle.Reparation', prio=0
044 |global script map: set: key=REPARER_FLOTTE, class=TM, race=Player, script='AA.Pero.Tourelle.Reparation', prio=0]
Code: Select all
Script AA.Pero.TRep.M1.Type.Check
Arguments
* 1: Ship , Var/Ship owned by Player , 'Cuirassé'
001 skip if not $Ship -> is of class TM
002 |return [TRUE]
003
004 if $Ship -> is of class M1
005 |skip if not $Ship -> is of type 3C Mobile
006 ||return [TRUE]
007 end
008 return [FALSE]
But i want that the commands are grayed (available but Deactivated ) when other lasers type are also installed on the same turret, without deactivated the same command for the nearby turret if the lasers which are installed on it are correct
I try somethings like this :
Code: Select all
Script AA.Pero.T.Rep.OrdreDispo
Arguments
* 1: Ship , Var/Ship owned by Player , 'Vaisseau'
001 $Task = get task ID
003 $NbLaser = $Ship -> get max. number of lasers in turret $Task
004
005 $Laser.dispo = 0
006 while $NbLaser
007 |$laser = $Ship -> get laser type in turret $Task at slot $NbLaser
008 |skip if not $laser != Laser de Réparation Industriel AND $laser != null
009 ||return [CmdConCheck.Disabled]
010 |skip if not $laser == Laser de Réparation Industriel
011 ||inc $Laser.dispo =
012 end
013 skip if not $Laser.dispo != 0
014 |return [CmdConCheck.Available]
015 return [CmdConCheck.Disabled]
Already that :
Code: Select all
set script command upgrade: command=REPARER_FLOTTE upgrade=[TRUE] script='AA.Pero.TRep.M1.Type.Check'
Someone know how to do

[ external image ]
"On apprend en faisant des erreurs, mais le problème c'est qu'en explosifs, l'erreur est fatale." Aldébaran v10
[ external image ]<-- Clef Des Toilettes Privées Du Forum Français décernée par Thoto le 23/06/07
"On apprend en faisant des erreurs, mais le problème c'est qu'en explosifs, l'erreur est fatale." Aldébaran v10
[ external image ]<-- Clef Des Toilettes Privées Du Forum Français décernée par Thoto le 23/06/07
-
- Posts: 9378
- Joined: Mon, 29. Dec 08, 20:58
-
- Posts: 2033
- Joined: Wed, 29. Jun 05, 01:45
For available and greyed you need to do.......
set script command upgrade: command=<Object Command/Signal> upgrade=<Var/Ware> script=<Script Name>
And that script ... does something... If you look at the stickies and specifically the older stickies (i.e. x3r and x2) it will have more info
I've mostly forgotten how, but this is how my script does it
Setup script:
011 $ware = Trade Command Software MK2
012 $cmd = COMMAND_TYPE_TRADE_42
013
014
015 set script command upgrade: command=$cmd upgrade=$ware script='plugin.sfm.global.ship.cmdcheck'
016 set ship command preload script: command=$cmd script='plugin.sfm.ship'
017
018 global script map: set: key=$cmd, class=Little Ship 2133, race=Player, script='plugin.sfm.ship.loop', prio=0
019 global script map: set: key=$cmd, class=M6 2026, race=Player, script='plugin.sfm.ship.loop', prio=0
020 global script map: ignore: key=$cmd, class=Fighter Drone (object class), race=$race
021 global script map: ignore: key=$cmd, class=Freight Drone 2092, race=$race
022
cmd check script
args 0 $ship
args1 $ware
001 if $ship == [PLAYERSHIP]
002 |$ret = null
003 else
004 |$ret = [CmdConCheck.Available]
005 end
006
007 return $ret
And there are many more cmdconcheck's that can be bit-or'ed together
i.e. aaa|bbb|ccc|ddd|ee
And the one your after is called like disabled or something
(I return null as I want it to be not visible at all)
(Your after whats on line 15)
set script command upgrade: command=<Object Command/Signal> upgrade=<Var/Ware> script=<Script Name>
And that script ... does something... If you look at the stickies and specifically the older stickies (i.e. x3r and x2) it will have more info
I've mostly forgotten how, but this is how my script does it
Setup script:
011 $ware = Trade Command Software MK2
012 $cmd = COMMAND_TYPE_TRADE_42
013
014
015 set script command upgrade: command=$cmd upgrade=$ware script='plugin.sfm.global.ship.cmdcheck'
016 set ship command preload script: command=$cmd script='plugin.sfm.ship'
017
018 global script map: set: key=$cmd, class=Little Ship 2133, race=Player, script='plugin.sfm.ship.loop', prio=0
019 global script map: set: key=$cmd, class=M6 2026, race=Player, script='plugin.sfm.ship.loop', prio=0
020 global script map: ignore: key=$cmd, class=Fighter Drone (object class), race=$race
021 global script map: ignore: key=$cmd, class=Freight Drone 2092, race=$race
022
cmd check script
args 0 $ship
args1 $ware
001 if $ship == [PLAYERSHIP]
002 |$ret = null
003 else
004 |$ret = [CmdConCheck.Available]
005 end
006
007 return $ret
And there are many more cmdconcheck's that can be bit-or'ed together
i.e. aaa|bbb|ccc|ddd|ee
And the one your after is called like disabled or something
(I return null as I want it to be not visible at all)
(Your after whats on line 15)
-
- Posts: 2230
- Joined: Sun, 2. Apr 06, 00:12
I will see older stickies, perhaps i will find something.
Since the problem is not the use of this script commande (on your line 15 which is on my line 42) but the check script.
I want to separate turrets. But in the Check script, $Task = get task ID don't give me the turret ID.
So, for now, the best i can do is greying all turret if only one have a destructive laser. :/
Of course i can still improve the script IS (targeting ship who is in turret field of vision) But i'm already glad of what it do.
[edit]
Nothing found on olds topics. At best just what is already done, but nothing on greying command turret separetly.
I will try what $Task = get task ID return in a preload script, and if i could transmit the result to the check script.
Thank for helping me, i hope not detroy Shakespeare language to much...
Since the problem is not the use of this script commande (on your line 15 which is on my line 42) but the check script.
I want to separate turrets. But in the Check script, $Task = get task ID don't give me the turret ID.
So, for now, the best i can do is greying all turret if only one have a destructive laser. :/
The command itself is working 'perfectly' (IS and OOS). You will see it soon in the New Horizon mod in a couple of day, as soon as i've finished this script!EmperorJon wrote:Ah, this is something I've wanted to do for a long time, the repair laser turret command...
Of course i can still improve the script IS (targeting ship who is in turret field of vision) But i'm already glad of what it do.
[edit]
Nothing found on olds topics. At best just what is already done, but nothing on greying command turret separetly.
I don't know how this commande work, but it's perhaps the solution...016 set ship command preload script: command=$cmd script='plugin.sfm.ship'
I will try what $Task = get task ID return in a preload script, and if i could transmit the result to the check script.
Thank for helping me, i hope not detroy Shakespeare language to much...

[ external image ]
"On apprend en faisant des erreurs, mais le problème c'est qu'en explosifs, l'erreur est fatale." Aldébaran v10
[ external image ]<-- Clef Des Toilettes Privées Du Forum Français décernée par Thoto le 23/06/07
"On apprend en faisant des erreurs, mais le problème c'est qu'en explosifs, l'erreur est fatale." Aldébaran v10
[ external image ]<-- Clef Des Toilettes Privées Du Forum Français décernée par Thoto le 23/06/07
-
- Posts: 63
- Joined: Fri, 13. Jan 06, 03:12
Could be taken as a request but firstly as a question
Is it possible to create a script that would use turrets ship to fire in a barrage pattern? Kind of looking if there are 2 or more ennemy fighters in close proximity and then just make the ships gun -not- target/fire at any of these ships but fire something like 10-20 burst in a grid pattern in the direction of these? (Targeting empty space instead of object)
Is it possible to create a script that would use turrets ship to fire in a barrage pattern? Kind of looking if there are 2 or more ennemy fighters in close proximity and then just make the ships gun -not- target/fire at any of these ships but fire something like 10-20 burst in a grid pattern in the direction of these? (Targeting empty space instead of object)
-
- Posts: 851
- Joined: Fri, 13. Jun 08, 13:14
-
- Posts: 2033
- Joined: Wed, 29. Jun 05, 01:45
Not directly no, what you can do thou is you can create a dummy object and fire at that instead.
And there is also what Coruskane said. The idea of a barrage hitting anything in a 3d space is pretty slim. It is hard enough for turrets to hit ships period, let alone when they aren't firing directly at a target.
And there is also what Coruskane said. The idea of a barrage hitting anything in a 3d space is pretty slim. It is hard enough for turrets to hit ships period, let alone when they aren't firing directly at a target.
-
- Posts: 58
- Joined: Tue, 4. May 10, 23:07
Maybe a stupid question, but is there a way to do a performance analysis on X3 scripts like you would with a program? That is, at some point in my game where it's lagging incredibly badly, could I do something to see how many scripts, what scripts, or how mjuch time a script is using? Would be greatly useful in figuring out why 3 or so capships are lagging sometimes but not others.
Edit: As o the above, this is actually because they're too accurate. It's a rough problem in Naval shuffle with beam weapons for example, that they'll miss very nearly due to gentle manuevering of either ship. Typically, in a low accuracy situation, you want to saturate the target with shots: Rather than aiming at where they will be, aim at where they could be. Compare the hit rate of a single FBC in NS to the hit range of 6 of them, each with a tiny innaccuracy. The solution is either to make the weapons slower and more destructive (it doesn't matter if you miss several antifighter shots when one good hit blows off half their health!) or faster with shorter "beam" durations, so that the randomizer can trigger more often - closer to projectile weapons and their small spread + high fire rate 'cone'.
Edit: As o the above, this is actually because they're too accurate. It's a rough problem in Naval shuffle with beam weapons for example, that they'll miss very nearly due to gentle manuevering of either ship. Typically, in a low accuracy situation, you want to saturate the target with shots: Rather than aiming at where they will be, aim at where they could be. Compare the hit rate of a single FBC in NS to the hit range of 6 of them, each with a tiny innaccuracy. The solution is either to make the weapons slower and more destructive (it doesn't matter if you miss several antifighter shots when one good hit blows off half their health!) or faster with shorter "beam" durations, so that the randomizer can trigger more often - closer to projectile weapons and their small spread + high fire rate 'cone'.
-
- Posts: 851
- Joined: Fri, 13. Jun 08, 13:14
yes 'sort of', TC has an inbuilt listing of all the scripts on stack. It will count how many times they are called/executed. This gives a very very rough idea: a script called 10 times will almost certainly have less impact than a script called 200000 times.
*However*, unfortunately it gives no indication of how many cycles have been required for each execution of the script. So, a script that exits after only a few functions will have much less impact than a major script but there is no built in way of saying so.
In addition we, as scripters, dont really have much info on how the functions we are able to call are actually executed and so have no real idea over how much processing is involved for each. E.g. the processing required for a 'get object size' function (essentially calling a method/function that has been hardcoded)
As a weak workaround: Gazz wrote a little lib script to return the engine fps to quite a degree of accuracy. You could use this to benchmark the performance impact of some scripts.
And to specifically answer your concern over a few specific ships: try and see what tasks are running on the ships (by tasks I dont mean commands; e.g. not "Action avoiding" in the ship info panel but rather script tasks on stack for the ship)
*However*, unfortunately it gives no indication of how many cycles have been required for each execution of the script. So, a script that exits after only a few functions will have much less impact than a major script but there is no built in way of saying so.
In addition we, as scripters, dont really have much info on how the functions we are able to call are actually executed and so have no real idea over how much processing is involved for each. E.g. the processing required for a 'get object size' function (essentially calling a method/function that has been hardcoded)
As a weak workaround: Gazz wrote a little lib script to return the engine fps to quite a degree of accuracy. You could use this to benchmark the performance impact of some scripts.
And to specifically answer your concern over a few specific ships: try and see what tasks are running on the ships (by tasks I dont mean commands; e.g. not "Action avoiding" in the ship info panel but rather script tasks on stack for the ship)
-
- Posts: 58
- Joined: Tue, 4. May 10, 23:07
Specific case is IR mod with response ships (fighters and capitals) active in a system with 3 teladi huge ships all hostile. Looking away is smooth, but looking at the ships temporarily lagged up. Will need to test more as it could be me hitting my free RAM limit of about 3.3gigs. It is certainly not graphical either. It could be a comination of MARS + IR's Improved Carrier feature.
-
- Posts: 2033
- Joined: Wed, 29. Jun 05, 01:45
-
- Posts: 58
- Joined: Tue, 4. May 10, 23:07
Mostly because this game is very very light graphically for my card. I get better performance on higher settings than low ones
Second, unless this game pauses the engine when waiting on a frame to render...
Going to boot up now, and see if my RAM was just full. Bloody game eats so much o.o
edit: Yep, appeared to be RAM related. I just booted up into the sector, and while it lagged once initially when looking, it now smoothly loads the ships into view.

Going to boot up now, and see if my RAM was just full. Bloody game eats so much o.o
edit: Yep, appeared to be RAM related. I just booted up into the sector, and while it lagged once initially when looking, it now smoothly loads the ships into view.
-
- Posts: 2033
- Joined: Wed, 29. Jun 05, 01:45
The game does pause to render frames. I used to run x3r on a VERY old geforce 3 (min requirements is like gf 4 or 5+ or something). The game would literally go to about 1/10th the speed and render a frame about every 2 seconds. The game is single threaded so it has to complete one action before it can move on.
Are you sure it isn't just that when you first look at a ship it lags?
As I know with AQC I find it actually makes performance worse for me, as it keeps loading the different quality textures and models. (as loading the resources, does seem to tax the computer more heavily than continuing to render existing stuff)
Are you sure it isn't just that when you first look at a ship it lags?
As I know with AQC I find it actually makes performance worse for me, as it keeps loading the different quality textures and models. (as loading the resources, does seem to tax the computer more heavily than continuing to render existing stuff)
-
- Posts: 58
- Joined: Tue, 4. May 10, 23:07
As far as I can tell, it has to do with running out of RAM after playing for a while. Maybe scripts are lowering my 'buffer' and I'm just noticing lag that was already there now. Gonna try with medium shaders. Could also be my card's memory getting pissed, depending on how much VRAM X3 takes at high settings on 1920x1080
Edit:How do I get that list of script calls? Well, found some, but it only shows 80 each for two scripts, even though it says about 9800 are running
Edit:How do I get that list of script calls? Well, found some, but it only shows 80 each for two scripts, even though it says about 9800 are running
-
- Posts: 2035
- Joined: Wed, 18. Aug 10, 14:28
If you are running out of RAM and getting skipping/stuttering its more likely VRAM than normal RAM. Even if your normal RAM usage is high when looking at objects which cause a stutter is the VRAM that is getting overfilled.
"If you’re not prepared to be wrong, you’ll never come up with anything original."
Sir Ken Robinson
Sir Ken Robinson