[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

FriedTrix
Posts: 63
Joined: Fri, 13. Jan 06, 03:12
x4

Post by FriedTrix »

Where can we find documentation about the script commands and their respective parameters?

For example

START $ship->command {COMMAND_JUMP_POSITION}: arg1= xxx arg2= xxx ...


where do I find what the arguments are and which are optionnal?

thank you
Coruskane
Posts: 851
Joined: Fri, 13. Jun 08, 13:14
x4

Post by Coruskane »

FriedTrix wrote:Where can we find documentation about the script commands and their respective parameters?

For example

START $ship->command {COMMAND_JUMP_POSITION}: arg1= xxx arg2= xxx ...


where do I find what the arguments are and which are optionnal?

thank you
you won't.

Open up the respective script and see what happens to your args.

Most scripts will use descriptions for the args but some don't.

edit: ah I was confused by the fact that the args in your chose function above actually are dependent on the script called, but if by script command you mean the MSCI functions then you can find a reference in the MSCI manual and Mark Condrens reference for newer commands for TC v2.5

____________________________________________________

Question:

1) Is it possible to declare variables dynamically rather than deterministically? I have been unable to find any way of doing so, and unfortunately this means we cannot make some types of proper functions.

2) Is there any way to name a global variable from a variable? (related to my previous question)

Code: Select all

$dummy = array alloc: size=1
$dummy[0] = 'Whoopsie Daisies'
$y = 'Blah' 
$z = 'Blah' 
$x = $y & $z 
set global variable: name=$x value=$dummy
return null

The above code will corrupt the global variables registry and wipe them all. (according to Propmongler). Presumably because $x is actually just a reference.

edit: hmm will passing a referential variable through as a parameter/argument on a call collapse the reference to the target or simply pass the references? If the former then we could use calls as a means of dynamically naming/declaring variables
FriedTrix
Posts: 63
Joined: Fri, 13. Jan 06, 03:12
x4

Post by FriedTrix »

Coruskane wrote:1) Is it possible to declare variables dynamically rather than deterministically? I have been unable to find any way of doing so, and unfortunately this means we cannot make some types of proper functions.

2) Is there any way to name a global variable from a variable? (related to my previous question)
*--------------------*
$wreck = create special: type=87 addto=$sector x=$posX y=$posY z=$posZ
$sectorName = $sector->get name
$textGVarSectorName = 'FTrix.' + $sectorName
set global variable: name=$textGVarSectorName value=$wreck
*--------------------*

if I m not mistaken.. that s what I do there.
Coruskane
Posts: 851
Joined: Fri, 13. Jun 08, 13:14
x4

Post by Coruskane »

Assuming you have tried what you posted and it worked then my thoughts are as follows:

that is nearly equivalent to the code snippet posted above, the only functional difference I can see is that $textGVarSectorName contains a string as well as a reference whereas $x from my example just has 2 references (also the datatype of the assigned 'value='but I doubt that is the issue)

So, my new conjecture is that the problem comes from not forcing the name variable to collapse down (in your example it does collapse caused by having a string) before passing it into set global function. I think it may thus be passed through as datatype var and not datatype string)

test1 for string part:

Code: Select all

$dummy = array alloc: size=1
$dummy[0] = 'Whoopsie Daisies'
$y = 'Blah'
$z = 'Blah'
$x = $y & '.' & $z
set global variable: name=$x value=$dummy
return null 
if test1 success:

Code: Select all

$dummy = array alloc: size=1
$dummy[0] = 'Whoopsie Daisies'
$y = 'Blah'
$z = 'Blah'
$x = 'a' & $y & $z
$x = get substring of $x offset=1 length=null
set global variable: name=$x value=$dummy
return null 
I will try it later when I can...
User avatar
ScRaT_GER
Posts: 1962
Joined: Tue, 8. Jan 08, 18:19
x3tc

Post by ScRaT_GER »

$x = $y & '.' & $z
I don't think that you can concentate strings like that. Use the + operator instead.
Otherwise your code looks correct.

& is the bitwise AND operator.

Greetings,
ScRaT
Coruskane
Posts: 851
Joined: Fri, 13. Jun 08, 13:14
x4

Post by Coruskane »

oh wow...lol!!!!!!!

That would explain many things :D.....no wonder it was corrupting global variables and so on :lol:


..........................I feel like an idiot ^^

thanks for correcting me!!
User avatar
s9ilent
Posts: 2033
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent »

Idea
Missile tubes (the key word, is tubeSSS plural)

A small script that changes the way missiles are fired. Instead of fire one, reloading, fire one reload. The idea is you have some n number of tubes, and you fire any 1-n of those.
(Via set missile time difference to 0, and use some internal count to store how many tubes, how long until reloaded etc.)

(I'm not in a position to make this script atm, - to busy with other misc junk so I thought I would post the idea here in case someone else wanted to)
Coruskane
Posts: 851
Joined: Fri, 13. Jun 08, 13:14
x4

Post by Coruskane »

s9ilent wrote:Idea
Missile tubes (the key word, is tubeSSS plural)

A small script that changes the way missiles are fired. Instead of fire one, reloading, fire one reload. The idea is you have some n number of tubes, and you fire any 1-n of those.
(Via set missile time difference to 0, and use some internal count to store how many tubes, how long until reloaded etc.)

(I'm not in a position to make this script atm, - to busy with other misc junk so I thought I would post the idea here in case someone else wanted to)
look at !ship.cmd.missile.attack.std.pck

Currently that uses n=8 as a constant but you could change it to a variable in about 2 lines...

How do you want the launch to be initiated? Through barrage or overriding the manual missile hotkey?
User avatar
s9ilent
Posts: 2033
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent »

:O hax hax hax! I'd never noticed this one before (but then again, I'm not really a M7M kinda guy, to stingy to use missiles :P)
(I'm calling hax as there does not appear to be anything stopping you from firing that script 100x in a row)

I had planed this more for the player (as I had assumed integration into npc's would require replacing too many stock scripts)to replace the keyboard M (or mouse/joystick) command


Thou my idea for the script was some what ... different, than the ship.cmd.missile.attack.std.pck one.
One of the key things I wanted was that tube reload times should be independent. (i.e. If I fire tube one, it reloads by it self, and doesn't matter if tube 2 is loading/full)

(Also my idea was not for turret-missile launchers, but like a Nova having 2x launchers, or a m8 having 4x etc. )

Also, I wanted 1 missile each time you pressed fire (but the difference being that you could press it e.g. 4x on an m8, then run away and reload, rinse and repeat)
User avatar
TrixX
Posts: 2035
Joined: Wed, 18. Aug 10, 14:28
x4

Post by TrixX »

Really like the idea of Missile hardpoints working like laser hardpoints.

Makes more sense too than just having invisible firing dummies for missiles. Perhaps making them work like lasers would be good for immersion...
"If you’re not prepared to be wrong, you’ll never come up with anything original."
Sir Ken Robinson
FriedTrix
Posts: 63
Joined: Fri, 13. Jan 06, 03:12
x4

Post by FriedTrix »

It look like I can t create pirate ships...

anyone had/have the same problem as I do?

Any way of correcting this?

Used simple command to do this so...

= create ship: type={Pirates Brigantine} owner={Pirates} addto={Danna's Chance} x=0 y=15000 z=0

(Running 2.71)


* got the answer to that :P
Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22438
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow »

FriedTrix wrote:It look like I can t create pirate ships...

anyone had/have the same problem as I do?

Any way of correcting this?

Used simple command to do this so...

= create ship: type={Pirates Brigantine} owner={Pirates} addto={Danna's Chance} x=0 y=15000 z=0

(Running 2.71)


* got the answer to that :P
that should create a pirate ship, what happens when you try it ?

at a guess im gonna assume that it creates a ship but it the wrong race ?
if so, u need to disable the pirate cover state on the creted ship
FriedTrix
Posts: 63
Joined: Fri, 13. Jan 06, 03:12
x4

Post by FriedTrix »

is there a simple way to get the array of ships in a specific sector, owned by a specific race and which homebase is a specific station

I am trying to calculate a defensive value of a specific sector and I ve tryed many commands but they always return zero :O
the only command to get a ship array that worked so far return all ships in the sector mentionned...

so
-I get the whole ship in a sector,
-I ll check the entire array for ship of the selected race AND homebase relative to a specific station

then I do the work of calculating the value.

running all the array when half is garbage is probly very uneffective...

anyone can help me on that?
Coruskane
Posts: 851
Joined: Fri, 13. Jun 08, 13:14
x4

Post by Coruskane »

@FriedTrix:

so you are looking for ships that satsify two criteria:

1) homebased to station X
2) in sector Y

?

(race will follow from race of homebase.)

If so use "get owned ships" and then test the members of that array for sector. That is more efficient than doing it the other way round.

As a general guide, when filtering down etc, it is best to start with the most restricting criterion; in this case this is homebase.

edit:

e.g.

Code: Select all

* $station = blah your station etc...........
$station.sector = $station -> get sector
* or if you want a different sector to the station sector then just declare it instead of $station.sector
$station.ships = array alloc: size=0
$station.ships = $station -> get owned ships: class/type={Moveable Ship 2134}
$station.ships.sector = array alloc: size=0
$i = size of array $station.ships
while $i >= 1
  dec $i=
  $x = $station.ships[$i]
  $y = $x -> get sector
  skip if not $y == $station.sector
    append $x to array $station.ships.sector
end
hth
rusky
Posts: 458
Joined: Sun, 4. Jan 09, 17:17
x4

Post by rusky »

Is there any way to make a bullet thicker ? For example, I want to make the Fusion Beam Cannon a lot bigger (hitbox and actual gfx).

I already tried changing the Rapid Box values in TBullets but that didn't seem to do anything.
ThisIsHarsh
Posts: 1135
Joined: Sun, 19. Oct 08, 18:46
x3tc

Post by ThisIsHarsh »

Anyone have any experience with CTD when adding a menu info line to a command preload menu? Had a couple of people reporting this for one of my scripts now, so I'm wondering what could cause it? Maybe special characters or something weird like that?
There are 10 types of people in the S&M forums - those who understand binary, and those who don't.

Black holes are where God divided by zero.
User avatar
ScRaT_GER
Posts: 1962
Joined: Tue, 8. Jan 08, 18:19
x3tc

Post by ScRaT_GER »

No, never experienced such a thing. The menu engine is quite flexible, when it is given "wrong" arrays (i.e. objects instead of strings) - it simply doesn't print them.

A common source of CTD is the command "convert number $num to string". If $num is not of datatype DATATYP_INTEGER the game will crash. This can happen quite quickly, when you do something like this:

* $someVariable is a variable, which can be null (!)
$num = 12 + $someVariable

If $someVariable is null, $num will be something "12null" and cannot be converted to a number.

So maybe you could check if you use this command somewhere.

Greetings,
ScRaT
ThisIsHarsh
Posts: 1135
Joined: Sun, 19. Oct 08, 18:46
x3tc

Post by ThisIsHarsh »

Ah, hmm, not sure if I do use that command, but I'll check it out, cheers for the pointer.
There are 10 types of people in the S&M forums - those who understand binary, and those who don't.

Black holes are where God divided by zero.
User avatar
s9ilent
Posts: 2033
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent »

@rusk are you sure changing the rapid box does not do anything?
From my testing it did seem to have an affect?
What did you change it from and to
rusky
Posts: 458
Joined: Sun, 4. Jan 09, 17:17
x4

Post by rusky »

Changed it from 1 to 10 and couldn't notice any difference.
From what i understand, i need to edit the bod model the beam uses in order to make it bigger.

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