[Discussion] Generic X3TC S&M questions I

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

KNT79
Posts: 80
Joined: Thu, 10. Sep 09, 19:14

Post by KNT79 »

Thank you for answers. That is what I expected - if you script advanced AI routines you have to check for IS/OOS in your scripts.

Another question:
Where is jobs engine located, which spawns ships and gives them jobs? Is it hardcoded or scripted in the stock scripts? (I mean the overall control part, not particular job scripts).
NOT PEACE BUT A SWORD
User avatar
s9ilent
Posts: 2033
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent »

It's hard coded. The only editable parts are the tjobs, tjobswings, and the scripts reference in tjobs.
Kapakio
Posts: 4442
Joined: Thu, 20. Oct 05, 20:43
x4

Post by Kapakio »

Sorry if this questions has been made but, where can I get information about the status of XTM for TC (if it's ever being made)?

EDIT: Thanks a lot!
Last edited by Kapakio on Wed, 16. Sep 09, 21:30, edited 1 time in total.
User avatar
Ponder
Posts: 1585
Joined: Wed, 19. Nov 08, 15:58
x3tc

Post by Ponder »

I'm sure that in the german S&M part is a topic about XTM for TC so I think in the english part is one too. Here you can find it
Did you use the search function? [sounds crazy but I'm from germany and I don't know a better word]
Too geek for real life.
jlehtone
Posts: 22477
Joined: Sat, 23. Apr 05, 21:42
x4

Post by jlehtone »

Schaf123 wrote:I'm sure that in the german S&M part is a topic about XTM for TC so I think in the english part is one too. Here you can find it
The thread you did link does include a link to this (en). ;)
User avatar
Ponder
Posts: 1585
Joined: Wed, 19. Nov 08, 15:58
x3tc

Post by Ponder »

Ohh...
I forgot my glasses^^
Too geek for real life.
User avatar
s9ilent
Posts: 2033
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent »

I this is a long shot but.... (an extreme long shot)
Q: Any chance the formula(/equation/code) for marine boarding is available some where?

What I want to do is revisit my (macro) ship crews idea, and I thought, why don't I just stack crews. e.g. "1 crew" = (fight, eng, mech, hack) {10,2,4,10}, so if I had "1000 crew", it would simply just be {10 000, 2 000. 4 000, 10 000}.
But then that might produce... skewed results with normal marine boarding action.

(If using marines becomes too difficult, then I may consider passengers, or just going back to the local variable idea)
ladyboy
Posts: 69
Joined: Fri, 14. Sep 07, 19:18

Post by ladyboy »

Hoping somebody can help with this...

I'm trying to get the sector positions of all ships (of a certain class and race) in the player's sector.

i've managed to find all ships of class and race in the universe but that's not right... Is it possible to filter the array by sector? or is there any easier way?
All those moments will be lost.. in time, like tears.. in rain.
[ external image ]
User avatar
s9ilent
Posts: 2033
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent »

@ladyboy,
You would probably be better of by using get ship array from sector, and then removing non player owned ships.

Code: Select all

$sect = [playership] -> get sector
$list = get ship array from sector $sect

$count = size of array $list
while $count > 0
dec $count =
 $ship = $list[$count]
 $ship.owner = $ship -> get owner
 skip if $ship.owner == {player}
  remove element from array $List at index $count
end
User avatar
s9ilent
Posts: 2033
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent »

Q: About the script debugger menu

How come after it runs a ! script (e.g. the !lib. equipment one) it supresses all output in the main debug window?
(I'm running trace debug, and I can see as I press enter, the variables are changing, so it is doing stuff, but the top window won't update with the new code)
ladyboy
Posts: 69
Joined: Fri, 14. Sep 07, 19:18

Post by ladyboy »

How can i invert a number?

eg.
if $x=200
how do i make it output -200
if $x=-200
how do i make it output 200

i've tried using if and if not

Code: Select all

if $x < 0 
$x.inv = '+' $x

if not $x < 0 
$x.inv = '-' $x

the above doesn't work - "Invalid expression - tokens remaining"

edit: Thanks ScRaT! works perfectly
Last edited by ladyboy on Fri, 18. Sep 09, 22:46, edited 1 time in total.
All those moments will be lost.. in time, like tears.. in rain.
[ external image ]
User avatar
ScRaT_GER
Posts: 1962
Joined: Tue, 8. Jan 08, 18:19
x3tc

Post by ScRaT_GER »

How about $x.inv = -1 * $x?

-1 is an integer, not a string.

Greetings,
ScRaT
User avatar
s9ilent
Posts: 2033
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent »

You can go 1 step lazier and just have - $var
(Note, - (negative), is not the same as '-' (string hyphen))

And I suspect that is why you got the error in the first place.



it should read $x.inv = - $x
(Note the lack of ' ')





Q: How do I make Visual Studio 2008 'tie in' with MD stuff?
(I'm rather new to MD-ing and VS, but I know the S.E back to front)
NM, found it, its called a schema, and its loaded via the XML menu (you have to open/create an XML first for the menu to display)





Q2: Can preloaded scripts be used with stations??
(I was under the impression they couldn't -baseless assumption- but then I noticed Cycrow's RnD script uses one???)
Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22413
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow »

yes preloads can be used by stations, and ship additional commands

althou preloads aren't technically needed for stations anyways.

it uses the same system so the functionality was added to both
KNT79
Posts: 80
Joined: Thu, 10. Sep 09, 19:14

Post by KNT79 »

1. Can I control the 3d person camera from scripts?

2. What is relvalue? Player relvalue, NPC relvalue - what for, what's the main idea?
NOT PEACE BUT A SWORD
ladyboy
Posts: 69
Joined: Fri, 14. Sep 07, 19:18

Post by ladyboy »

I've been trying to get an array of all Xenon fighters in the player's sector.

I'm in a xenon sector full of ships and $count=0
only time $count is above 0 is when i remove the "skip if" bit but then i get all the xenon fighters in the universe lol

I'm using a slightly modified code to what s9ilent gave me on the previous page.

Code: Select all

$sect = [PLAYERSHIP] ->get sector
$ship.arr = get ship array: of race {Xenon} class/type={Fighter 2034}
$count = size of array $ship.arr
while $count > 0 
  dec $count =
  $ship = $ship.arr[$count]
  $ship.sector = $ship->get sector
  skip if $ship.sector == $sect 
    remove element from array $ship.arr at index $count
end
return null

Edit:
Thanks... i'm such a n00b. I was calling Count in the wrong place (after the END) so i kept getting a big fat zero. It's working now.


I have another question... I've been checking the $count output by simpley getting it to write to the player log at the moment.
The below script writes a new player log message for each fighter ship and displaying $count. (eg 70 ships. 70 player log messages starting with 69 down to 0)

The problem is that it seems to be counting all the ships in the sector ignoring the class and race. With it set to filter for fighters, $count in argon prime was 70. I've changed it to M1 to confirm this, One M1 in the sector and $count was outputting 69. (1 less.. i'm assuming a ship left the sector)

Code: Select all

$sect = [PLAYERSHIP]->get sector
$list = $sect->get ship array from sector/ship/station
$count = size of array $list
while $count > 0 
  dec $count =
  $ship = $list[$count]
  $ship.owner = $ship->get owner race
  skip if $ship.owner == {Player} 
    remove element from array $list at index $count
  $ship.class = $ship->get object class
  skip if $ship.class == {Fighter 2034} 
    remove element from array $list at index $count
  write to player logbook $count
end
return null
can anybody see why it isn't filtering by race and ship class?
Last edited by ladyboy on Mon, 21. Sep 09, 03:37, edited 2 times in total.
All those moments will be lost.. in time, like tears.. in rain.
[ external image ]
User avatar
ScRaT_GER
Posts: 1962
Joined: Tue, 8. Jan 08, 18:19
x3tc

Post by ScRaT_GER »

1. Can I control the 3d person camera from scripts?
Well, there is one command in the "Other Commands" section which says: "set monitor mode and viewpoint...". But I never used it so I guess you'll have to try, if that's what you're looking for.
2. What is relvalue? Player relvalue, NPC relvalue - what for, what's the main idea?
The RelVal, also called relative value, is a tricky thing. It controls about everything concerning wares - price, production time, amount of ressources, amount of products/cycle.
With the two values, one for NPC and one for the player, you can differentiate between products produced by NPC fabs and ones produced by yours.

@ladyboy
Are you sure? The code looks fine to me.
At which line do you check the value of $count?

By the way: I'd rather use the command "get ship array from sector/ship/station" on the sector, because it will most likely return a smaller array and thus require less time to filter (which you'll have to do anyways).

---------------------

Open question: What are B3D textures (come on - someone has to know!)?


Greetings,
ScRaT
User avatar
s9ilent
Posts: 2033
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent »

@Ladyboy,
your code is correct in that you ARE removing them via the race/type criteria, although, you are still printing ALL the entries to the log book

i.e. Consider changing
skip if $ship.class == {Fighter 2034}
remove element from array $list at index $count

to
if not $ship.class == {Fighter 2034}
remove element from array $list at index $count
continue
end
This will go like 69 68 (skip) (skip) 66 65 64 etc.

Either that, or just go through the array twice, once to clean, once to print the items and their index.

If you want your counts to be accurate, either
a) iterate from the 0 upwards, using remove element and count = count -1 in each continue case
b) iterate from 0 upwards, but use print $count - $num, where $num is initially 0, but increments at each time a continue is encountered
c) loop through the array twice
or some other method. (Different methods have some slight advantages/disadvantages depending on what your trying to do before/during/after the loop)








Q: Regular Expressions
I want to write a script to copy all the local variables from [THIS] to script arg $ship.

Rather then doing $list = [THIS] -> get all local variable keys, starting with='a'
A b BcCdDeEfF...123...!#%^&*)(<> .... and so on.
How would I do so with a regular expression and the following command?

$list = [THIS] -> get local variables: regular expression='???????'
User avatar
ScRaT_GER
Posts: 1962
Joined: Tue, 8. Jan 08, 18:19
x3tc

Post by ScRaT_GER »

Q: Regular Expressions
Just use the regular expression ".".
This should get you an array of all local variables. For more information look here.

Greetings,
ScRaT
KNT79
Posts: 80
Joined: Thu, 10. Sep 09, 19:14

Post by KNT79 »

Thank you ScRaT_GER :)

Another one (I have currently some big plans for this game 8) ):

Say, I want to create lots of objects (say, 100 or 1000) with some parameters set (the most obvious - coordinates). The best and simplest way I see is to write script for that. Now I want the script to get array of parameters as input. I think it is possible for the script to read that array from text file. I would be grateful for any thoughts or suggestions on how to organize this the best way.
NOT PEACE BUT A SWORD

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