Mining Beam Script help

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
Holmpc
Posts: 8
Joined: Mon, 31. Mar 14, 00:19
x3tc

Mining Beam Script help

Post by Holmpc » Tue, 29. Jul 14, 13:13

I am working on a script that I used once before to mobile mine without the ship having to actually cover all the ground and pick up each rock individually. I lost the original script that I had used which had been working properly for some time in AP/TC both.

I think that it plausible that if a ship could have a transporter device then there is no reason it can't have a mineral vacuum.



Code: Select all

$anull = null
if [THIS]
$ship = [THIS]
$ship-> set command: [COMMAND_COLLECT_DEBRIS]
else
$ship = [PLAYERSHIP]
$ship-> set command: [COMMAND_COLLECT_DEBRIS]
end


$sec = $ship-> get sector


$rock = find debris: sector=[Sector] resource=null min yield=0 flags=0 refobj=$Value num=5 maxdist=9999999 refpos=$Array



while $rock-> has collectible rocks
$rmc = $rock-> get resource waretype of asteroid
$count = $rock-> get asteroid yield
$free = $ship-> get free amount of ware $rmc in cargo bay
if $free < $count
$m = sprintf: pageid=8818 textid=1, null, null, null, null, null
play sample: incoming transmission 1, from object $anull
write to player logbook $m
return $anull
end
= $ship-> add $count units of $rmc
$rock-> destruct: show no explosion=[TRUE]
play sample 991
= wait randomly from 1300 to 1800 ms
$rock = find debris: sector=[Sector] resource=null min yield=0 flags=0 refobj=$Value num=5 maxdist=9999999 refpos=$Array
end

return null

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

Post by X2-Illuminatus » Tue, 29. Jul 14, 16:50

Your title suggests that need you help with your script. However, you haven't told us, what the problem is you need help with.
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!

Holmpc
Posts: 8
Joined: Mon, 31. Mar 14, 00:19
x3tc

Post by Holmpc » Tue, 29. Jul 14, 18:43

I am unable to get this script to do anything. It is being called in place of move.collectrocks in another script. I have used this or a slight variation before but haven't had this particular one work since fresh install and add-on pack. Game is flagged as modded and several other scripts installed.

User avatar
vukica
Posts: 1744
Joined: Sun, 10. Aug 08, 18:05
x4

Post by vukica » Tue, 29. Jul 14, 19:05

Holmpc wrote:I am unable to get this script to do anything. It is being called in place of move.collectrocks in another script. I have used this or a slight variation before but haven't had this particular one work since fresh install and add-on pack. Game is flagged as modded and several other scripts installed.
is this script .pck or .xml?

game could just be using the wrong version...
Split say NEED MORE FIREPOWER!!

Holmpc
Posts: 8
Joined: Mon, 31. Mar 14, 00:19
x3tc

Post by Holmpc » Tue, 29. Jul 14, 20:31

.pck script

User avatar
JSDD
Posts: 1378
Joined: Fri, 21. Mar 14, 20:51
x3tc

Post by JSDD » Tue, 29. Jul 14, 21:44

... there R several errors in your code, i assume that´s the complete code, right ?

1. the variable $Value (used in the "find"-instruction) is not set anywhere
2. the variable $Array (used in the "find"-instruction) is not set anywhere
3. you dont check anywhere IF the object exists
4. you better run the script on the object which shouldd collect ´roids

Code: Select all

if [THIS]
$ship = [THIS]
$ship-> set command: [COMMAND_COLLECT_DEBRIS]
else
[PLAYERSHIP] -> start task 7778888867 with script xxxxfffffhdhsddhxdf ...
return null
end 
5. you have to set flags=[Find.Multiple] if you set num=5
6. refobj must exist if you set maxdist=2147483647
7. refobj must exist if you set refpos=$Array

... the "find"-instruction wont find anything (i guess), because [SECTOR] means the sector of the object on which this script is running

i would do it something like that:

Code: Select all

skip if THIS exists
| return null

skip if THIS is of class TS
| return null

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


############################
while TRUE

skip if THIS get amount of ware "Transporter Device" in cargobay
| return null

gosub FIND.ROIDS
if not $count.roids > 0
| wait 10000ms
| continue
end

// ... here the collect loop

wait 2000-4000ms

end
############################

return null

FIND.ROIDS

$scanner.range = THIS -> get scanner range
$array.roids = find ... refobj=THIS ... flags=[Find.Multiple] ... maxdist=
$scanner.range
$count.roids = size of array $array.roids

endsub

return null
To err is human. To really foul things up you need a computer.
Irren ist menschlich. Aber wenn man richtig Fehler machen will, braucht man einen Computer.


Mission Director Beispiele

Holmpc
Posts: 8
Joined: Mon, 31. Mar 14, 00:19
x3tc

Post by Holmpc » Wed, 30. Jul 14, 01:56

Yes I have some errors there, I will take a further look at it tonight if I get a moment. Thank you for the clarification on the things that I was clearly missing. it has been quite a while since I did any scripting in the game and I really only fiddled before.

I played with one a few months back and the first one was taking all asteroids in a sector in a few seconds. and was not breaking them down. you only got the yield of the full roid. I eventually tweaked that one to where it was only getting collectible rocks and with a cheat cargo capacity mobile repair ship - somewhere in the millions and a few mining ships could fully clear kingdoms end of all non asteroid size rocks in a few game hours.

Post Reply

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