[Discussion] Generic X3TC S&M questions I

The place to discuss scripting and game modifications for X³: Terran Conflict and X³: Albion Prelude.

Moderators: Moderators for English X Forum, Scripting / Modding Moderators

Kilrathi Avenger
Posts: 275
Joined: Fri, 6. Feb 04, 20:16
x3tc

Post by Kilrathi Avenger » Sun, 14. Feb 10, 12:49

Firstly, apologies for posting this here but the Community Script & Mod Download Library for X3: Terran Conflict is locked.

If anyone has the time would it be possible to add a section in the "Community Download List" area called Huds so that more exposure could be placed on some of the excellent work that has gone into this area.
"As I slide down the banister of life;
my job is just another splinter in the bum"

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

Post by Cycrow » Sun, 14. Feb 10, 16:14

TheEarl wrote:hi !
i tried to clear a marines training center (hope thats the english name) of its marines to spawn new troopers.
i tried it with:

Code: Select all

Script aaaa.test
Version: 0
for Script Engine Version: 44

Description
Description
Arguments
1: station1 , Var/Ship/Station , 'station'
Source Text

001   $marines = $station1 -> get marines array
002   $marines.size =  size of array $marines
003   
004   while not $marines.size == 0
005   |$marine = $marines[0]
006   |= $marine -> destroy passenger
007   |remove element from array $marines at index 0
008   |$marines.size =  size of array $marines
009   end
010   
011   display subtitle text: text='alle tot' duration=500 ms
012   return null 
as result i have 71 "unknown objects" in the station instead of 71 marines.
i tried

Code: Select all

destruct: show no explosion
with the same result.
then i moved them into a spawned TP and destroyed it, same result.
i wondered why the "unknown objects" are in the station and discovered another feature:
if you move marines with

Code: Select all

= $marine -> move passenger to ship $ship: set passenger as pilot=[FALSE]
you see them in the inventory of the TP and in the station (same names) and there still 71 left in the station. then i destroyed the TP manually in space and after this the named marines, that was in station and in TP are now "unknown objects" inside the station.
and not to forget, the destroy commands work well on marines, if i buy them manually into an TP (or other ship) and destroy them inside one of my ships. they dont convert to an "unknonwn object".
now the 2 questions:

1) can i clearly remove them from game when they are in training center ?
2) is there a way to move (or buy) them by script from a station into a ship ? (for another reason i need some of them alive :) )

thx for help !
Most of those marines commands are used for ships, and dont work the same way for stations.

the move passenger command will have weird results if the passenger is not currently in a ship.


a simple way to remove the marines, would be to use the add ware command.

Code: Select all

$amt = $station -> get amount of ware Marine
$amt = - $amt
= $station -> add $amt units of Marine
you can also use this to create new marines as well

Orfevs
Posts: 183
Joined: Thu, 22. Jan 09, 23:03
x3tc

Post by Orfevs » Mon, 15. Feb 10, 22:38

ScRaT_GER wrote:A boolean TRUE value would be 1 and not -1.
And still, this does not explain, why the signal fires when a ship is bought by the shipyard, although it only should fire, when the shipyard sells a ship.
That may be correct for the X3 script language, but in general -1 is the same as all bits set in a variable. Signed or otherwise.

What do you get when you buy more ships at once?
TCAN TC/AP Artificial Life, Menudriven Automated Ship/Station Namer
Spex: i7 4790K@4Ghz 16Gb DDR3 GTX970Strix(4Gb)
X:R 454 Hours. 15 hours unmodded.

User avatar
Gazz
Posts: 13244
Joined: Fri, 13. Jan 06, 16:39
x4

Post by Gazz » Mon, 15. Feb 10, 22:45

Orfevs wrote:That may be correct for the X3 script language, but in general -1 is the same as all bits set in a variable. Signed or otherwise.
No, only when signed. There is no unsigned -1. </smartass>

In X3 scripts, logical TRUE is defined as (not null).
That's why abominations like "if find ship..." (which returns null or a ship object) work just fine. =)
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.

Orfevs
Posts: 183
Joined: Thu, 22. Jan 09, 23:03
x3tc

Post by Orfevs » Tue, 16. Feb 10, 01:43

Gazz wrote:
Orfevs wrote:That may be correct for the X3 script language, but in general -1 is the same as all bits set in a variable. Signed or otherwise.
No, only when signed. There is no unsigned -1. </smartass>

In X3 scripts, logical TRUE is defined as (not null).
That's why abominations like "if find ship..." (which returns null or a ship object) work just fine. =)
You kill me. :lol:
TCAN TC/AP Artificial Life, Menudriven Automated Ship/Station Namer
Spex: i7 4790K@4Ghz 16Gb DDR3 GTX970Strix(4Gb)
X:R 454 Hours. 15 hours unmodded.

TheEarl
Posts: 352
Joined: Fri, 3. Aug 07, 17:27
x3ap

Post by TheEarl » Tue, 16. Feb 10, 11:52

@Cycrow
thank you for this good and short solution.

@all, including Cycrow :)
when i use this for creating new marines, i think they have random skills ?
another interesting point is, of which race are they, does it depend on the stations owner race ?
(if nobody knows, i will test this soon, i had no time so far)

Is it possible to load a selected (by script) marine into a ship in a clean way (without having him on ship and station at the same time) ?

if this is not possible, i have another idee for my script, that does not include automatically buying marines from station. so its not a big problem.

thank you !

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

Post by Cycrow » Tue, 16. Feb 10, 13:08

yes when you add a marine using the add ware command, they will get random stats, and usually will be of the same race as the station its added to, unless its a pirate station, then it'll be a random race.

when you say a clean way, what do you mean exactly ?

to create a marine yourself, you first create a passenger, then use the convert command to convert the passenger to a marine.

marines are basically just passengers with additional stats, adding the fighting skill to a passenger turns them into a marine

TheEarl
Posts: 352
Joined: Fri, 3. Aug 07, 17:27
x3ap

Post by TheEarl » Tue, 16. Feb 10, 14:18

Hi !

As you told before, the move of passenger does only work from ship to ship correctly and not from a station. i tested it and theres a marin in the ship and in the station. if i detroy the ship, the marine inside the station becomes an unknown object. a clean way means, that the marine should only exist on the ship after i moved it out of the station. i hope you understand my english.

greetings
TheEarl


p.s.
perhaps as a workaround i put all marines into an array with all stats and their names. then remove all from station as you told me and create new passengers first with the same name and race like before, train them to marine and give them back the stats. and create this marine, that i wanted to move into a ship on this ship. if nothing else helps.

Cronos988
Posts: 691
Joined: Mon, 27. Aug 07, 12:34
x3tc

Post by Cronos988 » Thu, 18. Feb 10, 12:25

Hey, could anyone point me to a tutorial/reference concerning how multiple scripts on the same object (i.e. a ship) work? I am thinking about some insight into interrupt, script priorities etc.

I want to adjust some of the behaviour of ships in X3TC and I want to know what happens when I interrupt a script, whether I can run multiple scripts at once on one object etc.

Northern Comfort
Posts: 16
Joined: Mon, 7. Jul 08, 03:24

Post by Northern Comfort » Fri, 26. Feb 10, 16:32

Didn't want to start a whole new thread on the matter, so here seems like a good place to ask-is there any way to affect how much ammo a weapon uses? For example-setting the Gauss Cannon to use 20 units of ammunition instead of 1?

VVV Thanks :)
Last edited by Northern Comfort on Fri, 26. Feb 10, 17:01, edited 1 time in total.

User avatar
Gazz
Posts: 13244
Joined: Fri, 13. Jan 06, 16:39
x4

Post by Gazz » Fri, 26. Feb 10, 16:53

No.
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.

Falconek
Posts: 113
Joined: Thu, 28. Jun 07, 14:10
x4

Post by Falconek » Sat, 27. Feb 10, 10:24

I extracted the director folder, using X3 editor 2, and I try to view director.htm, but all I got is a black window. Is this a known problem, and if so, what is solution to it? I don't see any errors in XML, css and htm files, but I don't know much about XML.

User avatar
ScRaT_GER
Posts: 1962
Joined: Tue, 8. Jan 08, 18:19
x3tc

Post by ScRaT_GER » Sat, 27. Feb 10, 12:08

If you're using Firefox to open the file, try to open it with the Internet Explorer. Firefox has problems displaying the file.

Greetings,
ScRaT

Falconek
Posts: 113
Joined: Thu, 28. Jun 07, 14:10
x4

Post by Falconek » Sat, 27. Feb 10, 12:24

I use IE and it is the same effect ><

Edit: ok, problem solved.
I copied xsl and xsd files to a directory with old Reunion Mission Director, and they work. Still not sure what was wrong though.
Also, the X3 editor changes file extensions to wrong.

User avatar
LV
Sith Lord
Posts: 8255
Joined: Wed, 6. Nov 02, 20:31
x3tc

Post by LV » Wed, 3. Mar 10, 21:15

as i'm not a trade geek

Code: Select all

030   |$buyer =  find station: resource $ware with best price: min.price=$average, amount=$anul, max.jumps=100, startsector=$sec, trader=$tug, exclude array=[TRUE]
how the hell do I return an array of stations buying my defined ware at average price, I only ever get 1 returned

i tried exclude array=[FALSE] before someone says try that ;)
LV's TC Scripts
Readme's For All My Scripts


I felt a great disturbance in the forum, Like millions of voices cried out in terror, then were silenced

si tacuisses, philosophus mansisses

User avatar
ScRaT_GER
Posts: 1962
Joined: Tue, 8. Jan 08, 18:19
x3tc

Post by ScRaT_GER » Wed, 3. Mar 10, 22:37

This command only returns one station.
The "exclude array" argument can be used to supply stations, which shouldn't be considered during the search.

For multiple stations you'd have to use the "Universe and Sector Commands".

Greetings,
ScRaT

Logain Abler
Posts: 2255
Joined: Mon, 31. Oct 05, 08:44
x4

Ship class from ware type

Post by Logain Abler » Tue, 9. Mar 10, 23:17

Is it possible to get a ship class from it's ware type code?

I have an array which stores a ships details and resource required to build it, to get the values I used

$type = $ship->get ware type code of object
$rel.Val = get relvalue of $type

This is all fine and I can create a ship from the values stored, however if I try and pull class type from the ware code for information purposes it shows null. I take as it's not been created as an object $ship.class = $type->get object class won't work.

So my question is, can you pull a ship class from a ship ware type? If so how?

Thanks

LA

User avatar
ScRaT_GER
Posts: 1962
Joined: Tue, 8. Jan 08, 18:19
x3tc

Post by ScRaT_GER » Tue, 9. Mar 10, 23:30

I guess you'll first have to reate a dummy ship using the ware type code and then get the class of that dummy.

Greeting,
ScRaT

Logain Abler
Posts: 2255
Joined: Mon, 31. Oct 05, 08:44
x4

Post by Logain Abler » Tue, 9. Mar 10, 23:33

ScRaT_GER wrote:I guess you'll first have to reate a dummy ship using the ware type code and then get the class of that dummy.

Greeting,
ScRaT
Thanks, thats my plan B (dirty but works) if there's not a plan A (cleam and simple) way of doing it :)

LA

jlehtone
Posts: 21878
Joined: Sat, 23. Apr 05, 21:42
x4

Post by jlehtone » Thu, 11. Mar 10, 17:27

This thread is getting long. The discussion should continue here.

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