[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

User avatar
Nividium
Posts: 800
Joined: Tue, 21. Aug 07, 01:31

Post by Nividium »

@ 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.
User avatar
eldyranx3
Posts: 2178
Joined: Sat, 14. Jan 06, 21:29
xr

Post by eldyranx3 »

Erk! More scripting skill required than I have at the moment :oops:

Thanks so much for the solution though! I really appreciate it.
User avatar
ScRaT_GER
Posts: 1962
Joined: Tue, 8. Jan 08, 18:19
x3tc

Post by ScRaT_GER »

Erk! More scripting skill required than I have at the moment
It's really not that hard. Just have a look at the following code:

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
So, first you set up every station and save them in an array (think of it as a list of stations). Afterwards you loop over every station in that list and add your products.

It's really straight-forward, I think.

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

Post by eldyranx3 »

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?
User avatar
ScRaT_GER
Posts: 1962
Joined: Tue, 8. Jan 08, 18:19
x3tc

Post by ScRaT_GER »

what do I have to do to get the scripted factory to start its production cycle?
Well, start it:

Code: Select all

$station -> factory production task: on=[TRUE]
Btw:
My Question on RegExes is still unanswered. =)

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

Post by eldyranx3 »

Thanks everyone for all your help.

@ ScRaT_GER - Sorry for stealing the attention from your question with all the Newbie stuff.
User avatar
ScRaT_GER
Posts: 1962
Joined: Tue, 8. Jan 08, 18:19
x3tc

Post by ScRaT_GER »

No problem, I'll just repeat the question. ;)
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?
Greetings,
ScRaT
Dant12
Posts: 22
Joined: Tue, 18. Nov 08, 00:16

Post by Dant12 »

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]
jlehtone
Posts: 22575
Joined: Sat, 23. Apr 05, 21:42
x4

Post by jlehtone »

[url=http://forum.egosoft.com/viewtopic.php?t=216690]TC Download Library[/url] states that Text Page 8804 is used by the RRF (by LV). Therefore, the dialog attempts to show some RRF text, but fails, and all you see is 8804-216.

So LV would be the person, who might know best. :)
User avatar
Cith
Posts: 534
Joined: Thu, 21. Sep 06, 19:47
x3tc

Post by Cith »

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.
jlehtone
Posts: 22575
Joined: Sat, 23. Apr 05, 21:42
x4

Post by jlehtone »

Cith wrote:Is there an obvious reason why many scripts don't have .spk versions?
Yes. Ask the scripters, who
* 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.
draeka182
Posts: 4
Joined: Sat, 31. Jan 09, 03:20

Post by draeka182 »

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.
Bishop149
Posts: 7232
Joined: Fri, 9. Apr 04, 21:19
x3

Post by Bishop149 »

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

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
Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22438
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow »

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

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
that will update every second
Khadger
Posts: 1
Joined: Sat, 24. Oct 09, 23:28
x4

Player Shipyards

Post by Khadger »

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?
Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22438
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow »

i assume ur talking about some kind of mod u've downloaded ?

as u cant buy them in the stardard game, and without a script/mod to use them, they wont do anything if u cheat one in either.

if u have a script/mod that adds shiyards, u will need to ask in the thread you got it from
User avatar
eldyranx3
Posts: 2178
Joined: Sat, 14. Jan 06, 21:29
xr

Post by eldyranx3 »

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:

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>
Does this mean spawning the Terran models for jump gates is a MD code only deal?
Bishop149
Posts: 7232
Joined: Fri, 9. Apr 04, 21:19
x3

Post by Bishop149 »

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

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
that will update every second
Many thanks, I'm coming along!
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

$tog is called from the global variable that alternates.
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
Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22438
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow »

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

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
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
Bishop149
Posts: 7232
Joined: Fri, 9. Apr 04, 21:19
x3

Post by Bishop149 »

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
Sorry, very new to all this, still learning and I realise my methods/logic will be crude!!

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
Edit: Appears the answer to my question is yes, I remove my crude method from the beginning and use yours and it works well. . . . I will study the structure of loop more carefully!
"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

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