PDA

View Full Version : New To Modding


AmadanLegre
20.11.2008, 15:01
Hi, i'm kind of an old player of X2. I've played a bit, but I'm in no way an expert. I am, however, a fairly experienced programmer/scripter and i've used multiple languages. So I'm not afraid of trying to script something. Problem is I have no idea where to start. I know that with something like this it can take months to become familiar and years to master, so if I try something, I'd like to start simple. Does anyone have any advice for me? And.. how would I go about making a custom galaxy like the one you're able to select when you start a new game?

Kind of idea I have is just start up in my own ship and carve my own way without the help of that Ban Danna and the other manipulators. Just start fresh as my own pilot, maybe an argon mercenary of some sort or possibly something seedier. I kind of wonder why I don't have that option, that's what bothers me with these forced story-lines where you're given a preset name and plot. In this case, I kind of feel guilty running out on Ban Danna and going it alone - wonder what he'll tell everyone about this jerk that took off with a discoverer and never showed up again.

Graceburn
20.11.2008, 21:51
Custom Start wroks like that i think, welcome to the forums anyway :)

Chris Gi
20.11.2008, 23:27
Yeah, I forgot: a warm welcome from me too.

Like Graceburn said: that's what Custom Galaxies are for. You get a X2 universe without Ban Danna (and without Saya ;( ).

If you want to start scripting, this is a good starting point. Tired of this old Discoverer you get at the beginning? Then write a small script and change the starting place, ship etc. It's very easy if you know how to do it, you only need to know a few script commands and how to name this script.

The best way to learn writing to scripts is to look at the work of others. Get the MSCI Handbook from ES home page, it has some useful information on scripting, and look at other people's scripts.

If you want to change some of the starting conditions, you need to do the following: you need a custom map and a script. Let's assume the map you want to play is called MyMap (MyMap.xml). You need to name the script galaxy.MyMap.initplayership. It's always galaxy.{MapName}.initplayership. There is an example in the scripts folder galaxy.Example.initplayership for the Example map. If you know other programming languages, it's pretty easy to read.

AmadanLegre
22.11.2008, 18:58
Yeah, I forgot: a warm welcome from me too.

Like Graceburn said: that's what Custom Galaxies are for. You get a X2 universe without Ban Danna (and without Saya ;( ).

If you want to start scripting, this is a good starting point. Tired of this old Discoverer you get at the beginning? Then write a small script and change the starting place, ship etc. It's very easy if you know how to do it, you only need to know a few script commands and how to name this script.

The best way to learn writing to scripts is to look at the work of others. Get the MSCI Handbook from ES home page, it has some useful information on scripting, and look at other people's scripts.

If you want to change some of the starting conditions, you need to do the following: you need a custom map and a script. Let's assume the map you want to play is called MyMap (MyMap.xml). You need to name the script galaxy.MyMap.initplayership. It's always galaxy.{MapName}.initplayership. There is an example in the scripts folder galaxy.Example.initplayership for the Example map. If you know other programming languages, it's pretty easy to read.
I've got that far! I also made my first "hello world" script using the MSCI handbook (i'm on page 25 atm).

My question is whether or not I can change the initial settings for the ship when you select "<X2 Universe>" in the "New Game in Custom Universe". I don't see a "galaxy.X2 UNIVERSE.initplayership.xml." And I'm going to need to get a galaxy editor.

Gravemind
22.11.2008, 19:26
I've got that far! I also made my first "hello world" script using the MSCI handbook (i'm on page 25 atm).

My question is whether or not I can change the initial settings for the ship when you select "<X2 Universe>" in the "New Game in Custom Universe". I don't see a "galaxy.X2 UNIVERSE.initplayership.xml." And I'm going to need to get a galaxy editor.

hello,
the original x2 universe is in one of the cats of x2 ;)
you need to extract them with the x² archiver

Chris Gi
23.11.2008, 00:02
My question is whether or not I can change the initial settings for the ship when you select "<X2 Universe>" in the "New Game in Custom Universe". I don't see a "galaxy.X2 UNIVERSE.initplayership.xml."

No. A script named this way can't be made. You have a very limited character set in the internal script editor. Just letters, digits, and '.' and ','. In strings you can use '%', '-' and space too.
If you want to play the original X2 map, you need to extract it like Gravemind said. Then you need to rename it to 'X2Universe.xml' for example and your script to 'galaxy.X2Universe.initplayership'. This is the same as choosing <X2 Universe> in the "New Game in Custom Universe", except you can now change the initial settings.

AmadanLegre
25.11.2008, 08:47
Is there a way to have a script command menu on a station when you dock?

So far I only see the possibility of having a script command menu on one of the ship menues or on a station that you own (through the command console).

What I wanted to do was put the following command on the dock tab when you're docked at a station:
"Browse Recruitment Catalog Level 1..."

This would place it somewhere near the bulletin command menu or the "Comm with person aboard".

It looks like I have to put it on a ship menu though :/

On the bright side, I could probably check to see if they're docked. If they're not, the command wouldn't execute. Is there a way to make the command menu gray out or to disable it visiibly?

Chris Gi
25.11.2008, 11:49
No, you can't add a command to a station you don't own - at least noone figured out how to do this.
Furthermore, ship commands are disabled while docked. Maybe the commands in the additional ship slots are working, I don't know, I haven't tested this.

But you can use a script to disable a command. (I'm not quite sure about the names, I have no X2 here at work):
To use a command, you need to connect a command with a script. This is done by the command 'set ship command upgrade ...'. There is a second version of this command with an additional parameter that takes a script.
This script is used to allow or disallow the use of a command. This is explained in the MSCI Handbook with a very basic example.

AmadanLegre
25.11.2008, 12:22
No, you can't add a command to a station you don't own - at least noone figured out how to do this.
Furthermore, ship commands are disabled while docked. Maybe the commands in the additional ship slots are working, I don't know, I haven't tested this.

But you can use a script to disable a command. (I'm not quite sure about the names, I have no X2 here at work):
To use a command, you need to connect a command with a script. This is done by the command 'set ship command upgrade ...'. There is a second version of this command with an additional parameter that takes a script.
This script is used to allow or disallow the use of a command. This is explained in the MSCI Handbook with a very basic example.
Yep I've confirmed this just past few hours. I'm going to try the "Additional Ship Commands" menu.

I was hoping that the menu items would only come up when you dock. Failing that, I tried to get the menu items to be up at all times, whether you're docked or not. Still looking for an inbetween. I'll find one.

AmadanLegre
25.11.2008, 15:58
A minor update. It does work with "Additional Ship Commands". However, you can't tell that these commands are present without selecting one of two slots in the "Additional Ship Commands" section. Both of the slots say "None" - that's misleading. A new user wouldn't know where the commands are because ther'es nothing to suggest they exist except a possible ware that might be needed to use the commands. I preferred using the custom/sepcial menu, but am prevented from doing so because it won't work when you're docked.

Some questions:

1) Is there a way to edit the "FROM:UNKNOWN" in a scripted incoming message?

2) Also, can anyone point me in the right direction as to how I can add a new ware to all trading stations? I also don't know where to start in creating a new ware, either.

EDIT: Yipee, I figured out how to change the "Message from:" field. Basically, you hadd "name of source".

Also I found out how to change the button text at the end of an incoming transmission. You use button text. It looks like it's using a form to me. Form controls. Problem is that we don't have access to the action/get response code that responds to clicking on the buttons. I've used forms before so it was kind of familiar.

On the bright side, this means that both incoming messages and normal messages can have an extensive amount of formatting, which is kind of kool. I've already used [center], [justify], [right], [b], and so on. You can also color the text and arrange in columns (I think). Only problem is there's no interface except the joy of clicking a button that does nothing. If they could have allowed us to attach a script to the button (Send a Yes!), we could of asked players questions in incoming messages! (that would have been SWEET).

Chris Gi
25.11.2008, 23:46
Nice, you've found out quite a lot :D .

Yeah, too bad this [select script='....'] syntax doesn't work....

However, you can't tell that these commands are present

Use the 'set script command' instruction, giving the command name at the beginning of the script. Set 'set script command: nulll' at the end of the script.

Also, can anyone point me in the right direction as to how I can add a new ware to all trading stations?

011 $x.max = get max sectors in x direction
012 $y.max = get max sectors in y direction
013
014 while [TRUE]
015 $y = 0
016 while $y < $y.max
017 $x = 0
018 while $x < $x.max
019 @ = wait 10 ms
020 if $x != 1 AND $y != 3
021 $Sector = get sector from universe index: x=$x, y=$y
022 if $Sector
023 @ = [THIS] -> call script 'plugin.ck.pandora.gov.sector' : Sector=$Sector
024 end
025 end
026 inc $x =
027 @ = wait randomly from 10 to 30 ms
028 end
029 inc $y =
030 @ = wait randomly from 10 to 30 ms
031 end
032 end


Instead of the script call, use a 'find station'-instruction (from General Object Commands) with class=Trade Dock, race=null ..., and then an 'add product to factory or dock' (from General Object Commands).

I also don't know where to start in creating a new ware, either.

There are only limited possibilities without go into modding. There are several wares that aren't used, but are active. If you browse the ware list, you find several wares with 'ReadText17-Number'. Just use any of these numbers and give it a name. The difficult part is: every ware has a set price that can't be changed (without modding!). 5773 is cheap, 5943 is not (the higher the number, the higher the price).

AmadanLegre
26.11.2008, 10:14
I was kind of hoping that "COMMAND_ACTION" somehow had something to do with ", but I don't think so. It would make some sense I guess, if there was a special script to handle the value, but oh well. Looks like it's hard coded.
Use the 'set script command' instruction, giving the command name at the beginning of the script. Set 'set script command: nulll' at the end of the script.
I'm not sure I understand what you're saying here. What i"m wanting to do is be able to give the pilot some indication that there're commands in the "Additional Ship Commands" section. Rgith now I just see two rows, each lebelled "Slot 1" and "Slot 2", respectively. The rest of the row just says "None". And when you select either slot, they go to the same place.
There are only limited possibilities without go into modding. There are several wares that aren't used, but are active. If you browse the ware list, you find several wares with 'ReadText17-Number'. Just use any of these numbers and give it a name. The difficult part is: every ware has a set price that can't be changed (without modding!). 5773 is cheap, 5943 is not (the higher the number, the higher the price).How exactly would I mod a new ware? Is there a website you can link me to? I can't find anything that explains this in the MSCI handbook.

Chris Gi
26.11.2008, 11:48
I'm not sure I understand what you're saying here.

Oh, it seems I didn't understand your original question. I thought you were referring to the fact that if you use a command in one of the two slots, the command executed is not properly displayed. If you do not use the 'set script command' instruction, the command is not displayed.
Re-reading your original question, I think you refer to the fact that there's no hint that there are additional ship commands that could be executed, right? Well, that can't be helped, that's the way it works: in fact, the info 'None' is absolutely correct - there are no commands in this slot. All you can do is document this in a ReadMe or one a website!

How exactly would I mod a new ware? Is there a website you can link me to? I can't find anything that explains this in the MSCI handbook.

The MSCI handbook is a reference for scripting. Are you sure you want to mod a ware? Most of the time, this isn't really necessary. Those ReadText17 entries are wares not used by the game, but ready to use.
All you have to do is edit a t-file and use the following lines:

<page id="17">
<text id="5773">My New Ware</t>
</page>

Now you have a new ware, ready to use for whatever purpose you want.
The drawback is that you have to go with the values the game provides. All these wares have certain properties like cargo size, price, volume etc. You have to test the different ReadText17's to find one that comes close to your expectations. If you don't find any, then you'll need to start modding.
What exactly are you want to do?

AmadanLegre
26.11.2008, 16:53
Oh, it seems I didn't understand your original question. I thought you were referring to the fact that if you use a command in one of the two slots, the command executed is not properly displayed. If you do not use the 'set script command' instruction, the command is not displayed.
Re-reading your original question, I think you refer to the fact that there's no hint that there are additional ship commands that could be executed, right? Well, that can't be helped, that's the way it works: in fact, the info 'None' is absolutely correct - there are no commands in this slot. All you can do is document this in a ReadMe or one a website!



The MSCI handbook is a reference for scripting. Are you sure you want to mod a ware? Most of the time, this isn't really necessary. Those ReadText17 entries are wares not used by the game, but ready to use.
All you have to do is edit a t-file and use the following lines:

<page id="17">
<text id="5773">My New Ware</t>
</page>
Now you have a new ware, ready to use for whatever purpose you want.
The drawback is that you have to go with the values the game provides. All these wares have certain properties like cargo size, price, volume etc. You have to test the different ReadText17's to find one that comes close to your expectations. If you don't find any, then you'll need to start modding.
What exactly are you want to do?
Yes you're correct about the "Additional Ship Commands" concern. That's what I was wondering about. Too bad it can't be changed!

How do I browse for those items again? The pre-built ones? Which file are they in? As for what I'm creating.. I want to create a ware that's required in order to access a recruitment agency's services. It won't be expensive, it's basically just you buying a basic account. Using the service also costs credits so the war doesn't need to cost much. Just want it for consistency. Also, there could be different agencies down the road that offer similar services at higher quality, so it'd be nice to know how to do this.

EDIT: I'd also like to know whether I can attach more than one version/type of a ware to the same command menu item. The idea is that I wouldn't have to add more commands, and I can change their results by changing the ware that allows for them. If I can't do it this way, I'll have to use a script and store some globals. Then I could use just one ware ware/type. Once you got it, you'd "log in" to the recruitment service and from there you'd have to pick an agency to join and create an account. This way there can be agencies based on faction/idealogy, but they'd all use the same command menu item.