[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

Bishop149
Posts: 7232
Joined: Fri, 9. Apr 04, 21:19
x3

Post by Bishop149 »

Stupid question number 2309

How do you rename a script without cocking everything up?
"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
User avatar
ScRaT_GER
Posts: 1962
Joined: Tue, 8. Jan 08, 18:19
x3tc

Post by ScRaT_GER »

Either by using the ingame script list to copy the script using "c" and thereby giving it a new name, or by using the Exscriptor and simply saving the script under a different name.

Still unanswered questions of mine in the following post: Link

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

Post by Cycrow »

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?
not enterly sure which RegEx parser is used, but most standard regex should work. However, it is abit fussy. u might just have to play around with it until u get it right.

i would remove the $ at the end and try that
ScRaT_GER wrote:When using the "call named script" command, I noticed that in the ingame SE the option "START" is not available.
However, in the Exscriptor it is possible to use that startoption and it works perfectly well, as long as you START the script on an object.
If you START it globally, it will call the script in an infinite loop which can crash your game:

Code: Select all

* works perfectly well:
START [PLAYERSHIP]->call named script: script='a.test', null, null, null, null, null

* crashes your game:
$null = null
START $null->call named script: script='a.test', null, null, null, null, null
So was the START option forgotten or left out on purpose? If the latter applies, why was it left out?
the start wasn't added due to it not working correctly or having any proper testing.

there is the start named script command as well thou, which will do the same thing but work properly
User avatar
ScRaT_GER
Posts: 1962
Joined: Tue, 8. Jan 08, 18:19
x3tc

Post by ScRaT_GER »

Thanks for the answers, Cycrow.
i would remove the $ at the end and try that
Mh, I think I already tried that. I guess, I shall try harder then. :)
the start wasn't added due to it not working correctly or having any proper testing.
Oh, okay...
there is the start named script command as well thou, which will do the same thing but work properly
The problem with this command is, that it cannot start global scripts. However I wrote a workaround, which works by calling the appropriate command depending on the object the script is running on.

Greetings,
ScRaT
User avatar
EmperorJon
Posts: 9378
Joined: Mon, 29. Dec 08, 20:58
x3tc

Post by EmperorJon »

I've forgotten how to get a Yes/No user input... :S Which command! :lol:
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
Bishop149
Posts: 7232
Joined: Fri, 9. Apr 04, 21:19
x3

Post by Bishop149 »

EmperorJon wrote:I've forgotten how to get a Yes/No user input... :S Which command! :lol:
If you mean from an argument then I can't help you, only just started experimenting with those myself. . . just poke though all the different options.

If you mean on an incoming message then Cycrows guide might help:
http://cycrow.thexuniverse.us/scripts/h ... index.html

Question of my own.

Arrays.

Just started poking around with these too, but can't see their utility. I must be missing something.
The following command for example:

Code: Select all

<RetVar> = <RefObj> get ship array from sector/ship/station
Rather helpfully creates an array of every ship in the sector. But I can then DO anything with the array unless I start calling each element individually. This seems to rather defeat the point.

How would I for example start applying other commands to EVERY element of an array.

A good tutorial on arrays would be nice if someone could point one out, the MSCI handbook only skims the details and the link here is dead
"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
User avatar
EmperorJon
Posts: 9378
Joined: Mon, 29. Dec 08, 20:58
x3tc

Post by EmperorJon »

So you want to grab everything in the array and do something?

For example, get all ships in the sector and change their name?

You have to cycle through the array and apply it individually to each...

So, for this example you would have...

(Variable 'Count' is just a good choice for easy understanding)

$Array = array of all ships in sector
$Count = size of array
While $Count
Dec. $Count
$Ship = $Array [$Count]
(Then, all the commands go fro $Ship here!)

To talk through it...
1. Gets the array.
2. Sets Count as the size of the array.
3. Basically, whilst count exists/is above 0...
4. Decrease it.
5. Ship is the part of the array at that level of decreasement, that count.

Then, it goes back to the while because it's still not 0, and continues for everything in the array.
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
User avatar
Gazz
Posts: 13244
Joined: Fri, 13. Jan 06, 16:39
x4

Post by Gazz »

Bishop149 wrote:How would I for example start applying other commands to EVERY element of an array.
Not. This is not a database application.
My complete script download page. . . . . . I AM THE LAW!
There is no sense crying over every mistake. You just keep on trying till you run out of cake.
Bishop149
Posts: 7232
Joined: Fri, 9. Apr 04, 21:19
x3

Post by Bishop149 »

EmperorJon wrote:So you want to grab everything in the array and do something?

For example, get all ships in the sector and change their name?

You have to cycle through the array and apply it individually to each...

So, for this example you would have...

(Variable 'Count' is just a good choice for easy understanding)

$Array = array of all ships in sector
$Count = size of array
While $Count
Dec. $Count
$Ship = $Array [$Count]
(Then, all the commands go fro $Ship here!)
Ah, ha Brilliant! Thanks a lot for the explanation!
That looks extremely similar to another bit of code I was trying to reverse engineer but i couldn't get my head round what it was doing!
"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
User avatar
EmperorJon
Posts: 9378
Joined: Mon, 29. Dec 08, 20:58
x3tc

Post by EmperorJon »

And another question of my own, where's the command for the price of a station? I know there isn't one directly, but hwat route do you go down? Do you use Relvals or something?
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
User avatar
ScRaT_GER
Posts: 1962
Joined: Tue, 8. Jan 08, 18:19
x3tc

Post by ScRaT_GER »

Code: Select all

$ware = $station -> get ware type code of object
$price = get maximum price for ware $ware
Greetings,
ScRaT
User avatar
EmperorJon
Posts: 9378
Joined: Mon, 29. Dec 08, 20:58
x3tc

Post by EmperorJon »

That's the one!

Thanks.
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22438
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow »

EmperorJon wrote:I've forgotten how to get a Yes/No user input... :S Which command! :lol:

Code: Select all

$ret = get user input: Var/Boolean, title='my yes/no question'
User avatar
EmperorJon
Posts: 9378
Joined: Mon, 29. Dec 08, 20:58
x3tc

Post by EmperorJon »

Aahh... Thanks.
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
xiriod
Posts: 1131
Joined: Wed, 6. Nov 02, 20:31
x3tc

Post by xiriod »

Don't know if this question fits here, but when a station is destroyed GOD-engine usually deploys a replacement after some time.

Now, I've been using the Board Station script by uberex and those stations that I have boarded and taken does not get rebuild by the GOD-engine it seems even after I repack them and move them to another sector. Does the big-G look for a signal or something that triggers the need to rebuild something?
Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22438
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow »

dont think it uses signals, i think it just periodically checks what stations are available in the universe, and then builds new ones that are needed/missing

it doesn't always build them back in the same place thou, there are a number of "proposed" stations in the map file, god simply picks one of these that are free and creates it, it will never have them all created at the same time however
xiriod
Posts: 1131
Joined: Wed, 6. Nov 02, 20:31
x3tc

Post by xiriod »

Cycrow wrote:dont think it uses signals, i think it just periodically checks what stations are available in the universe, and then builds new ones that are needed/missing

it doesn't always build them back in the same place thou, there are a number of "proposed" stations in the map file, god simply picks one of these that are free and creates it, it will never have them all created at the same time however
Ok, perhaps. I boarded and captured the Ghoul Missile Factory and transported it to my sector a while back. But G' hasn't replaced it yet though, and as far as I know it was the only one in the universe so it should be high on the list. I'll give it a week game-time and see, that should at the very least be enough :)
User avatar
eldyranx3
Posts: 2178
Joined: Sat, 14. Jan 06, 21:29
xr

Post by eldyranx3 »

GoD has issues replacing Terran Stations. Its because the Terran Economy is borked.
User avatar
EmperorJon
Posts: 9378
Joined: Mon, 29. Dec 08, 20:58
x3tc

Post by EmperorJon »

I was thinking, do stations have a set size of cargobay for each item?

For example, with my PSS stations they hold quite a lot of stuff, but each one only holds as much as the maximum of a really big station, for example it only holds 8 capital weapons, 50,000 energy cells etc.

Would there be a way to mod a station so it held twice, or even thrice as much?

The only effect it would have on the plugin is that it would eat a lot lot lot more! :D
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
User avatar
Gazz
Posts: 13244
Joined: Fri, 13. Jan 06, 16:39
x4

Post by Gazz »

The "production multiplier" for docks is in Globals.txt and for factories in TFactories.txt.
My complete script download page. . . . . . I AM THE LAW!
There is no sense crying over every mistake. You just keep on trying till you run out of cake.

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