[Discussion] Generic X3TC S&M questions III

The place to discuss scripting and game modifications for X³: Terran Conflict and X³: Albion Prelude.

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

User avatar
ScRaT_GER
Posts: 1962
Joined: Tue, 8. Jan 08, 18:19
x3tc

Post by ScRaT_GER » Sat, 23. Apr 11, 22:25

It's only there when the menu is open. So... once I try to equip ship 1, I need an array called, say Equip1. Then for ship 2, Equip2, etc.
Does that mean, that you only want to create the equipment array, if you actually try to equip that ship?

In any case, why not simply create an array of arrays:

Code: Select all

$ships = ... (your ships, array stays the same as long as the script runs)
$equipments = array alloc: size=$sizeOfShipArray

$selectedShip = ... (a ship you selected in the menu)
$index = get index of $selectedShip in $ships
$equipment = $equipments[$index]
if not $equipment
  * build $equipment array 
  $equipments[$index] = $equipment
end
* do something with $equipment
Like that, you'd lazily construct the array $equipments, which holds the equipment of each ship in the corresponding index.

Greetings,
ScRaT

User avatar
EmperorJon
Posts: 9378
Joined: Mon, 29. Dec 08, 20:58
x3tc

Post by EmperorJon » Sat, 23. Apr 11, 23:21

Yeah, but the point is, there are multiple ship groups... er, I'll try an example.


10 Nova
3 Centaur
2 Cerberus

All ships have shields, weapons etc...


So I create an array, equipment1, and match it up to the 10 Nova... but then, with the Centaurs, I need a new array, equipment2, and then 3 for cerberus, and an infinite number more for more ships...
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______

User avatar
ScRaT_GER
Posts: 1962
Joined: Tue, 8. Jan 08, 18:19
x3tc

Post by ScRaT_GER » Sun, 24. Apr 11, 00:19

Yeah, but the point is, there are multiple ship groups...
Then, instead of doing it on a per ship basis, do it on a per group basis. Where exactly is the problem with possibly infinite numbers of groups?

Maybe you could show some code, so that the problem gets clearer.

Greetings,
ScRaT[/quote]

User avatar
EmperorJon
Posts: 9378
Joined: Mon, 29. Dec 08, 20:58
x3tc

Post by EmperorJon » Sun, 24. Apr 11, 09:45

It is on a per group or per ship basis. (There may be a group of only 1 ship, for example)

The problem stems from the fact that, when setting up an array, I'm creating an array called Equipment, for example, every time, and cannot think of a way of setting up an array with a different name. I cannot think how to dynamically make a new array for every group there is.


Showing code is a last resort. I was tired when I did it. And, well, it's horribly inefficient and... messy.
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______

User avatar
ScRaT_GER
Posts: 1962
Joined: Tue, 8. Jan 08, 18:19
x3tc

Post by ScRaT_GER » Sun, 24. Apr 11, 10:40

I cannot think how to dynamically make a new array for every group there is.
The point is, that you cannot assign each equipment-array to a different variable, because you cannot create variables on the fly. So instead, you have to gather each equipment array in another array (as I did in the code below), so that you can later get them through their index in the array.

The code might look like this:

Code: Select all

$groups = ... (array of groups, where each group is an array of ships)
$size = size of array $groups
$equipments = array alloc: size=$size

* Fill $equipments array
$i = size of array $groups
while $i 
  dec $i =  
  = wait 1 ms
  $equipment = ... (somehow create an equipment array for that group)
  $equipments[$i] = $equipment
end
Now, you can get the equipment of each group, by getting their index in the $groups array and then using that index for the $equipments array.

This solution would be quite expensive though, because it would create the entire $equipments array directly. But depending on your menu, you don't even need that, which is why I proposed building the array lazily as you need the entries (see previous example).

Greetings,
ScRaT

User avatar
EmperorJon
Posts: 9378
Joined: Mon, 29. Dec 08, 20:58
x3tc

Post by EmperorJon » Sun, 24. Apr 11, 10:44

Ah, now I understand, thank you... Shame that MSCI doesn't support an easy 2D array function...
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______

User avatar
ScRaT_GER
Posts: 1962
Joined: Tue, 8. Jan 08, 18:19
x3tc

Post by ScRaT_GER » Sun, 24. Apr 11, 11:12

Shame that MSCI doesn't support an easy 2D array function...
What do you mean? You cannot create a 2D array directly, but at least you can get elements from a 2D array via $array[x][y].

Greetings,
ScRaT

User avatar
s9ilent
Posts: 2033
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent » Sun, 24. Apr 11, 23:30

@EJ

Just some ideas for your fleet idea thingy. (Separation of concerns)

-Consider separating ship equipment, and ship types/numbers. e.g. Have some pre set ship "templates". As I'm guessing most of the time, each ship of the same type has a similar load out.
-Also you may want to just have an option to "max out shields=true" and not specify the shield type/qty directly. (assume this is always true, unless specified to be false?)

-Or pherhaps, you can have "hardpoint" load outs (turret/cockpit weapon combo's). And then you just specify what ship, and what loadout in which turret.



And finally w.r.t tfile/logfile
There's a json and an xml script lib in the stickies
Although tbh, it is probably easier to just write your own system from scratch.

NicoPalazzari
Posts: 66
Joined: Fri, 5. Mar 10, 20:24
x3tc

Post by NicoPalazzari » Mon, 25. Apr 11, 21:22

I updated my game to 3.1 and downloaded some of your scripts. The problem I'm having is that when I save my game it saves as 2.0 not 3.1. Is this caused by the scripts? I usually would not care, but the new marine aspects in later patches would be nice to have.

User avatar
X2-Illuminatus
Moderator (Deutsch)
Moderator (Deutsch)
Posts: 24969
Joined: Sun, 2. Apr 06, 16:38
x4

Post by X2-Illuminatus » Tue, 26. Apr 11, 09:32

I updated my game to 3.1 and downloaded some of your scripts.
It would help, if you would post in the scripts' topics or if you would say, which scripts you're using. This is a topic for general S&M questions, so it's not clear which scripts you refer to.
The problem I'm having is that when I save my game it saves as 2.0 not 3.1. Is this caused by the scripts?
No, scripts cannot change the game version. More probably you made a mistake while patching. Best you uninstall your scripts, download the 1.0 -> 3.0 and the 3.0 -> 3.1 patches again and install them after each other. Then check, if saving works without problems.
Nun verfügbar! X3: Farnham's Legacy - Ein neues Kapitel für einen alten Favoriten

Die komplette X-Roman-Reihe jetzt als Kindle E-Books! (Farnhams Legende, Nopileos, X3: Yoshiko, X3: Hüter der Tore, X3: Wächter der Erde)

Neuauflage der fünf X-Romane als Taschenbuch

The official X-novels Farnham's Legend, Nopileos, X3: Yoshiko as Kindle e-books!

sTeeL86
Posts: 28
Joined: Wed, 27. Apr 11, 06:48
x4

Post by sTeeL86 » Wed, 27. Apr 11, 09:02

Is MARS gonna cause problems with SRM/CMO4.8/IR install?

HotSake
Posts: 472
Joined: Sun, 3. Jan 10, 22:15
x3tc

Post by HotSake » Wed, 27. Apr 11, 15:23

sTeeL86 wrote:Is MARS gonna cause problems with SRM/CMO4.8/IR install?
This should be asked in the MARS thread, and no.

SyncViews
Posts: 58
Joined: Thu, 27. Jan 11, 14:38
x3tc

Post by SyncViews » Fri, 29. Apr 11, 11:56

Been working on adding menu interfaces and stuff to some of my scripts. Is there a way to simply display a message, with an OK button, kinda like the pause window, or what you get in Windows with MessageBox(mainWindow, "My Message", "Title", MB_OK)?

I tried doing somthing with custom menus but it always insists on creating the subheading things which I dont want, and send incoming message seems to never pop up over the command console :(

mark_a_condren
Posts: 1468
Joined: Wed, 3. Aug 05, 05:05
x3tc

Post by mark_a_condren » Fri, 29. Apr 11, 13:03

You could try,

$choice = THIS -> get user input: type=Var/Boolean, title='Select Yes to continue'

This will give you a 'Yes / No' dialog box with the 'Select Yes to continue' across the top.


MarCon

SyncViews
Posts: 58
Joined: Thu, 27. Jan 11, 14:38
x3tc

Post by SyncViews » Fri, 29. Apr 11, 13:14

hmm...I guess thats if the closest I can get. Just seems wrong for a "your asking the impossible" message...

mark_a_condren
Posts: 1468
Joined: Wed, 3. Aug 05, 05:05
x3tc

Post by mark_a_condren » Fri, 29. Apr 11, 13:25

How about


send incoming message "your asking the impossible" to player: display it=TRUE


Will pop up right in front of you. Set it to FALSE if you want to get the 'incoming message' warning and then have to press ctrl+M to read it.


EDIT: typo

MarCon

User avatar
s9ilent
Posts: 2033
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent » Fri, 29. Apr 11, 22:29

Heh,

SW quote?

"I need more men!"

(Lv quick, jump in and do your bit)

User avatar
EmperorJon
Posts: 9378
Joined: Mon, 29. Dec 08, 20:58
x3tc

Post by EmperorJon » Sun, 1. May 11, 21:52

Well I'm back at work on the fleet builder...


@max shields idea YES. Good. Will be included

Hmm, turrets... yeah I'll probably add that too.
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______

sTeeL86
Posts: 28
Joined: Wed, 27. Apr 11, 06:48
x4

Post by sTeeL86 » Mon, 2. May 11, 10:45

Not sure if anyone has noted this but you can use this utility

http://www.ntcore.com/4gb_patch.php

to allow X3 to use more than 2GB of RAM.

User avatar
Carlo the Curious
Posts: 16999
Joined: Mon, 5. Mar 07, 22:03
x4

Post by Carlo the Curious » Mon, 2. May 11, 14:03

sTeeL86 wrote:to allow X3 to use more than 2GB of RAM.
It's not necessary. x3tc.exe has LAA turned on already (since 2.7, iirc).

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