[Script] Simple Claim Hotkey

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

Post Reply
Treelor
Posts: 314
Joined: Mon, 5. May 08, 01:25
x4

[Script] Simple Claim Hotkey

Post by Treelor » Thu, 3. Jan 13, 07:30

So I decided one day that I wanted an easy way to claim ships that didn't have extra features bundled in, or required certain wares in my cargohold, or any of that. So, I made a script for it. It checks to ensure there is no pilot in your targeted ship, and if this condition is true, it makes it yours and writes a quick note in your log saying you claimed a ship. No sounds, no fanfare, just a ship that was once blue and is now green.

Download
Last edited by Treelor on Thu, 3. Jan 13, 09:58, edited 1 time in total.

User avatar
Jack08
Posts: 2993
Joined: Sun, 25. Dec 05, 10:42
x3tc

Post by Jack08 » Thu, 3. Jan 13, 08:04

Try something like this:

Code: Select all

$GVar = 'Hotkey.Claim.Ship'
$Key = get global variable: name=$GVar 
if not $Key
   $Label = read text: page=7777 id=20013
   $Key = register hotkey $Label to call script 'ClaimShipScript'
   set global variable: name=$GVar value=$Key
end
You can take out the read text in favor of just hard-coding the name if you like.
[ external image ]
"One sure mark of a fool is to dismiss anything that falls outside his experience as being impossible."
―Farengar Secret-Fire

User avatar
jack775544
Posts: 1277
Joined: Tue, 13. Dec 11, 08:27
x4

Post by jack775544 » Thu, 3. Jan 13, 08:56

For your setup script just use this code:

Code: Select all

if not get global variable: name='GlobalVar'
$HK = register hotkey 'Cipher Game' to call script 'ScriptName'
set global variable: name='GlobalVar' value=$HK
end
Replace GlobalVar with a global variable name, and ScriptName with the name of your script.

It will only make one hotkey using that.
1940s - Various "computers" are "programmed" using direct wiring and switches. Engineers do this in order to avoid the tabs vs spaces debate.

Treelor
Posts: 314
Joined: Mon, 5. May 08, 01:25
x4

Post by Treelor » Thu, 3. Jan 13, 09:38

I thought it would be something like that, just wasn't sure how global variables work in this engine. Thanks! I'll update it right away.

Edit: File updated and post edited as appropriate. Thanks again for your help!

User avatar
jack775544
Posts: 1277
Joined: Tue, 13. Dec 11, 08:27
x4

Post by jack775544 » Thu, 3. Jan 13, 11:28

Hope you changed the text from cipher game as well. Forgot to change that from my script that I copied it from as well :oops: .
1940s - Various "computers" are "programmed" using direct wiring and switches. Engineers do this in order to avoid the tabs vs spaces debate.

Treelor
Posts: 314
Joined: Mon, 5. May 08, 01:25
x4

Post by Treelor » Thu, 3. Jan 13, 11:59

Haha yes, I of course changed that.

User avatar
Jack08
Posts: 2993
Joined: Sun, 25. Dec 05, 10:42
x3tc

Post by Jack08 » Thu, 3. Jan 13, 12:02

Only checking the pilots name could be a problem, it is possible for the pilot to not exist but the ship to still be under a races control - if you want to be 100% certain that the target ship has bailed you can use this check:

Code: Select all

$Race = $Object-> get owner race
$Cmd = $Object-> get command
if $Race == [Neutral Race] AND $Cmd == [COMMAND_NONE]
   * This ship has bailed.
end
[ external image ]
"One sure mark of a fool is to dismiss anything that falls outside his experience as being impossible."
―Farengar Secret-Fire

User avatar
Gazz
Posts: 13244
Joined: Fri, 13. Jan 06, 16:39
x4

Post by Gazz » Thu, 3. Jan 13, 12:38

Current speed being zero while the ship isn't docked is also a nice indicator.
Ships always fly... somewhere. =)
My complete script download page. . . . . . I AM THE LAW!
There is no sense crying over every mistake. You just keep on trying till you run out of cake.

Post Reply

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