[Discussion] Generic X3TC S&M questions II
Moderators: Scripting / Modding Moderators, Moderators for English X Forum
-
- Posts: 63
- Joined: Fri, 13. Jan 06, 03:12
-
- Posts: 851
- Joined: Fri, 13. Jun 08, 13:14
you won't.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
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
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
-
- Posts: 63
- Joined: Fri, 13. Jan 06, 03:12
*--------------------*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.
-
- Posts: 851
- Joined: Fri, 13. Jun 08, 13:14
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:
if test1 success:
I will try it later when I can...
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
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
-
- Posts: 851
- Joined: Fri, 13. Jun 08, 13:14
-
- Posts: 2033
- Joined: Wed, 29. Jun 05, 01:45
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)
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)
-
- Posts: 851
- Joined: Fri, 13. Jun 08, 13:14
look at !ship.cmd.missile.attack.std.pcks9ilent 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)
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?
-
- Posts: 2033
- Joined: Wed, 29. Jun 05, 01:45


(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)
-
- Posts: 2035
- Joined: Wed, 18. Aug 10, 14:28
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...
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
Sir Ken Robinson
-
- Posts: 63
- Joined: Fri, 13. Jan 06, 03:12
-
- Moderator (Script&Mod)
- Posts: 22438
- Joined: Sun, 14. Nov 04, 23:26
that should create a pirate ship, what happens when you try it ?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
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
-
- Posts: 63
- Joined: Fri, 13. Jan 06, 03:12
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
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?
I am trying to calculate a defensive value of a specific sector and I ve tryed many commands but they always return zero

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?
-
- Posts: 851
- Joined: Fri, 13. Jun 08, 13:14
@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.
hth
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
-
- Posts: 458
- Joined: Sun, 4. Jan 09, 17:17
-
- Posts: 1135
- Joined: Sun, 19. Oct 08, 18:46
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.
Black holes are where God divided by zero.
-
- Posts: 1962
- Joined: Tue, 8. Jan 08, 18:19
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
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
-
- Posts: 1135
- Joined: Sun, 19. Oct 08, 18:46
-
- Posts: 2033
- Joined: Wed, 29. Jun 05, 01:45
-
- Posts: 458
- Joined: Sun, 4. Jan 09, 17:17