[Discussion] Generic X3TC S&M questions II
Moderators: Scripting / Modding Moderators, Moderators for English X Forum
-
- Posts: 800
- Joined: Tue, 21. Aug 07, 01:31
@ eldyranx3
By using a command line like you have there ie:
$PP = Find Station in Galaxy = Start Sector = Saturn Class or Type = Terran Protein Paste Blending Facility L Race = Terran Flags = Null Ref Obj = Null Max Jumps = 10 Num = 10
You have actually set up an array of stations and placed them into the variable name of $PP. You will need to examine each element of that array and isolate it into a separate variable value (which will be the individual stations. You need to use a loop structure code to do this, then add the wares "if" variable = station.
By using a command line like you have there ie:
$PP = Find Station in Galaxy = Start Sector = Saturn Class or Type = Terran Protein Paste Blending Facility L Race = Terran Flags = Null Ref Obj = Null Max Jumps = 10 Num = 10
You have actually set up an array of stations and placed them into the variable name of $PP. You will need to examine each element of that array and isolate it into a separate variable value (which will be the individual stations. You need to use a loop structure code to do this, then add the wares "if" variable = station.
-
- Posts: 2178
- Joined: Sat, 14. Jan 06, 21:29
-
- Posts: 1962
- Joined: Tue, 8. Jan 08, 18:19
It's really not that hard. Just have a look at the following code:Erk! More scripting skill required than I have at the moment
Code: Select all
$stationArray = array alloc: size = 0
$station = create station ...
append $station to array $stationArray
$station = create station ...
append $station to array $stationArray
... (repeat for all stations)
$count = size of array $stationArray
while $count
dec $count =
$station = $stationArray[$count]
$station -> add product to factory or dock: {Energy Cells}
... (add all products here)
= wait 1 ms
end
It's really straight-forward, I think.
Greetings,
ScRaT
-
- Posts: 2178
- Joined: Sat, 14. Jan 06, 21:29
Hmm loops. *Breaks out the MSCI handbook* I'll have to read up on them a bit.
Different problem, and I know its been asked before, but on a newly created station, after adding in products, resources, and then adding max stock of the primary resource (In this case ECs), what do I have to do to get the scripted factory to start its production cycle?
Different problem, and I know its been asked before, but on a newly created station, after adding in products, resources, and then adding max stock of the primary resource (In this case ECs), what do I have to do to get the scripted factory to start its production cycle?
-
- Posts: 1962
- Joined: Tue, 8. Jan 08, 18:19
Well, start it:what do I have to do to get the scripted factory to start its production cycle?
Code: Select all
$station -> factory production task: on=[TRUE]
My Question on RegExes is still unanswered. =)
Greetings,
ScRaT
-
- Posts: 2178
- Joined: Sat, 14. Jan 06, 21:29
-
- Posts: 1962
- Joined: Tue, 8. Jan 08, 18:19
No problem, I'll just repeat the question.
ScRaT

Greetings,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:Reading this text from the T-File and logging it to the logbook shows, that everything is unescaped correctly.Code: Select all
<t id=10003">\^\(I\|V\|X\)+\$</t>
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
-
- Posts: 22
- Joined: Tue, 18. Nov 08, 00:16
i accidently did something, somewhere, i dunno where and now i got a pop up that wont go away. if i enter something or esc it just comes back. any idea how i can get it to go away?
[ external image ][/list]
[ external image ][/list]
-
- Posts: 22575
- Joined: Sat, 23. Apr 05, 21:42
-
- Posts: 534
- Joined: Thu, 21. Sep 06, 19:47
Is there an obvious reason why many scripts don't have .spk versions? It's so much easier to work with those. Most of the time a script ends up breaking something else so it's nice to just click disable or uninstall on the culprit.
Give a man a fish and he'll eat for a day, teach a man how to fish and he'll eat yours.
-
- Posts: 22575
- Joined: Sat, 23. Apr 05, 21:42
Yes. Ask the scripters, whoCith wrote:Is there an obvious reason why many scripts don't have .spk versions?
* have never heard of Plugin Manager
* wrote their scripts before Plugin Manager was released
* are so busy scripting that they have no time for trivialities, such as playing the game or observing file management challenges
One could as well ask why all scripts don't offer simple zip-compressed package.
-
- Posts: 4
- Joined: Sat, 31. Jan 09, 03:20
Hey guys,
I've been using dozens of scripts and mods, but have just recently started using ship packages to add some more variety to what I blow up. I want to make some certain ships unavailable from shipyards so I can spawn one and RE it, leaving me to build a custom fleet. I assume I can accomplish this by importing the ship spk's to the ship creator, but when I go to the customize tab, it tells me to select the X3 directory. I only have :TC, not :R, which I believe it is referring to, as I am selecting the X3:TC directory through Steam.
Of course I could be going about this the wrong way. To specify, I just want to edit some ship spk's that I downloaded so that they will not be sold from universe shipyards. Hope that clears it all up.
I've been using dozens of scripts and mods, but have just recently started using ship packages to add some more variety to what I blow up. I want to make some certain ships unavailable from shipyards so I can spawn one and RE it, leaving me to build a custom fleet. I assume I can accomplish this by importing the ship spk's to the ship creator, but when I go to the customize tab, it tells me to select the X3 directory. I only have :TC, not :R, which I believe it is referring to, as I am selecting the X3:TC directory through Steam.
Of course I could be going about this the wrong way. To specify, I just want to edit some ship spk's that I downloaded so that they will not be sold from universe shipyards. Hope that clears it all up.
-
- Posts: 7232
- Joined: Fri, 9. Apr 04, 21:19
Hey people
Right I have begun to join the dark side and start a bit of minor scripting so first things first any good comprehensive tutorials around?
I have looked at Cycrow's guide here and it has been very helpful thus far, but I'm finding it rather limited.
Many of the other more basic guides etc go all the way back to X2 and whilst I get that many of the basics maybe the same most of the X2 related links are now dead.
I'll also give a basic run down of what I'm trying to do in the hop of more specific help. I'm trying to get the subtitle bar to display the current Hull %, Shield % and Speed of the playership.
This I have managed but I have one main issue:
1- the display is static, to make it dynamic I guess I'd have to get the script to repeat itself every few ms or so. Beyond me so far.
Code below if relevent
Right I have begun to join the dark side and start a bit of minor scripting so first things first any good comprehensive tutorials around?
I have looked at Cycrow's guide here and it has been very helpful thus far, but I'm finding it rather limited.
Many of the other more basic guides etc go all the way back to X2 and whilst I get that many of the basics maybe the same most of the X2 related links are now dead.
I'll also give a basic run down of what I'm trying to do in the hop of more specific help. I'm trying to get the subtitle bar to display the current Hull %, Shield % and Speed of the playership.
This I have managed but I have one main issue:
1- the display is static, to make it dynamic I guess I'd have to get the script to repeat itself every few ms or so. Beyond me so far.
Code below if relevent
Code: Select all
001 $Hull = [PLAYERSHIP] -> get hull percent
002 $Shield = [PLAYERSHIP] -> get shield percent
003 $Speed = [PLAYERSHIP] -> get current speed
004 $msg = sprintf: pageid=7012 textid=1, $Hull, $Shield, $Speed, null, null
005 display subtitle text: text=$msg duration=10000 ms
006 return 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
-
- Moderator (Script&Mod)
- Posts: 22438
- Joined: Sun, 14. Nov 04, 23:26
one slight problem with doing that, if u have it permantly displaying, then u might miss other messages that may be there.
a few scripts use that for status reports.
but for the loop, its fairly simple
that will update every second
a few scripts use that for status reports.
but for the loop, its fairly simple
Code: Select all
001 while [TRUE]
002 $Hull = [PLAYERSHIP] -> get hull percent
003 $Shield = [PLAYERSHIP] -> get shield percent
004 $Speed = [PLAYERSHIP] -> get current speed
005 $msg = sprintf: pageid=7012 textid=1, $Hull, $Shield, $Speed, null, null
006 display subtitle text: text=$msg duration=10000 ms
007 wait 1000 ms
008 end
009 return null
-
- Posts: 1
- Joined: Sat, 24. Oct 09, 23:28
Player Shipyards
I can't post a new topic for some reason, so I'm posting on here.
I bought a shipyard. It looks great. Now what do I do with it?
I can access the ship and station sell price, but I can't buy any ships. I dock at it, press trade, and it takes me to menu where I can exchange stock and change sell price preferences. I take a ship that it says "1" in stock, and transfer it to my cargo. Nothing happens. Is there any good to this or am I wasting my time and money?
I bought a shipyard. It looks great. Now what do I do with it?
I can access the ship and station sell price, but I can't buy any ships. I dock at it, press trade, and it takes me to menu where I can exchange stock and change sell price preferences. I take a ship that it says "1" in stock, and transfer it to my cargo. Nothing happens. Is there any good to this or am I wasting my time and money?
-
- Moderator (Script&Mod)
- Posts: 22438
- Joined: Sun, 14. Nov 04, 23:26
-
- Posts: 2178
- Joined: Sat, 14. Jan 06, 21:29
Since I had no luck randomly spawning special objects to see which one the Terran Gate model is assigned to, Ive decided to bite the bullet and look at the mission director XML used for the Aldrin Expansion plot. I'm hoping to see how Egosoft plunked down the working Terran gate in Neptune instead of the standard create : gate script command.
Anyone have an idea which xx.cat I need to unpack to find the relevant XML?
Edit: Located. Looks like the MD spawns the gate in Terran Unknown Sector 2 using the code:
Does this mean spawning the Terran models for jump gates is a MD code only deal?
Anyone have an idea which xx.cat I need to unpack to find the relevant XML?
Edit: Located. Looks like the MD spawns the gate in Terran Unknown Sector 2 using the code:
Code: Select all
<destroy_object object="L2M011.TUS2 N Gate"/>
<destroy_object object="L2M011.Neptune Facility"/>
<play_cutscene file="Version 2 S3 C1"/>
<create_gate name="L2M011.TUS2 N Gate" safety="0" typename="SS_WG_NORTH" gate="north">
<position x="-3km" y="0" z="30km"/>
<sector sector="L2M011.New Terran 2"/>
<destination sector="L2M011.Neptune" gate="south"/>
</create_gate>
<create_gate name="L2M011.Neptune Gate" safety="0" typename="SS_WG_TJ_SOUTH" gate="south">
<position x="20km" z="-40km"/>
<sector sector="L2M011.Neptune"/>
<destination sector="L2M011.New Terran 2" gate="north"/>
</create_gate>
-
- Posts: 7232
- Joined: Fri, 9. Apr 04, 21:19
Many thanks, I'm coming along!Cycrow wrote:one slight problem with doing that, if u have it permantly displaying, then u might miss other messages that may be there.
a few scripts use that for status reports.
but for the loop, its fairly simple
that will update every secondCode: Select all
001 while [TRUE] 002 $Hull = [PLAYERSHIP] -> get hull percent 003 $Shield = [PLAYERSHIP] -> get shield percent 004 $Speed = [PLAYERSHIP] -> get current speed 005 $msg = sprintf: pageid=7012 textid=1, $Hull, $Shield, $Speed, null, null 006 display subtitle text: text=$msg duration=10000 ms 007 wait 1000 ms 008 end 009 return null
I now what to turn the display on and off, I have managed to set up a global variable that alternates between 1 and 0 each time the script is run, The idea being eventually to call the script with a hotkey.
So with the following code section:
Code: Select all
025 while $tog ==1
026 |$hull = [PLAYERSHIP] -> get hull percent
027 |$shield = [PLAYERSHIP] -> get shield percent
028 |$speed = [PLAYERSHIP] -> get current speed
029 |$msg = sprintf: pageid=7012 textid=1, $hull, $shield, $speed, null, null
030 |display subtitle text: text=$msg duration=10 ms
031 @ |= wait 10 ms
032 end
033 return null
The first time I run it ($tog set to 1) It come up fine, the second time I run it ($tog should now be 0) the text does not disappear and remains live.
I suspect I do not yet understand the intricacies of the "while" statement, can someone enlighten me?
"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
-
- Moderator (Script&Mod)
- Posts: 22438
- Joined: Sun, 14. Nov 04, 23:26
from the looks of it, ur not doing the global variable correctly.
basically, no where in ur loop are u ever changing $tog, so once it starts, it will never stop.
the script could looking something like this
then each loop, it checks the status of your global variable to see if it no longer exists.
also, 10ms is really way too low, u really dont need it updating that fast and tieing up the script queue.
500ms will be plenty fast enough (every half a second)
also, i would set the duration of the subtitle to twice the wait time, to prevent flicker.
so 500ms wait, 1000ms duration.
now for a few suggestions.
there are 2 other (slightly more advanced) methods of creating an on off switch.
the first is to create an AL Plugin, this adds an option in the AL Settings menu, then u can switch between on and off. Just ignore the timer event and trigger the script with the on and off events.
second, u could use my Community Plugin Config scripts, that allows you to add ur own scripts and options to a custom menu.
this can also add an on off button that u can toggle between to enable/disable.
the menu is opened via a hotkey, and ur option will be listed there along with any other scripts that use it giving a central place for those kinds of options.
of course, setting up a toggle hotkey is very straight forward, and usually works. Again, to make it easier for you, u can use my hotkey manager, so u only need to register ur hotkey, and not worry about removing it or uninstalling, etc
basically, no where in ur loop are u ever changing $tog, so once it starts, it will never stop.
the script could looking something like this
Code: Select all
if get global variable: name='my.variable'
set global variable: name='my.variable', value = NULL
else
set global variable: name='my.variable', value = [TRUE]
while get global variable:name='my.variable'
.... (rest of your loop)
end
end
also, 10ms is really way too low, u really dont need it updating that fast and tieing up the script queue.
500ms will be plenty fast enough (every half a second)
also, i would set the duration of the subtitle to twice the wait time, to prevent flicker.
so 500ms wait, 1000ms duration.
now for a few suggestions.
there are 2 other (slightly more advanced) methods of creating an on off switch.
the first is to create an AL Plugin, this adds an option in the AL Settings menu, then u can switch between on and off. Just ignore the timer event and trigger the script with the on and off events.
second, u could use my Community Plugin Config scripts, that allows you to add ur own scripts and options to a custom menu.
this can also add an on off button that u can toggle between to enable/disable.
the menu is opened via a hotkey, and ur option will be listed there along with any other scripts that use it giving a central place for those kinds of options.
of course, setting up a toggle hotkey is very straight forward, and usually works. Again, to make it easier for you, u can use my hotkey manager, so u only need to register ur hotkey, and not worry about removing it or uninstalling, etc
-
- Posts: 7232
- Joined: Fri, 9. Apr 04, 21:19
Sorry, very new to all this, still learning and I realise my methods/logic will be crude!!Cycrow wrote:from the looks of it, ur not doing the global variable correctly.
Code: Select all
if get global variable: name='my.variable' set global variable: name='my.variable', value = NULL else set global variable: name='my.variable', value = [TRUE] while get global variable:name='my.variable' .... (rest of your loop) end end
Lets see if I understand correctly
In my setup script I should set the global variable to "null"
Your code section 1st checks the state of the global variable
If its "TRUE" it is set to "Null"
Otherwise it Is set to TRUE
If it's TRUE loop starts.
So am I right in thinking that my crude way of alternating the variable every time the script is run (below) is no longer necessary?
Code: Select all
001 $tog = get global variable: name='xsi.tog'
002 inc $tog =
003 if $tog > 1
004 |$tog = 0
005 end
006 set global variable: name='xsi.tog' value=$tog
"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