Index of useful short scripts for scripters (Upd: 31/08/05)
Moderators: Moderators for English X Forum, Scripting / Modding Moderators
-
- Posts: 488
- Joined: Wed, 6. Nov 02, 20:31
Index of useful short scripts for scripters (Upd: 31/08/05)
All scripters inevitably end up writing short routines to do jobs that the otherwise excellent scripting engine is missing. Here i hope to be linking them together in one place to make a library of useful tools so that other scripters can reference them and save time and effort in producing new and exciting end user scripts.
I shall start off with a few of mine, if you have any of your own please bring them to my attention so they can be linked. You don't need to package them with a read.me file provided you state clearly either to me or in your thread their purpose, input variables and output/objective.
cmd.get.flyingware.count.zip - TycHouse
Returns the count in a flying ware container
Input: flying ware object pointer
Output: two element array-> e[0]=new object pointer, e[1]=count
ship.get.warearray.zip - TycHouse
Returns an array of wares on a ship
Input: ship object pointer, all wares or trade wares only
Output: array of wares or null
lib.shipname.to.weaparray.zip - TycHouse
(Updated: 24/4/05 Fixed a small bug with turret numbers on M1 & M2 ships)
Returns an array of possible weapons that will fit into shiptype/turret, Ion D and Mass D are at the end as they're harder to use in scripts.
LIMITATION - No TL's, TP's or TS's (yet !)
Input: shipTypeCode, turretNumber
Output: multi element array of possible weapons
X² Math library - fixed point decimal & trig functions - Reven
A library of maths script to perform maths functions that are otherwise unavailable in the X2 SE
mhordes.getangle.toface.zip - Milling_hordesman
Returns the angles that [This] should attain to 'look at' an object or position
Input: position array (position to look at)
Output: two element array -> e[0]=Alpha Rotation, e[1]=Beta Rotation
Extended Ship Information - Burianek
This is a thread link for a script to rename a ship to display extended information about itself.
There is no seperate download (yet).
RS Tools - Red Spot
RS.Tool.Random.Names
RS.Tool.Pos.Front
RS.Tool.Pos.Behind
RS.Tool.Pos.Sides
RS.Tool.Pos.Target
RS.Tool.Wait.End
Information in this thread on page 2
Products and Resources Per Cycle *Merroc* - OML
Products Per Cycle *Commander Jamieson* - OML
Resources Per Cycle *Commander Jamieson* -OML
Information in this thread on page 2
[added by Burianek 5/18]
Some Miscellaneous Tool Scripts - Burianek
These are some of the scripts I use in my day to day developing / testing. Very basic stuff like add money, create ships, manipulate local variables, reveal all sectors, etc.
If you know of any or need them hosted please let me know
-----------------------
Edit 27 Aug 2011 - Corrected links to my scripts and added Revens excellent maths library
-----------------------
I shall start off with a few of mine, if you have any of your own please bring them to my attention so they can be linked. You don't need to package them with a read.me file provided you state clearly either to me or in your thread their purpose, input variables and output/objective.
cmd.get.flyingware.count.zip - TycHouse
Returns the count in a flying ware container
Input: flying ware object pointer
Output: two element array-> e[0]=new object pointer, e[1]=count
ship.get.warearray.zip - TycHouse
Returns an array of wares on a ship
Input: ship object pointer, all wares or trade wares only
Output: array of wares or null
lib.shipname.to.weaparray.zip - TycHouse
(Updated: 24/4/05 Fixed a small bug with turret numbers on M1 & M2 ships)
Returns an array of possible weapons that will fit into shiptype/turret, Ion D and Mass D are at the end as they're harder to use in scripts.
LIMITATION - No TL's, TP's or TS's (yet !)
Input: shipTypeCode, turretNumber
Output: multi element array of possible weapons
X² Math library - fixed point decimal & trig functions - Reven
A library of maths script to perform maths functions that are otherwise unavailable in the X2 SE
mhordes.getangle.toface.zip - Milling_hordesman
Returns the angles that [This] should attain to 'look at' an object or position
Input: position array (position to look at)
Output: two element array -> e[0]=Alpha Rotation, e[1]=Beta Rotation
Extended Ship Information - Burianek
This is a thread link for a script to rename a ship to display extended information about itself.
There is no seperate download (yet).
RS Tools - Red Spot
RS.Tool.Random.Names
RS.Tool.Pos.Front
RS.Tool.Pos.Behind
RS.Tool.Pos.Sides
RS.Tool.Pos.Target
RS.Tool.Wait.End
Information in this thread on page 2
Products and Resources Per Cycle *Merroc* - OML
Products Per Cycle *Commander Jamieson* - OML
Resources Per Cycle *Commander Jamieson* -OML
Information in this thread on page 2
[added by Burianek 5/18]
Some Miscellaneous Tool Scripts - Burianek
These are some of the scripts I use in my day to day developing / testing. Very basic stuff like add money, create ships, manipulate local variables, reveal all sectors, etc.
If you know of any or need them hosted please let me know
-----------------------
Edit 27 Aug 2011 - Corrected links to my scripts and added Revens excellent maths library
-----------------------
Last edited by TycHouse on Sun, 28. Aug 11, 00:32, edited 8 times in total.
AMD FX-8350 Eight-Core 4.0GHz Processor
ASrock Extreme 3 R2.0 Motherboard
8Gb memory
2 x AMD HD7770 Graphics (Crossfire not enabled)
Windows Vista Ultimate 64bit SP2
ASrock Extreme 3 R2.0 Motherboard
8Gb memory
2 x AMD HD7770 Graphics (Crossfire not enabled)
Windows Vista Ultimate 64bit SP2
-
- Posts: 372
- Joined: Mon, 1. Mar 04, 06:16
here's the only useful one i have right now that otherwise couldn't be made in a few seconds:
Get Angle To Face
input: sector position
output:
[0] = alpha rotation
[1] = beta rotation
that the calling object should face to aim at the input position. gamma rotation is roll, so it shouldn't affect this calculation, but i generally set it to 0.
limitations: it's not horribly accurate, but i'd say within a few degrees at worst.
notes: to improve accuracy (at the slight expense of performance), increase the value of the "$power" variable to any odd number. it is currently 19, and can be found on line 21 of mhordes.tools.cos.inv script.
Get Angle To Face
input: sector position
output:
[0] = alpha rotation
[1] = beta rotation
that the calling object should face to aim at the input position. gamma rotation is roll, so it shouldn't affect this calculation, but i generally set it to 0.
limitations: it's not horribly accurate, but i'd say within a few degrees at worst.
notes: to improve accuracy (at the slight expense of performance), increase the value of the "$power" variable to any odd number. it is currently 19, and can be found on line 21 of mhordes.tools.cos.inv script.
-
- Posts: 488
- Joined: Wed, 6. Nov 02, 20:31
-
- Posts: 1380
- Joined: Mon, 11. Oct 04, 22:47
MH can you use this to say pivot ships in dokcing positions?
My Roid Table: Special Thx to Greyhawk for hosting
http://gr3yh4wk.50megs.com/Files/Table% ... 20v1.2.rar
http://gr3yh4wk.50megs.com/Files/Table% ... 20v1.2.rar
-
- Posts: 372
- Joined: Mon, 1. Mar 04, 06:16
no, you cannot. docking positions are part of the model, and are not controlled via scripting. you can rotate the external docking position in the scene file to make the ship face differrently while docked. i did this to make my fun little khaak commander scripts, which simulate a khaak cluster for the player with an m6 acting as the m3 and 5 docked m5s, so i know it works. i do not know how this affects launch behavior, if at all; my scripts teleported the ships out and in, so i never observed how they naturally launch when the docking body is rotated.
-
- Posts: 1380
- Joined: Mon, 11. Oct 04, 22:47
What would happen if you faces the ship with its nose up?
Or its nose down?
Or its nose down?
My Roid Table: Special Thx to Greyhawk for hosting
http://gr3yh4wk.50megs.com/Files/Table% ... 20v1.2.rar
http://gr3yh4wk.50megs.com/Files/Table% ... 20v1.2.rar
-
- Posts: 1380
- Joined: Mon, 11. Oct 04, 22:47
Well you said you turn teh ships on teh docking point axis so they can fly off easier say for M6's
Could you possibly pivot teh docking points so they have their nose facing down or up?
Id be intrested to see what direction then undock from
Could you possibly pivot teh docking points so they have their nose facing down or up?
Id be intrested to see what direction then undock from
My Roid Table: Special Thx to Greyhawk for hosting
http://gr3yh4wk.50megs.com/Files/Table% ... 20v1.2.rar
http://gr3yh4wk.50megs.com/Files/Table% ... 20v1.2.rar
-
- Posts: 372
- Joined: Mon, 1. Mar 04, 06:16
no, i said that i script the docking/undocking so that the ships don't ever actually "undock", they just get placed into the sector right next to the carrier. thus i've never seen if rotating the docking point will rotate the direction that the ship launches from. i can only tell you that rotating the docking point will rotate the ship's model while it is docked.
-
- Posts: 1380
- Joined: Mon, 11. Oct 04, 22:47
So you can pivot them left and right but not up or down.
Ok all i wanted to know.
(Besides i didnt knwo they were just 'placed' in the sector i thought they actually undocked)
Ok all i wanted to know.
(Besides i didnt knwo they were just 'placed' in the sector i thought they actually undocked)
My Roid Table: Special Thx to Greyhawk for hosting
http://gr3yh4wk.50megs.com/Files/Table% ... 20v1.2.rar
http://gr3yh4wk.50megs.com/Files/Table% ... 20v1.2.rar
-
- Posts: 372
- Joined: Mon, 1. Mar 04, 06:16
wha...?
no, you can point the external docking body (which controls the docked ship) in any direction (rotate on any of the 3 axis: roll, pitch, yaw) and the docked ship will reflect that. so yes, you can pivot them left or right, up or down, or roll them.
i'm also saying that i don't know how that will effect the ship when it launches. it might actually make it undock relative to the external docking body, or it might always be forced to undock relative to the ship's orientation; i haven't tried it, so it could do either. the trial that i did i just placed them into the sector using a script instead of undocking them. i don't know how the game engine would do it if you let them undock normally. for that you will need to ask someone to test it for you.
no, you can point the external docking body (which controls the docked ship) in any direction (rotate on any of the 3 axis: roll, pitch, yaw) and the docked ship will reflect that. so yes, you can pivot them left or right, up or down, or roll them.
i'm also saying that i don't know how that will effect the ship when it launches. it might actually make it undock relative to the external docking body, or it might always be forced to undock relative to the ship's orientation; i haven't tried it, so it could do either. the trial that i did i just placed them into the sector using a script instead of undocking them. i don't know how the game engine would do it if you let them undock normally. for that you will need to ask someone to test it for you.
-
- Posts: 1380
- Joined: Mon, 11. Oct 04, 22:47
milling_hordesman wrote:wha...?
no, you can point the external docking body (which controls the docked ship) in any direction (rotate on any of the 3 axis: roll, pitch, yaw) and the docked ship will reflect that. so yes, you can pivot them left or right, up or down, or roll them.
Gah! you said you could roll them


Now i guess instead of the theory that the fighter would be upside down on the condor you can now roll them so they will be upright?


Or am i just messing this up further?

My Roid Table: Special Thx to Greyhawk for hosting
http://gr3yh4wk.50megs.com/Files/Table% ... 20v1.2.rar
http://gr3yh4wk.50megs.com/Files/Table% ... 20v1.2.rar
-
- Posts: 372
- Joined: Mon, 1. Mar 04, 06:16
there are 3 axis of rotation: roll, pitch, and yaw, which correspond to the three 3ds max rotations y, x, and z, which correspond to the 3 scene file rotations z, x, and y, which correspond to the 3 axis of rotation in the game, gamma, beta, and alpha. you can change any of the 3 rotations on the external docking body in the scene file. this will make it so that the ship docked in that external docking slot looks like it's rotated while it is docked.
i think that the ships will be launched at the rotation they appear to have while docked.
i don't if that will affect the direction that it launches the ship actually moves in when it's launched (you know how a ship is normally given a downwards shove when it's launched from an external port? i don't know if you have an upside-down ship if it will be given an upwards shove instead).
i think that the ships will be launched at the rotation they appear to have while docked.
i don't if that will affect the direction that it launches the ship actually moves in when it's launched (you know how a ship is normally given a downwards shove when it's launched from an external port? i don't know if you have an upside-down ship if it will be given an upwards shove instead).
-
- Posts: 1380
- Joined: Mon, 11. Oct 04, 22:47
We will have to test that out then
Anyone willing to test our theroies out? please

Anyone willing to test our theroies out? please
My Roid Table: Special Thx to Greyhawk for hosting
http://gr3yh4wk.50megs.com/Files/Table% ... 20v1.2.rar
http://gr3yh4wk.50megs.com/Files/Table% ... 20v1.2.rar
-
- Posts: 488
- Joined: Wed, 6. Nov 02, 20:31
A simple 'attack object' would be about four lines of code so it's simply written when it's needed, however if you require more than that you would need to specify what it's functions need to be, then i'm sure either i or some other kind sole could provide one.
TycHouse
TycHouse
AMD FX-8350 Eight-Core 4.0GHz Processor
ASrock Extreme 3 R2.0 Motherboard
8Gb memory
2 x AMD HD7770 Graphics (Crossfire not enabled)
Windows Vista Ultimate 64bit SP2
ASrock Extreme 3 R2.0 Motherboard
8Gb memory
2 x AMD HD7770 Graphics (Crossfire not enabled)
Windows Vista Ultimate 64bit SP2
-
- Posts: 3461
- Joined: Fri, 4. Feb 05, 13:44
EDIT: have some 'easy' tool/template-scripts ..
http://www.geocities.com/g5_11/RS.Tools.zip
-RS.Tool.Random.Names --> returns the pilot-name .. if THIS is not the playership .. but the pilot-name is the same it will set the pilot-name off THIS to the found name .. returning that name or the playersname(in case off THIS being the player)
it gets a name based on the owner off sector THIS is in .. if THIS is not in race-space .. it will use an Argon-name
-RS.Tool.Pos.Front --> returns a pos. in front off THIS at the designated distance .. (not as accurate as the one by Reven .. but still pretty accurate .. and easy to understand .. (pos. is a bit off to the nearest axis))
-RS.Tool.Pos.Behind --> same as above .. only now it returns a pos. behind THIS
-RS.Tool.Pos.Sides --> returns a pos. left of right off THIS at the same Y-value .. (input -> 0 for left/1 for right of THIS .. meaning all even numbers are being set as left .. all uneven as right)
-RS.Tool.Pos.Target --> returns a pos. at x distance from THIS in a almost perfect line between THIS and $Target ..
-RS.Tool.Wait.End --> well just a script with a wait .. the 1st arg. is the size off the wait .. not really off much use .. but still its in there ..
(I use it to let ships 'stay' for x time .. or quit tasks)
G
http://www.geocities.com/g5_11/RS.Tools.zip
-RS.Tool.Random.Names --> returns the pilot-name .. if THIS is not the playership .. but the pilot-name is the same it will set the pilot-name off THIS to the found name .. returning that name or the playersname(in case off THIS being the player)
it gets a name based on the owner off sector THIS is in .. if THIS is not in race-space .. it will use an Argon-name
-RS.Tool.Pos.Front --> returns a pos. in front off THIS at the designated distance .. (not as accurate as the one by Reven .. but still pretty accurate .. and easy to understand .. (pos. is a bit off to the nearest axis))
-RS.Tool.Pos.Behind --> same as above .. only now it returns a pos. behind THIS
-RS.Tool.Pos.Sides --> returns a pos. left of right off THIS at the same Y-value .. (input -> 0 for left/1 for right of THIS .. meaning all even numbers are being set as left .. all uneven as right)
-RS.Tool.Pos.Target --> returns a pos. at x distance from THIS in a almost perfect line between THIS and $Target ..
-RS.Tool.Wait.End --> well just a script with a wait .. the 1st arg. is the size off the wait .. not really off much use .. but still its in there ..
(I use it to let ships 'stay' for x time .. or quit tasks)
G
Last edited by Red Spot on Tue, 21. Jun 05, 20:15, edited 1 time in total.
-
- EGOSOFT
- Posts: 13124
- Joined: Sat, 9. Nov 02, 11:45
http://www.egosoft.com/x2/forum/viewtopic.php?t=85754
My new scripts for trade scripts. It kind of works as a
Var = Products/Resources per cycle, {stationtype}, {Ware}.
Its just a list of all the resources needed or products made per cycle.
My new scripts for trade scripts. It kind of works as a
Var = Products/Resources per cycle, {stationtype}, {Ware}.
Its just a list of all the resources needed or products made per cycle.
Come watch me on Twitch where I occasionally play several of the X games
-
- Posts: 39
- Joined: Thu, 5. Oct 06, 10:32