[HELP REQ]Creating a script for Xtended allowing ships to be build on mobile shipyard

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

Anubitus
Posts: 693
Joined: Fri, 21. Jan 05, 00:44
x4

[HELP REQ]Creating a script for Xtended allowing ships to be build on mobile shipyard

Post by Anubitus » Mon, 21. Jan 13, 00:15

hi,

im trying to create/addapt a script to allow ships to be build on a mobile shipyard.

im trying to use the Xtended scripts as a template, but i have no idea how to aproach this..

so i had a few ideas of wich i dont know if they will work but i hope somebody can help me with this..

There are a few scripts in Xtended of wich i suspect they got something to do with what im trying to achieve..

- plugin.XTC.ALM.POSY.xml
- plugin.XTC.Lib.CalcShipProdVals.xml
- plugin.XTC.Plot.SY.2.7.xml
- plugin.XTC.POSY.Choose.Upgrades.xml
- plugin.XTC.POSY.Equip.ship.xml
- plugin.XTC.POSY.ShowLicenses.xml
- plugin.XTC.POSY.SYBuilt.xml

im not sure if there are more involved with the mobile shipyard production.. if there are, pls let me know..

so, to start with the beginning i start with plugin.XTC.ALM.POSY.xml

Code: Select all

* X-Tended - Terran Conflict

$Page.ID = get global variable: name='XTC.PAGE.FRAMEWORK'


if $state == 'init'

* Shipyards
$docks = get station array: of race [Player] class/type=[Dock]
for each $SY in array $docks
= $null-> call script 'plugin.XTC.POSY.SYBuilt' : SY=$SY
end


else if $state == 'stop'
$shipyards = array alloc: size=0
set global variable: name='XTC.POSY.SYs' value=$shipyards

else if $state == 'repeat'



* Arans

$SYs = get ship array: of race [Player] class/type={Goner Aran (SH_G_MSY)}
$size.SYs = size of array $SYs
$production.lines = array alloc: size=1
while $size.SYs
dec $size.SYs
$SY = $SYs[$size.SYs]
= $null-> call script 'plugin.XTC.POSY.SYBuilt' : SY=$SY
end



* check SY removed?

$shipyards = get global variable: name='XTC.POSY.SYs'

for each $SY in array $shipyards
skip if $SY-> exists
= $null-> call script 'plugin.XTC.POSY.SYKilled' : argument1=$SY
end

* $shipyards = sort array $shipyards
* $shipyards = reverse array $shipyards
* set global variable: name='XTC.POSY.SYs' value=$shipyards
end

return null

return null

now to have this script work with another ship, would it be sufficient to copy this script, rename it and just change the "Arans" and "{Goner Aran (SH_G_MSY)}" to the ones from the ship i want to add..?

or

will it work if i just copy/past this section

Code: Select all

* Arans

$SYs = get ship array: of race [Player] class/type={Goner Aran (SH_G_MSY)}
$size.SYs = size of array $SYs
$production.lines = array alloc: size=1
while $size.SYs
dec $size.SYs
$SY = $SYs[$size.SYs]
= $null-> call script 'plugin.XTC.POSY.SYBuilt' : SY=$SY
end
below the Aran one and make it look something like this

Code: Select all

* Arans

$SYs = get ship array: of race [Player] class/type={Goner Aran (SH_G_MSY)}
$size.SYs = size of array $SYs
$production.lines = array alloc: size=1
while $size.SYs
dec $size.SYs
$SY = $SYs[$size.SYs]
= $null-> call script 'plugin.XTC.POSY.SYBuilt' : SY=$SY
end



* MyShip

$SYs = get ship array: of race [Player] class/type={Argon MyShip (SH_A_MyShip)}
$size.SYs = size of array $SYs
$production.lines = array alloc: size=1
while $size.SYs
dec $size.SYs
$SY = $SYs[$size.SYs]
= $null-> call script 'plugin.XTC.POSY.SYBuilt' : SY=$SY
end
would this work..?

another idea wich will probbably not work is the abillity to just put MyShip behind "{Goner Aran (SH_G_MSY)}" with a "," in between or something..?

it would look something like this

Code: Select all

$SYs = get ship array: of race [Player] class/type={Goner Aran (SH_G_MSY)},{Argon MyShip (SH_A_MyShip)}
scripting is damn hard.. :o
Last edited by Anubitus on Mon, 21. Jan 13, 08:33, edited 2 times in total.

User avatar
RoverTX
Posts: 1436
Joined: Wed, 16. Nov 11, 18:37
x4

Post by RoverTX » Mon, 21. Jan 13, 02:18

XTC makes a lot of changes to the game. So those scripts are most likely set up in a way that may not work in the base game.

Basically those scripts base assumptions, or if you would requirements, are surely different then they would need to be in a vanillia game.

It would be hard to do even if you had more programatic experience. Your best bet would be to start small and try to build your own piece by piece. Other wise your just going to get lost trying to bring those scripts in line with the vanilla game.

In short even if you had '1337 hackzor skills' I would still suggest just starting fresh.

Anubitus
Posts: 693
Joined: Fri, 21. Jan 05, 00:44
x4

Post by Anubitus » Mon, 21. Jan 13, 08:27

its not ment for a base game, its for use with Xtended.. :)
Last edited by Anubitus on Mon, 21. Jan 13, 19:25, edited 1 time in total.

Larxyz
Posts: 262
Joined: Tue, 16. Nov 04, 08:46
x3tc

Post by Larxyz » Mon, 21. Jan 13, 08:28

one way would be to look at the script that the player headquarters uses?
since it already makes ships...
just a thought

Anubitus
Posts: 693
Joined: Fri, 21. Jan 05, 00:44
x4

Post by Anubitus » Mon, 21. Jan 13, 08:32

i could try that, but its a station, the Aran is a ship that makes ships.. wich is what i want to create.. besides, im not sure if the player HQ is even in Xtended nor that its scripts will work.. so i was thinking i'd use a Xtended script for this..? seemed logical..

Anubitus
Posts: 693
Joined: Fri, 21. Jan 05, 00:44
x4

Post by Anubitus » Fri, 25. Jan 13, 02:34

doesnt realy anyone know how to do this..?

i have tried so many differnt things already now, im losing faith.. *sigh*
i tried to copy/past the XTC script and rename it and then go inside the game and adapt it with the ingame script editor but the pasted script isnt even listed in the list of scripts..? why is this..? what am i missing here..

please help..

User avatar
mr.bear
Posts: 444
Joined: Sat, 11. Dec 10, 01:38
x2

Post by mr.bear » Fri, 25. Jan 13, 03:30

i think if you've just copy/pasted the script .xml file then it will have the same 'script name' and is probably ignored by the game. try changing the script-name using exscriptor or xstudio.

mr.bear
Rapunzel, Rapunzel, let down your bear...

Anubitus
Posts: 693
Joined: Fri, 21. Jan 05, 00:44
x4

Post by Anubitus » Fri, 25. Jan 13, 04:07

what do you mean with "script name"..? i did rename the script file in the scripts folder of the game.. but something tells me thats not what you ment.. i have no idea what im doing tbh.. i ve never scripted before.. :oops:

User avatar
mr.bear
Posts: 444
Joined: Sat, 11. Dec 10, 01:38
x2

Post by mr.bear » Fri, 25. Jan 13, 12:32

:o !!

dude, the script-name is like the filename of a script, but used inside the game. you can change it from the 'properties' window of X-studio.

[ external image ]

try reading the MSCI handbook to understand the basics of scripting first. also try writing some small test scripts -- walk before you run...

mr.bear[/img]
Last edited by mr.bear on Fri, 25. Jan 13, 15:22, edited 1 time in total.
Rapunzel, Rapunzel, let down your bear...

User avatar
X2-Illuminatus
Moderator (Deutsch)
Moderator (Deutsch)
Posts: 24961
Joined: Sun, 2. Apr 06, 16:38
x4

Post by X2-Illuminatus » Fri, 25. Jan 13, 13:33

Anubitus wrote:what do you mean with "script name"..? i did rename the script file in the scripts folder of the game.. but something tells me thats not what you ment.. i have no idea what im doing tbh.. i ve never scripted before..
That's only one part of the work you have to do, when renaming a script.

You also have to change the name twice in the script file itself. If you open the script in a text or xml editor you have to change the name between the name tags in the "header" of the script:

Code: Select all

<name>...</name>
and at the beginning of the codearry:

Code: Select all

<sval type="string" val="..."/>
You can search for the name to find both appearances.

Of course, with the internal and external script editors renaming a script is easier.
Nun verfügbar! X3: Farnham's Legacy - Ein neues Kapitel für einen alten Favoriten

Die komplette X-Roman-Reihe jetzt als Kindle E-Books! (Farnhams Legende, Nopileos, X3: Yoshiko, X3: Hüter der Tore, X3: Wächter der Erde)

Neuauflage der fünf X-Romane als Taschenbuch

The official X-novels Farnham's Legend, Nopileos, X3: Yoshiko as Kindle e-books!

The_Mess
Posts: 235
Joined: Thu, 1. Jan 04, 03:10
x3tc

Post by The_Mess » Fri, 25. Jan 13, 14:17

One thing - X-tended for X3:Reunion had a fully working Aarn mobile ship yard, so grab that and and have a look at how it's set up in there. You might even be able to adapt it to work with X-tended TC, once you understand how it works that is ;)

Anubitus
Posts: 693
Joined: Fri, 21. Jan 05, 00:44
x4

Post by Anubitus » Fri, 25. Jan 13, 17:54

k guys.. thanks.. ill go try some stuff now.. :)

Anubitus
Posts: 693
Joined: Fri, 21. Jan 05, 00:44
x4

Post by Anubitus » Sat, 23. Mar 13, 14:47

i cant get this to work.. cant make heads nor tails from the scripting language.. *sigh*

User avatar
DrBullwinkle
Posts: 5715
Joined: Sat, 17. Dec 11, 01:44
x3tc

Post by DrBullwinkle » Sat, 23. Mar 13, 22:41

The MSCI Programmer's Handbook is the best starting point for scripting. It answers the basic questions you asked, as well as many other topics that you need to know. It is very easy to read -- it is one of the best technical manuals I have ever seen.

As for how to approach a scripting job, it is usually easier to write your own from scratch than it is to read someone else's work. Perhaps read the existing scripts for ideas, but write your own.

Also, as suggested, start small. Do one thing; then get it to work. Then add another thing. Continue. It is important to get small pieces working before proceeding to the next piece because you will quickly get lost if you do not.

Anubitus
Posts: 693
Joined: Fri, 21. Jan 05, 00:44
x4

Post by Anubitus » Sun, 24. Mar 13, 11:51

hmm.. thx for the info.. havent realy tried to actually script myself.. well, i tried but never continued after it began to become complicated.. i will give this a shot (or two)..

User avatar
Trickmov
Posts: 1431
Joined: Wed, 7. Nov 07, 19:48
x3tc

Re: [HELP REQ]Creating a script for Xtended allowing ships to be build on mobile shipyard

Post by Trickmov » Mon, 25. Mar 13, 09:10

Anubitus wrote:

Code: Select all

* Arans

$SYs = get ship array: of race [Player] class/type={Goner Aran (SH_G_MSY)}
$size.SYs = size of array $SYs
$production.lines = array alloc: size=1
while $size.SYs
dec $size.SYs
$SY = $SYs[$size.SYs]
= $null-> call script 'plugin.XTC.POSY.SYBuilt' : SY=$SY
end



* MyShip

$SYs = get ship array: of race [Player] class/type={Argon MyShip (SH_A_MyShip)}
$size.SYs = size of array $SYs
$production.lines = array alloc: size=1
while $size.SYs
dec $size.SYs
$SY = $SYs[$size.SYs]
= $null-> call script 'plugin.XTC.POSY.SYBuilt' : SY=$SY
end
would this work..?
This one should work - though you also will have to change:

plugin.XTC.POSY.SYBuilt in line 26 (adding your ship to the array), too.

plugin.XTC.POSY.ShowLicenses line 76 onwards (this is for the possible licenses shown in your ship)

plugin.XTC.POSY.ChooseUpgrades line 287 and following (iirc this is for upgrades in some way)

plugin.XTC.POSY.Equip.ship line 194 onwards


Then it should work - though no guarantee... it's a too long time since I scripted this ;)

Larxyz
Posts: 262
Joined: Tue, 16. Nov 04, 08:46
x3tc

Post by Larxyz » Fri, 29. Mar 13, 07:24

just wanted to ask how it goes with this little project?=)

Anubitus
Posts: 693
Joined: Fri, 21. Jan 05, 00:44
x4

Post by Anubitus » Thu, 25. Apr 13, 11:42

after a small break i started on this again..

after looking at some scripts i came up with a new idea, wich may or may not work..

script: plugin.XTC.ALM.POSY.xml

if i change this:

Code: Select all

* X-Tended - Terran Conflict

$Page.ID = get global variable: name='XTC.PAGE.FRAMEWORK'


if $state == 'init'

* Shipyards
$docks = get station array: of race [Player] class/type=[Dock]
for each $SY in array $docks
= $null-> call script 'plugin.XTC.POSY.SYBuilt' : SY=$SY
end


else if $state == 'stop'
$shipyards = array alloc: size=0
set global variable: name='XTC.POSY.SYs' value=$shipyards

else if $state == 'repeat'



* Arans

$SYs = get ship array: of race [Player] class/type={Goner Aran (SH_G_MSY)}
$size.SYs = size of array $SYs
$production.lines = array alloc: size=1
while $size.SYs
dec $size.SYs
$SY = $SYs[$size.SYs]
= $null-> call script 'plugin.XTC.POSY.SYBuilt' : SY=$SY
end



* check SY removed?

$shipyards = get global variable: name='XTC.POSY.SYs'

for each $SY in array $shipyards
skip if $SY-> exists
= $null-> call script 'plugin.XTC.POSY.SYKilled' : station=$SY
end

* $shipyards = sort array $shipyards
* $shipyards = reverse array $shipyards
* set global variable: name='XTC.POSY.SYs' value=$shipyards
end

return null

return null
to this:

Code: Select all

* X-Tended - Terran Conflict

$Page.ID = get global variable: name='XTC.PAGE.FRAMEWORK'
$MobShipyard = create new array, arguments={Goner Aran (SH_G_MSY)}, {Boron Giantsquid}, null, null, null

if $state == 'init'

* Shipyards
$docks = get station array: of race [Player] class/type=[Dock]
for each $SY in array $docks
= $null-> call script 'plugin.XTC.POSY.SYBuilt' : SY=$SY
end


else if $state == 'stop'
$shipyards = array alloc: size=0
set global variable: name='XTC.POSY.SYs' value=$shipyards

else if $state == 'repeat'



* MobShipyards

$SYs = get ship array: of race [Player] class/type=$MobShipyard 
$size.SYs = size of array $SYs
$production.lines = array alloc: size=1
while $size.SYs
dec $size.SYs
$SY = $SYs[$size.SYs]
= $null-> call script 'plugin.XTC.POSY.SYBuilt' : SY=$SY
end



* check SY removed?

$shipyards = get global variable: name='XTC.POSY.SYs'

for each $SY in array $shipyards
skip if $SY-> exists
= $null-> call script 'plugin.XTC.POSY.SYKilled' : station=$SY
end

* $shipyards = sort array $shipyards
* $shipyards = reverse array $shipyards
* set global variable: name='XTC.POSY.SYs' value=$shipyards
end

return null

return null
notice at the top part the

"$MobShipyard = create new array, arguments={Goner Aran (SH_G_MSY)}, {Boron Giantsquid}, null, null, null"

line and the fact that i changed

"$SYs = get ship array: of race [Player] class/type={Goner Aran (SH_G_MSY)}"

to

"$SYs = get ship array: of race [Player] class/type=$MobShipyard ".


will this work..?

Anubitus
Posts: 693
Joined: Fri, 21. Jan 05, 00:44
x4

Post by Anubitus » Thu, 25. Apr 13, 12:17

or perhaps im aproaching this the wrong way.. the Aran cant build any ships in XTC either if im not mistaking..

would it be possible to add the mobile shipyards to the player owned shipyards menu from XTC..?

User avatar
Trickmov
Posts: 1431
Joined: Wed, 7. Nov 07, 19:48
x3tc

Post by Trickmov » Thu, 25. Apr 13, 12:58

Anubitus wrote:or perhaps im aproaching this the wrong way.. the Aran cant build any ships in XTC either if im not mistaking..

would it be possible to add the mobile shipyards to the player owned shipyards menu from XTC..?
The Aran can build ships in XTC.
Your latest code won't work, because afaik the there mustn't be an array in the class/type-argument.

The fist idea you wrote down, should work, if you change the other scripts accordingly. You will find everything necessary to change in my post at the top of this page.

Post Reply

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