[X3LU] Quick Wings 1.10

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

kaistern
Posts: 441
Joined: Mon, 30. Jun 14, 13:29
x3ap

Post by kaistern » Sun, 9. Nov 14, 09:28

and while my brain is being productive...

this is for the actual mod not the lite version I will work on tomorrow. I think that the first one will create the hotkeys, the second one will make a flag, and the third one will read the flag and give the order to the appropriate wing

with this one I would just add more to it for each hotkey

Code: Select all

setup.qw.register 
001 $blue = get global variable: name='qw.blue' 
002 if not $blue ... 
003    $blue= register hotkey 'Select Blue wing' to call script qw.blue 
004    set global vairiable: name='wc.baction' value=$blue
005 end 

i'll need one of these for each wing

Code: Select all

qw.blue
001 set global variable: name= 'qw_flag' value='blue'
002 end
and I THINK this will bring it all together.

Code: Select all

qw.action
001 $target = get player tracking aim
002 $wing = get global variable 'qw_flag' 
003 if $wing = 'blue'
004    $Wing = get predefined wing: wing=[Wing.Blue] 
005    $Wing.Ships = get flight wing ship array: wing=$Wing 
006    $Ship = $Wing.Ships[0]
       (at this point I could add several 'else if' for each additional wing, right?)
007 end 
008 If $target = ship or station and enemy 
009   $ship -> call script 'attack my target' 
010 
011 Else if $target = ship or station and not enemy 
012   $ship -> call script 'protect my target' 
013 
014 Else 
015   $ship -> call script 'protect me' 
016 end 
I still want to add 2 more command hotkeys (one to protect me only, one to dock) but they will follow a similar format to the action hotkey
Image
Running LU 1.4.7 + XM-O 1.0 + Quick Wings 1.0
Rise of Phanon DiD LUV
Wrath of the Hive DiD XM-O
Try my script: Quick Wings for better wing control in LU!

User avatar
Joubarbe
Posts: 4348
Joined: Tue, 31. Oct 06, 13:11
xr

Post by Joubarbe » Sun, 9. Nov 14, 10:36

1/ Use X-Studio.

2/ Don't be hasty to release something half finished. We want the full thing :)

3/ Just one thing : don't use an intermediary "blue" string in your global variable. Make it "[Wing.Blue]". Then you just have to do that :

Code: Select all

$Wing = get global variable name: 'qw_flag'
$Wing = get predefined wing: wing=$Wing
Then you don't have to do a check for every wing.

kaistern
Posts: 441
Joined: Mon, 30. Jun 14, 13:29
x3ap

Post by kaistern » Sun, 9. Nov 14, 10:41

Joubarbe wrote:1/ Use X-Studio.

2/ Don't be hasty to release something half finished. We want the full thing :)

3/ Just one thing : don't use an intermediary "blue" string in your global variable. Make it "[Wing.Blue]". Then you just have to do that :

Code: Select all

$Wing = get global variable name: 'qw_flag'
$Wing = get predefined wing: wing=$Wing
Then you don't have to do a check for every wing.
1) I downloaded it but I didn't get a chance to play with it before I had to leave the house :) i plan to use it though.

2)Ok ok, I think I have the final product figured out anyhow so the lite version really isn't nessary and is really just a waste of time.

3)That makes a lot of since actually.

added:oh wow that will cut out a LOT of programming :D thank you sir!
Image
Running LU 1.4.7 + XM-O 1.0 + Quick Wings 1.0
Rise of Phanon DiD LUV
Wrath of the Hive DiD XM-O
Try my script: Quick Wings for better wing control in LU!

kaistern
Posts: 441
Joined: Mon, 30. Jun 14, 13:29
x3ap

Post by kaistern » Wed, 12. Nov 14, 01:50

Success! well sort of... I managed to order A ship from blue wing to attack my target.... which wasn't very usefull as he left his friends behind and decided to walk through 5 or 6 sectors to get to me instead of jumping.... BUT IT'S PROGRESS!!!

Code: Select all

$target = get player tracking aim
$flag = get global variable: name='qw_flag'
$Wing = get predefined wing: wing=$flag
$wing.ships = get flight wing ship array: wing=$Wing
$ship = $wing.ships[0]
skip if $ship-> exists
write to player logbook 'Error: No wing selected'
skip if $ship-> exists
return null
if $target-> is [PLAYERSHIP] a enemy
START $ship-> call script '!wing.cmd.attack.std' : WING=$Wing target=$target
else if $target-> is [PLAYERSHIP] a friend
START $ship-> call script '!wing.cmd.protect.std' : WING=$target target=[FALSE]
else
START $ship-> call script '!wing.cmd.protect.std' : argument1=[PLAYERSHIP] argument2=[FALSE]
end
return null 
I didn't get much time to work on this this weekend(yeah my weekend this week was sunday-monday) but my work week is only two days long and then I have three off. While i'm away from home I'll read more on arrays and chapter 7 of the MSCI
Image
Running LU 1.4.7 + XM-O 1.0 + Quick Wings 1.0
Rise of Phanon DiD LUV
Wrath of the Hive DiD XM-O
Try my script: Quick Wings for better wing control in LU!

Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 20604
Joined: Mon, 15. Nov 04, 00:26
x4

Post by Cycrow » Wed, 12. Nov 14, 10:53

The main problem here is that unlike ship commands, wing commands are actually global scripts.

as you are running the command a ship, what happens is that the wing command then issues the command to that ship with overrides the existing script.

Which means once the first ship gets its command, the wing script is essentially terminated so no other ships will move.

change the $ship -> call script to $null -> call script

User avatar
Joubarbe
Posts: 4348
Joined: Tue, 31. Oct 06, 13:11
xr

Post by Joubarbe » Wed, 12. Nov 14, 11:12

And FYI kaistern, in this case, [THIS] = null = $null.

kaistern
Posts: 441
Joined: Mon, 30. Jun 14, 13:29
x3ap

Post by kaistern » Thu, 13. Nov 14, 05:46

Thanks guys I took your info and.... it worked sort of... I am once again running into issues with the scripts communication, and for some reason when I DO manage to get the order through to the wing it acts wierd. But lets start from the beginning, I changed the action code to

Code: Select all

$target = get player tracking aim
$flag = get global variable: name='qw_flag'
if not $flag-> exists
write to player logbook 'Error: No wing selected'
play sample 920
end
skip if $flag-> exists
return null
if $target-> is [PLAYERSHIP] a enemy
START [THIS]-> call script '!wing.cmd.attack.std' : WING=$flag target=$target
else if $target-> is [PLAYERSHIP] a friend
START $ship-> call script '!wing.cmd.protect.std' : WING=$target target=[FALSE]
else
START $ship-> call script '!wing.cmd.protect.std' : WING=[PLAYERSHIP] target=[FALSE]
end
return null
(I later added the message to logbook and the play sample to let me know when the scripts are not talking properly, but more on that later)

and nothing happened. So I decided to try changing the WING=$flag to WING=BLUE WING to see if it would work... and it DID!!! or sort of the wing jumped in and started on the enemy, but I obviously was not done with the code so I used the normal way to order them back to their homebase which is when it got weird. Instead of jumping back home they just sat there. When I checked their info panel I noticed that their action was jumping back and forth between "move to" (from the command for the wing to jump home I assume) and "attack in formation" (from the attack command I made I assume. Any ideas why this happened? I could not for the life of me get them to stop so I had to reload the game.

After messing with the above for an hour or so and not getting anywhere I decided to switch gears for awhile, and work on the 2 scripts communicating. That's when I added the message "Error: No wing selected" and the audio file so that I knew when they were not working together. I wasn't sure what was going on so I wrote a short script to check the state of the flag.

Code: Select all

$flag = get global variable: name='qw_flag'
write to player logbook $flag
return null
which returned "3" which was really weird to me since it should read "BLUE WING" (though I used the select flight wing option to put the works blue wing in the flag code) but what was also weird is that the flag did exist so it should not have been saying that it wasn't (everytime I was running the action script I was hearing the explosions that should only exist if the flag doesn't)

ANyhow I'm going back to work on it.
Image
Running LU 1.4.7 + XM-O 1.0 + Quick Wings 1.0
Rise of Phanon DiD LUV
Wrath of the Hive DiD XM-O
Try my script: Quick Wings for better wing control in LU!

kaistern
Posts: 441
Joined: Mon, 30. Jun 14, 13:29
x3ap

Post by kaistern » Thu, 13. Nov 14, 05:53

Actually I may have fixed these stand by for testing...
Image
Running LU 1.4.7 + XM-O 1.0 + Quick Wings 1.0
Rise of Phanon DiD LUV
Wrath of the Hive DiD XM-O
Try my script: Quick Wings for better wing control in LU!

kaistern
Posts: 441
Joined: Mon, 30. Jun 14, 13:29
x3ap

Post by kaistern » Thu, 13. Nov 14, 07:07

or not... still having both issues, Blue wing as a global variable is not seeming to come through as blue wing the wing.

Code: Select all

$target = get player tracking aim
$flag = get global variable: name='qw_flag'
$Wing = get predefined wing: wing=$flag
write to player logbook $target
write to player logbook $flag
write to player logbook $Wing
if $target-> is [PLAYERSHIP] a enemy
START [THIS]-> call script '!wing.cmd.attack.std' : WING=$Wing target=$target
end
return null
This writes 2 player logs the first is blue wing and the second is null.

As well when I change wing=$wing to wing=blue wing blue wing does get the order and follow it but refuses to follow any subsequent orders and instead just sits there.

anyhow I am going to try another idea I had (going back to the flag just being a color and then the action script changing it to a wing, ik ik it take more time to program, but at this rate.... lol)

---------------------------------------------------------




ADDED: I changed the flag script to

Code: Select all

set global variable: name='qw_flag' value='Blue'
return null
and the action script to

Code: Select all

$target = get player tracking aim
$flag = get global variable: name='qw_flag'
if $flag == 'Blue'
$wing = get predefined wing: wing=[Wing.Blue]
end
write to player logbook $target
write to player logbook $flag
write to player logbook $wing
if $target-> is [PLAYERSHIP] a enemy
START [THIS]-> call script '!wing.cmd.attack.std' : WING=$wing target=$target
end
return null
and it worked! Except for the whole "this is the last command ill ever accept" thing lol. maybe i need to set the wing state....

----------------------------------


ADDED2: What is the point of .pl.xml scripts? All they seem to do is call a exact same named .xml script.

---------------------------------


ADDED3: I changed the script to

Code: Select all

$target = get player tracking aim
$flag = get global variable: name='qw_flag'
if $flag == 'Blue'
$wing = get predefined wing: wing=[Wing.Blue]
end
write to player logbook $target
write to player logbook $flag
write to player logbook $wing
if $target-> is [PLAYERSHIP] a enemy
= [THIS]-> call script '!wing.cmd.attack.std' : WING=$wing target=$target
end
return null
but no change in action it still refuses to take any orders after the attack script is called.I'm not sure what I am doing wrong, I think my script now simulates what happens when you go into the command consul and issue the attack command.... grrrrr....... Did I make a loop some how? Is my script not ending properly?
Image
Running LU 1.4.7 + XM-O 1.0 + Quick Wings 1.0
Rise of Phanon DiD LUV
Wrath of the Hive DiD XM-O
Try my script: Quick Wings for better wing control in LU!

kaistern
Posts: 441
Joined: Mon, 30. Jun 14, 13:29
x3ap

Post by kaistern » Thu, 13. Nov 14, 09:21

Ok I figured out the why they keep going back to the same order.... The order never falls off the global list!!!! So now I need to figure out how to force it off the global list, maybe a break? (Added: yeah that didn't work but at least I know what the problem is.... back to the MSCI handbook to see if i can figure this out before you guys get online, if I do i'll post if not I hope ya'll might have an idea or two ;) )

current code

Code: Select all

* ************************************************
* SCRIPT NAME: Quick Wings action command.xml
* DESCRIPTION: Gives the selected wing the attack/protect target/protect me command
* 
* AUTHOR:Kaistern           DATE: 9 November 2014
* ************************************************
$target = get player tracking aim

* Uses the quick wing flag to determine which wing to give orders to
$flag = get global variable: name='qw_flag'
if $flag == 'Blue'
$wing = get predefined wing: wing=[Wing.Blue]
else if $flag == 'Red'
$wing = get predefined wing: wing=[Wing.Red]
else if $flag == 'Gold'
$wing = get predefined wing: wing=[Wing.Gold]
else if $flag == 'Green'
$wing = get predefined wing: wing=[Wing.Green]
else if $flag == 'Orange'
$wing = get predefined wing: wing=[Wing.Orange]
else if $flag == 'Purple'
$wing = get predefined wing: wing=[Wing.Purple]
else if $flag == 'Silver'
$wing = get predefined wing: wing=[Wing.Silver]
else if $flag == 'White'
$wing = get predefined wing: wing=[Wing.White]
end

* Error test to be removed before release
write to player logbook $target
write to player logbook $flag
write to player logbook $wing

* actual action commands
if $target-> is [PLAYERSHIP] a enemy
@ = [THIS]-> call script '!wing.cmd.attack.std' : WING=$wing target=$target
else if $target-> is [PLAYERSHIP] a friend
@ = [THIS]-> call script '!wing.cmd.protect.std' : WING=$wing target=$target
else
@ = [THIS]-> call script '!wing.cmd.protect.std' : WING=$wing target=[PLAYERSHIP]
end
return null
Image
Running LU 1.4.7 + XM-O 1.0 + Quick Wings 1.0
Rise of Phanon DiD LUV
Wrath of the Hive DiD XM-O
Try my script: Quick Wings for better wing control in LU!

Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 20604
Joined: Mon, 15. Nov 04, 00:26
x4

Post by Cycrow » Thu, 13. Nov 14, 10:45

its been awhile since i did anything with wings, so cant remember the exact way to use them without looking it up.

it might be better to start the wing commands, rather than run the scripts directly on them.

wing commands are special, they dont work the same as ship commands. The scripts are run globally, but they shouldn't actually show up in the global scripts list, they should be hidden.
Sounds like running the scripts directly doesn't trigger this

Its possible that your global variable isn't work for the Blue wing only. You could store the actual wing object instead.

Code: Select all

$wing = get predefined wing: with=[Wing.Blue]
set global variable: name='qw_flag' value=$wing

the .pl scripts are player commands.
all command scripts have a number of arguments, when run by the player, there is an input for each argument.
so the .pl scripts use different arguments to change how the input works.
Or at least they used to, with AP and preload commands, these were changed abit, so some .pl scripts are no longer different

User avatar
Joubarbe
Posts: 4348
Joined: Tue, 31. Oct 06, 13:11
xr

Post by Joubarbe » Thu, 13. Nov 14, 11:43

kaistern wrote:

Code: Select all

$flag = get global variable: name='qw_flag'
write to player logbook $flag
return null
which returned "3" which was really weird to me since it should read "BLUE WING" (though I used the select flight wing option to put the works blue wing in the flag code) but what was also weird is that the flag did exist so it should not have been saying that it wasn't (everytime I was running the action script I was hearing the explosions that should only exist if the flag doesn't)
When you write something in brackets or braces, like [Argon], [Blue.Wing] or {Advanced Satellite} for instance, that always return an integer. They are strings in X-Studio for convenience, because otherwise it would be unreadable. Strings should always be avoided when you do not want to communicate to the player. Hence what I said earlier and what Cycrow said above. ($flag should be an integer, [Blue.Wing])

And that, again :
Cycrow wrote:it might be better to start the wing commands, rather than run the scripts directly on them.

kaistern
Posts: 441
Joined: Mon, 30. Jun 14, 13:29
x3ap

Post by kaistern » Thu, 13. Nov 14, 11:53

thanks for the reply, unfortunately it raised more question then it answered :P
Cycrow wrote: it might be better to start the wing commands, rather than run the scripts directly on them.
how? lol
The scripts are run globally, but they shouldn't actually show up in the global scripts list, they should be hidden.
Sounds like running the scripts directly doesn't trigger this
To clarify in case I
caused some confusion, the wing commands were not what I saw on the global list, but my script. For some reason my script was not shutting down and instead it was continuing to run and (I think) reissue the order over and over again.
Its possible that your global variable isn't work for the Blue wing only. You could store the actual wing object instead.

Code: Select all

$wing = get predefined wing: with=[Wing.Blue]
set global variable: name='qw_flag' value=$wing
I tried it with a couple other wings as well, gold wing came back as 1, blue as 3... ect... idk why but the method I am using now seems to work(and i dont think that it should hurt performance? lol)
the .pl scripts are player commands.
all command scripts have a number of arguments, when run by the player, there is an input for each argument.
so the .pl scripts use different arguments to change how the input works.
Or at least they used to, with AP and preload commands, these were changed abit, so some .pl scripts are no longer different
ROFL I am just going to pretend any of that made since to me :D I dont think it is pertinent to my current scripts so.... anyway.... lol

---------------------------------------

I finished the script that creates the hotkeys, as well as all of the selection hotkeys. All of which run as expected. I THINK that the wing command it self is working correctly but MY script to call it is not dying like all good scripts should and instead it keeps issuing the order ever chance it gets. Unfortunately I THINK that this will apply to all of the command key that I write in the same format but..... meh...

Any ideas why my script isn't dying?
Image
Running LU 1.4.7 + XM-O 1.0 + Quick Wings 1.0
Rise of Phanon DiD LUV
Wrath of the Hive DiD XM-O
Try my script: Quick Wings for better wing control in LU!

kaistern
Posts: 441
Joined: Mon, 30. Jun 14, 13:29
x3ap

Post by kaistern » Thu, 13. Nov 14, 12:01

Joubarbe you ninja :D
Joubarbe wrote:
kaistern wrote:

Code: Select all

$flag = get global variable: name='qw_flag'
write to player logbook $flag
return null
which returned "3" which was really weird to me since it should read "BLUE WING" (though I used the select flight wing option to put the works blue wing in the flag code) but what was also weird is that the flag did exist so it should not have been saying that it wasn't (everytime I was running the action script I was hearing the explosions that should only exist if the flag doesn't)
When you write something in brackets or braces, like [Argon], [Blue.Wing] or {Advanced Satellite} for instance, that always return an integer. They are strings in X-Studio for convenience, because otherwise it would be unreadable. Strings should always be avoided when you do not want to communicate to the player. Hence what I said earlier and what Cycrow said above. ($flag should be an integer, [Blue.Wing])

And that, again :
Cycrow wrote:it might be better to start the wing commands, rather than run the scripts directly on them.
hmmm I think my head is not wrapping around integer... my algebra tells me that should be a number, so in short under the covers [blue.wing] is equal to 3, but to make it look good to me it reads [blue.wing] until I had the computer spit it out in a logbook where it returned to 3. Ok I'm with you now. Does it hurt anything to leave it the way it is now... errr... working? lol if it does hurt I'll change it and wrestle that lion again but if not i'll leave it alone :P

ADDED: malfunctioning script

Code: Select all

$target = get player tracking aim

* Uses the quick wing flag to determine which wing to give orders to
$flag = get global variable: name='qw_flag'
if $flag == 'Blue'
$wing = get predefined wing: wing=[Wing.Blue]
else if $flag == 'Red'
$wing = get predefined wing: wing=[Wing.Red]
else if $flag == 'Gold'
$wing = get predefined wing: wing=[Wing.Gold]
else if $flag == 'Green'
$wing = get predefined wing: wing=[Wing.Green]
else if $flag == 'Orange'
$wing = get predefined wing: wing=[Wing.Orange]
else if $flag == 'Purple'
$wing = get predefined wing: wing=[Wing.Purple]
else if $flag == 'Silver'
$wing = get predefined wing: wing=[Wing.Silver]
else if $flag == 'White'
$wing = get predefined wing: wing=[Wing.White]
end

* Error test to be removed before release
write to player logbook $target
write to player logbook $flag
write to player logbook $wing

* actual action commands
if $target-> is [PLAYERSHIP] a enemy
@= [THIS]-> call script '!wing.cmd.attack.std' : WING=$wing target=$target
else if $target-> is [PLAYERSHIP] a friend
@= [THIS]-> call script '!wing.cmd.protect.std' : WING=$wing target=$target
else
@= [THIS]-> call script '!wing.cmd.protect.std' : WING=$wing target=[PLAYERSHIP]
end
return null
ADDED2: after issuing the action command I went to the global scripts and manually kiled the action script and that reset the wing to it's normal state so it is defiantly the action script that is causing the problem. I need a way to force it to die? Could the interrupt spots be causing the problem? I tried to find a way to make it without them but was unable.
Last edited by kaistern on Thu, 13. Nov 14, 12:10, edited 1 time in total.
Image
Running LU 1.4.7 + XM-O 1.0 + Quick Wings 1.0
Rise of Phanon DiD LUV
Wrath of the Hive DiD XM-O
Try my script: Quick Wings for better wing control in LU!

User avatar
Joubarbe
Posts: 4348
Joined: Tue, 31. Oct 06, 13:11
xr

Post by Joubarbe » Thu, 13. Nov 14, 12:08

It doesn't hurt, it's just ugly and useless :)

Code: Select all

$flag = get global variable: name = 'qw_flag'
$wing = get predefined wing: wing = $flag
---

When Cycrow said you need to start your scripts, it means what I said earlier :

Code: Select all

START THIS -> call script '!wing.cmd.attack.std' : WING=$wing target=$target
The problem is wings are special like he said, and I'd need to some tests to be sure how they work ; the problem is to overwrite the current command, and I'm not sure your script will do that.

Post Reply

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