Scripting Tutorials

The place to discuss scripting and game modifications for X²: The Threat.

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

User avatar
Reven
Posts: 1120
Joined: Thu, 10. Jul 03, 07:42
xr

Scripting Tutorials

Post by Reven » Sun, 1. Feb 04, 11:53

Most of the material in the below tutorials is now in the MSCI Programmer's Handbook. Tutorial 2 is the only one with any material not in the book. The tutorials may still be useful, however, as they contain more in-depth examples than the book has.
  • Tutorial 1: New X² Commands - Connect a script to X²'s Menu
    How to link a script into the normal Nav, Trade, Combat, etc. menuing system in X².
    Example script: "Trade->Maintain product quantities..." command. A command to cause a ship to attempt to maintain a constant quantity of products in stock in its home factory.
  • Tutorial 2: Adding new command extension wares to X²
    How to create new wares, how to distribute them among stations, and how to integrate new commands with new wares.
    Example script: Create the ware "Hire Gunnery Crew" which will activate the turret command "Man turrets with gun crews". This ware will be used with a script developed in Tutorial 4.
  • Tutorial 3: Creationism Revisited: How to change the X Universe
    How to create planets, nebulas, gates, asteroids, factories, and ships.
    Example script: Create random asteroids coming from the planet Shipfall (the planet that is breaking up in Power Circle) and move them out and through the trading grid area.
  • Tutorial 4: Flight mechanics and combat: Custom combat scripts and more.
    The actual tutorial was never written - instead, get the MSCI Programmer's Handbook from the downloads section.

    Example script: Hired Gunnery Crews - an advanced turret AI. This script will change weapons to suit the target and conditions. IE: Use PSGs (if able to) if no friendlies are around, use mass drivers against incoming missiles, won't target incoming missiles if shields are above a certain percent and it's a weak missile, etc.
    Note: This evolved into a signed "bonus plugin" script. Download from the X² downloads page.
  • Tutorial 5: Interrupts & Signals
    Superceded by the MSCI Programmer's Handbook
  • Tutorial 6: Process control, init scripts, and other internal workings of the scripting system.
    Superceded by the MSCI Programmer's Handbook
  • X² Math library - fixed point decimal & trig functions
    A scripted X² math library and tutorial on how to use it to duplicate the functionality of floating-point variables. Includes sine and cosine functions.
Last edited by Reven on Mon, 13. Dec 04, 06:08, edited 5 times in total.
You were warned... pirates will be hunted down like vermin.

Ex Turbo Modestum

User avatar
Reven
Posts: 1120
Joined: Thu, 10. Jul 03, 07:42
xr

Post by Reven » Sun, 1. Feb 04, 12:07

Instead of stickying one or more of the tutorials, perhaps this post could be stickied instead. I'll update it as further ones are completed.
You were warned... pirates will be hunted down like vermin.

Ex Turbo Modestum

User avatar
Argonaught.
Posts: 1618
Joined: Wed, 6. Nov 02, 21:31
x3ap

Post by Argonaught. » Sun, 1. Feb 04, 12:59

Yea I vote for stickying this one....soon I shall be able to script a thing into X2.....Don't ask me what thing, as it has no name.
[MOD]X3TC No Fog / [MOD]X3AP No Fog / [MD]X3TC Menagerie Shipyard / [MD]X3AP Menagerie Shipyard
<==<<Argonaught>>==>

XBTF>XT>X2TT>X3R>X3TC>X3AP

I lurk alot for the most part now
:thumb_up:

ZeligtheLiar
Posts: 44
Joined: Sat, 24. Jan 04, 13:21
x3

Post by ZeligtheLiar » Sun, 1. Feb 04, 18:50

I just started playing the game last week, and was so very happy to find the scripting support here. So much excellent work, I just hope I can make some contribution.

First though, I must learn how. Reven, your first 2 tutorials and the extra stuff you've posted about scripting (the Ore Belt Colossus prod, for instance) have helped me a lot.

I can't wait for the next tutorials!

Zelig

User avatar
Reven
Posts: 1120
Joined: Thu, 10. Jul 03, 07:42
xr

Post by Reven » Sun, 1. Feb 04, 20:00

I maybe shouldn't have asked for a sticky for this - it means I actually have to do the rest now. :)

@ZeligtheLiar: Thanks. Glad it's helped. The next one is in progress - I'm hoping it will be ready tonight. Depends on how much time the wife leaves me. :)
You were warned... pirates will be hunted down like vermin.

Ex Turbo Modestum

OnlineKenji
Posts: 153
Joined: Thu, 8. Jan 04, 21:05
x3tc

Post by OnlineKenji » Wed, 4. Feb 04, 03:08

I'm getting into writing some trade scripts that use Jump. Yeah I know its been done already, but I want to use my own scripts. It feels less like cheating if I make it myself :-).

Thanks for the push in the right direction Rev, that helped me get started. I popped open a few of EGO's .pck's and picked up on the scripting. Your tut, taught me how to make it show up in the game, thanks bud

ZeligtheLiar
Posts: 44
Joined: Sat, 24. Jan 04, 13:21
x3

Post by ZeligtheLiar » Sat, 7. Feb 04, 18:30

Hey Reven. I've been looking through a few of the scripts, hoping to teach myself how to write them by working out how to read them first. I actually have a few little things I'd like to write myself once I get "there". Nothin' grandiose, nothin' amazin'. Jus' a few little things I think would make life easier, and I don't mean massive ships with flaming guns. I'll post on that when I'm done, or before then if anyone wants to know...

Anyway, what I wanted to say was that while looking through some of the scripts I think I may have found two typos in the Tutorial 1 script ship.cmd.maintainprod.xml - One is just a spelling error (I think) but the other looks like it would be a script-crashing bug.

Line 018 - The message 'Not enough room onboard to hold and %s' - Should that "and" be "any"?
Line 051 - Variable "$Freespace" at the start of the line... should that be "$Message"?

Thanks again Reven!


The_Rock
Posts: 2549
Joined: Wed, 6. Nov 02, 21:31
x2

Post by The_Rock » Mon, 12. Apr 04, 00:39

Hs anyone seen Raven about? He's still got work to do.. :wink:
"How very touching his meaningless death was. But this fight was never for mortals".

User avatar
red assassin
Posts: 713
Joined: Sun, 15. Feb 04, 16:11
x3

Post by red assassin » Sat, 17. Apr 04, 18:57

He probably ran away to avoid having to do the rest of the tutorials :lol: .
A still more glorious dawn awaits, not a sunrise, but a galaxy rise, a morning filled with 400 billion suns - the rising of the Milky Way

User avatar
Argonaught.
Posts: 1618
Joined: Wed, 6. Nov 02, 21:31
x3ap

Post by Argonaught. » Sat, 17. Apr 04, 20:39

red assassin wrote:He probably ran away to avoid having to do the rest of the tutorials :lol: .
Yes...I think he did considering Egosoft won't do the tutorials or release them...or give us any info on them....bloody shame that.....I used to think they actually cared what the X Gamer thought.
[MOD]X3TC No Fog / [MOD]X3AP No Fog / [MD]X3TC Menagerie Shipyard / [MD]X3AP Menagerie Shipyard
<==<<Argonaught>>==>

XBTF>XT>X2TT>X3R>X3TC>X3AP

I lurk alot for the most part now
:thumb_up:

CBJ
EGOSOFT
EGOSOFT
Posts: 37604
Joined: Tue, 29. Apr 03, 00:56
x4

Post by CBJ » Sat, 29. May 04, 12:12

I've unstickied this in favour of this Scripting / Modding Tutorials and Resources list, which includes a link to this thread as well as a number of other useful ones.

User avatar
Reven
Posts: 1120
Joined: Thu, 10. Jul 03, 07:42
xr

Post by Reven » Sat, 18. Sep 04, 07:18

Updated (at last) with Tutorial 3.

Tutorial 4 will be out in a day or two - this is a for sure, as I just bought a Titan and I really want the updated turret script for myself anyways. :)

After that, I'll reevaluate tutorials 5 and 6 to see if they are still necesary, or if existing documentation covers those topics.
You were warned... pirates will be hunted down like vermin.

Ex Turbo Modestum

The_Rock
Posts: 2549
Joined: Wed, 6. Nov 02, 21:31
x2

Post by The_Rock » Tue, 19. Oct 04, 23:30

:o :o
"How very touching his meaningless death was. But this fight was never for mortals".

User avatar
Reven
Posts: 1120
Joined: Thu, 10. Jul 03, 07:42
xr

Post by Reven » Mon, 13. Dec 04, 06:06

Obviously it was more than a day or two. The X² MSCI Programmer's Handbook combined with the newly signed Gunnery Crews "bonus plugin" finally lay to rest the remainder of my commitment made so long ago in this thread's original post. All the topics covered in the unfinished tutorials are covered in the book. I've edited the original post a little to reflect that.

In the next few days I'll go over the four tutorials and update them a little to make sure they are still accurate.
You were warned... pirates will be hunted down like vermin.

Ex Turbo Modestum

Post Reply

Return to “X²: The Threat - Scripts and Modding”