[Discussion] Generic X3TC S&M questions III
Moderators: Moderators for English X Forum, Scripting / Modding Moderators
- EmperorJon
- Posts: 9378
- Joined: Mon, 29. Dec 08, 20:58
Quick question regarding object types and such... is there any way to get one converting from a string?
EG. The player types in Mammoth and I can spawn a Mammoth or say "This is not a recognised object", without me having to harcode the entire thing? As far as I can see... it's not possible...
EG. The player types in Mammoth and I can spawn a Mammoth or say "This is not a recognised object", without me having to harcode the entire thing? As far as I can see... it's not possible...
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
-
- Posts: 1468
- Joined: Wed, 3. Aug 05, 05:05
Yes, but it's a workaround (as usual).
Get input string, say Mammoth, then cycle through all the object types and do a temp convert object type to string and check that string for match against the input string. Wollah, create object type Mammoth, or send back to player "This is not a recognised object" if no match found.
MarCon
Get input string, say Mammoth, then cycle through all the object types and do a temp convert object type to string and check that string for match against the input string. Wollah, create object type Mammoth, or send back to player "This is not a recognised object" if no match found.
MarCon
- EmperorJon
- Posts: 9378
- Joined: Mon, 29. Dec 08, 20:58
I thought it'd come to that. Doesn't seem that bad actually.
I'm working on a fleet creator that can be used to create a fleet in game and out of game. You can type it directly into the T file, or it exports into a log file and then you can move it in. Should be, er... 'fun'.
I'm working on a fleet creator that can be used to create a fleet in game and out of game. You can type it directly into the T file, or it exports into a log file and then you can move it in. Should be, er... 'fun'.
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
*omg* l3+ ideas is temporarily closed
In any case, I'm posting this here (next best thing) as I will probably forget if I dont.
Idea: Provide better debug support, i.e. Instead of just debug log, and debug trace, provide the ability to put break points in scripts, and have a level of debug between log and trace (i.e. debug break- where it will only stop at the pre defined break points).
As often you want to debug after loops, but don't care about the loop it self (or any intermediate scripts that you call)
In any case, I'm posting this here (next best thing) as I will probably forget if I dont.
Idea: Provide better debug support, i.e. Instead of just debug log, and debug trace, provide the ability to put break points in scripts, and have a level of debug between log and trace (i.e. debug break- where it will only stop at the pre defined break points).
As often you want to debug after loops, but don't care about the loop it self (or any intermediate scripts that you call)
- EmperorJon
- Posts: 9378
- Joined: Mon, 29. Dec 08, 20:58
I can't remember, but you could remove the ware and make it in a crate outside.
Now, a head scratching problem for me...
I have a fleet. It is stored in an array, as ship names and numbers and such.
Now, I want to have an array for each of those (groups of) ships. This stores equipment.
The problem I have is this... dynamically creating the arrays for ship equipment. None of this is saved in GVs or anything, it's all kept in a big open menu. 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.
Short of making the arrays a global variable (and removing them on closing), I can't think there's another way of doing it... any help?
Now, a head scratching problem for me...
I have a fleet. It is stored in an array, as ship names and numbers and such.
Now, I want to have an array for each of those (groups of) ships. This stores equipment.
The problem I have is this... dynamically creating the arrays for ship equipment. None of this is saved in GVs or anything, it's all kept in a big open menu. 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.
Short of making the arrays a global variable (and removing them on closing), I can't think there's another way of doing it... any help?
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
Does that mean, that you only want to create the equipment array, if you actually try to equip that ship?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.
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
Greetings,
ScRaT
- EmperorJon
- Posts: 9378
- Joined: Mon, 29. Dec 08, 20:58
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...
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.
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
- EmperorJon
- Posts: 9378
- Joined: Mon, 29. Dec 08, 20:58
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.
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.
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
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.I cannot think how to dynamically make a new array for every group there is.
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
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
- EmperorJon
- Posts: 9378
- Joined: Mon, 29. Dec 08, 20:58
@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.
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.
-
- Posts: 66
- Joined: Fri, 5. Mar 10, 20:24
- X2-Illuminatus
- Moderator (Deutsch)
- Posts: 24965
- Joined: Sun, 2. Apr 06, 16:38
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.I updated my game to 3.1 and downloaded some of your 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.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?
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!
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!
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
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
-
- Posts: 1468
- Joined: Wed, 3. Aug 05, 05:05