[Script Request - Mayhem] Fleet command for multiple "flagging for tug"
Moderators: Moderators for English X Forum, Scripting / Modding Moderators
-
- Posts: 267
- Joined: Fri, 20. Oct 17, 09:20
[Script Request - Mayhem] Fleet command for multiple "flagging for tug"
Hello,
Following the many improvements of the fleet system in Mayhem, I'm looking for someone who could create a "simple" script for me (as my coding knowledge is level 4 on a scale of 100, and the few times I tried something with Xstudio, it was a failure !! )
--- Fleet : Flag damaged fighters for Tug ---
1) RP purpose : after a fight, call the tug to gather all damaged fighters home for repairs. (because I don't like the idea of fighters with a jump drive !).
2) Description :
- command selected from a Fleet Leader command console, under "Fleet" (added below "Call to Arms" and the other existing commands)
- checks all fighters in this fleet
- if their hull <100% then run the "Flag for Tug" (LitCube"s) command on each of them
---------
That's all !
Thanks in advance to the person who could create this for me
Best regards,
Aurélien
Following the many improvements of the fleet system in Mayhem, I'm looking for someone who could create a "simple" script for me (as my coding knowledge is level 4 on a scale of 100, and the few times I tried something with Xstudio, it was a failure !! )
--- Fleet : Flag damaged fighters for Tug ---
1) RP purpose : after a fight, call the tug to gather all damaged fighters home for repairs. (because I don't like the idea of fighters with a jump drive !).
2) Description :
- command selected from a Fleet Leader command console, under "Fleet" (added below "Call to Arms" and the other existing commands)
- checks all fighters in this fleet
- if their hull <100% then run the "Flag for Tug" (LitCube"s) command on each of them
---------
That's all !
Thanks in advance to the person who could create this for me
Best regards,
Aurélien
Re: [Script Request - Mayhem] Fleet command for multiple "flagging for tug"
Hint 1: "Mayhem.Fleet.Repair".
Hint 2: "Cmd.Tug.Flag".
Hint 3: You cannot add more commands to the fleet menu.
Hint 2: "Cmd.Tug.Flag".
Hint 3: You cannot add more commands to the fleet menu.
-
- Posts: 267
- Joined: Fri, 20. Oct 17, 09:20
Re: [Script Request - Mayhem] Fleet command for multiple "flagging for tug"
Thanks for that !
Could this possibly work? (with a hotkey defined -----------> how can I add that to the command menu of a ship instead?)
?
First ever try to write a script
>EDIT : doesn't work :-p
Could this possibly work? (with a hotkey defined -----------> how can I add that to the command menu of a ship instead?)
$currentsector = [PLAYERSHIP]-> get sector
$allships = $currentsector-> get player owned ship array from sector
$fighters = array alloc: size=0
for each $ship1 in array $allships
$class = $ship1-> get object class
do if $class == [Fighter]
insert $ship1 into array $fighters at index 0
end
for each $ship2 in array $fighters
$hull = $ship2-> get hull percent
do if $hull < 100
=[THIS] -> call script 'Cmd.Tug.Flag' : Ship=$ship2
end
return null
?
First ever try to write a script
>EDIT : doesn't work :-p
-
- Posts: 267
- Joined: Fri, 20. Oct 17, 09:20
Re: [Script Request - Mayhem] Fleet command for multiple "flagging for tug"
Tried this as well :
----------------------------
$currentsector = [PLAYERSHIP]-> get sector
$allships = $currentsector-> get player owned ship array from sector
for each $ship in array $allships
$class = $ship-> get object class
if $class == [Fighter]
=$ship-> call script 'Cmd.Tug.Flag': [THIS]= $ship
end
end
return null
----------------
but won't work either... anywone could explain to me what I'm doing wrong? Sorry if it's obvious...
----------------------------
$currentsector = [PLAYERSHIP]-> get sector
$allships = $currentsector-> get player owned ship array from sector
for each $ship in array $allships
$class = $ship-> get object class
if $class == [Fighter]
=$ship-> call script 'Cmd.Tug.Flag': [THIS]= $ship
end
end
return null
----------------
but won't work either... anywone could explain to me what I'm doing wrong? Sorry if it's obvious...
Re: [Script Request - Mayhem] Fleet command for multiple "flagging for tug"
Don't use direct comparisons with classes (a ship can have multiple classes).
Code: Select all
$isInFleet = $ship -> is in fleet
$hullPercent = $ship -> get hull percent
if $isInFleet AND $hullPercent < 100
do if $ship -> is of class [Fighter]
START [NULL] -> call script 'Lib.Cmd.Tug.Flag': Ship=$ship
end
-
- Posts: 267
- Joined: Fri, 20. Oct 17, 09:20
Re: [Script Request - Mayhem] Fleet command for multiple "flagging for tug"
That works thanks a lot !
- For the direct comparison, you meant mine would always return FALSE? (eg: if ship = fighter + small ship, then ship == fighter is always FALSE ?)
- How do you know how to use the script properly? You wrote is as "START [NULL] ........" why this typo?
- For the direct comparison, you meant mine would always return FALSE? (eg: if ship = fighter + small ship, then ship == fighter is always FALSE ?)
- How do you know how to use the script properly? You wrote is as "START [NULL] ........" why this typo?
Re: [Script Request - Mayhem] Fleet command for multiple "flagging for tug"
Comparing two object classes gives unexpected results.
You should read the MSCI handbook and read some tutos. START is a vast subject. In a nutshell: in X3, you run scripts either on objects (START $ship), or globally (START [NULL]), and in the former, you have to choose on what tasks you want to run your script. See the X-Studio tooltip for the "begin task" command for more info on that subject.
You should read the MSCI handbook and read some tutos. START is a vast subject. In a nutshell: in X3, you run scripts either on objects (START $ship), or globally (START [NULL]), and in the former, you have to choose on what tasks you want to run your script. See the X-Studio tooltip for the "begin task" command for more info on that subject.
-
- Posts: 267
- Joined: Fri, 20. Oct 17, 09:20
Re: [Script Request - Mayhem] Fleet command for multiple "flagging for tug"
Thanks very much !
Re: [Script Request - Mayhem] Fleet command for multiple "flagging for tug"
Object classes are in a Hierarchy, so using get object class will only return the actual class of the object and not all the others it belongs too.
The command, is of class, will check against the whole hierarchy.
For example, an M5 would be:
M5
Fighter
Little Ship
Moveable Ship
Ship
Object
The command, is of class, will check against the whole hierarchy.
For example, an M5 would be:
M5
Fighter
Little Ship
Moveable Ship
Ship
Object
-
- Posts: 267
- Joined: Fri, 20. Oct 17, 09:20
Re: [Script Request - Mayhem] Fleet command for multiple "flagging for tug"
Thanks for that, makes sense.
Trying to refine the script slowly, so far I have this :
1/ Am I gonna get nothing in my array with the or will it indeed take the fighters (even if they are also small ships etc...)
2/ Is my last line the correct way to order that ship to move to sector center?
3/ When I run it (with hotkey), it only works for ONE ship in the sector, I have to press it multiple times to get all damaged fighters flagged... any idea why the FOR EACH loop doesn't apply for all ships?
Thanks again in advance for your tips
Trying to refine the script slowly, so far I have this :
Code: Select all
$sector = [PLAYERSHIP]-> get sector
$ships = get ship array: of race [Player] class/type=[Fighter]
for each $ship in array $ships
$isInFleet = $ship-> is in fleet
$hullPercent = $ship-> get hull percent
if $isInFleet AND $hullPercent < 100
$ship-> remove from fleet
$ship-> set homebase to null
START [NULL]-> call script 'Lib.Cmd.Tug.Flag' : Ship=$ship
$ship-> set command: [COMMAND_MOVE_POS] target=$sector target2=0 par1=0 par2=0
end
end
return null
1/ Am I gonna get nothing in my array with the
Code: Select all
get ship array: of race [Player] class/type=[Fighter]
2/ Is my last line the correct way to order that ship to move to sector center?
3/ When I run it (with hotkey), it only works for ONE ship in the sector, I have to press it multiple times to get all damaged fighters flagged... any idea why the FOR EACH loop doesn't apply for all ships?
Thanks again in advance for your tips