Page 1 of 2

[Mod] Apricot Salvage Mod (Beta)

Posted: Mon, 15. Oct 07, 10:06
by apricotslice
Apricot Salvage Mod
by Apricotslice


In the Office of John Slice, CEO, Apricot Mapping Service

Ah, pilot, come in, sit down.

I have all your scores here in front of me, and I was at a loss what to do with you. You are an average pilot, useless marksman, overuse the auto pilot, tend to damage ships for no particular reason, useless mechanic, should I go on ? Hmmmm, no.

The question was what to do with you.

Well, that answer came this morning on my way to work. Your going to clean this universe up !

No, wipe that smirk off your face, it doesnt mean your going to be sheriff. I mean your going to be a janitor to the whole universe and clean up all the debris, derelict ships, containers and whatnot that are left lying around all over the place.

I'm sick to death of having all this debris cluttering up the space ways and making coming to work a hazard instead of a joy. Your going to clean it up for me !

We've outfitted a Disco for you with some pretty nifty software.

Your ship will be updated with the locations of all known derelict ships, and a new command has been added to take you right there so you can salvage the ship. Its up to you what you do with them, but get them off the space lanes !

You have also been given software to help you claim without leaving your ship, up to a distance of 5km.

Also, you have been entrusted with the software to automate a ship into clearing the debris in the asteroid fields. And the new advance in HQ software that allows stations to be set up within the HQ instead of complexing them.

Ok pilot, you have a lot of work to do, get out there and do it !

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

Download : http://circleofatlantis.com/games/X3/salvage.html

Install using Cycrows X Plugin Manager.
Uses 10cat/10.dat.
Copy the 00.save file in the X3 directory to your save file directory.

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

Apricot Salvage Mod.

Task 1 : Collect Derelict Ships.

The X universe is a very dangerous place. But one of its oddities is that only ships being fired apon by the player will be abandonned by their pilot. This just isnt real. In reality, all sorts of reasons would have all sorts of pilots abandonning ship on a constant basis. So with this in mind, .....

Every time the game is started, 12 derelict ships will be created in random locations with random damage and fittings. This can be altered by either copying the main setup script in the script editor a few more times to get more, or deleting a few to get less - 1 ship per script.

A new command is on the Nav menu to jump your ship to a random derelict ship. Apricot Mapping Service makes no warranty about soiled underwear should you find yourself in a sea of red dots all of a sudden. The command is rinky dink, and does not check for the existance of a jumpdrive or enough ecells. If you dont have them, you dont go anywhere, simple as that. Where you go, is entirely random ! What you do when you get there is your problem.

Task 2 : Asteroid Debris Clearing.

Since 1.4, the universe has been filled with debris that makes flying around sectors dangerous.

So your job is to assign ships to clear the debris and sell it or stockpile it.

Task 3 : Container Clearing.

There is garbage being dropped all over the universe by careless ships that manage to get themselves destroyed through sheer stupidity. Make sure it all gets collected up and disposed of efficiently.

Scripts Included :

Apricot Beamdock (Apricot's private version)
Apricot Jump to Derelict Ship
Apricot mess up the universe with derelict ships
Cycrow System Override Software Mk2
Auto Debris Harvestor v2.0 by Nividium
Install Station to PHQ by MJALowe

Mod Included :

PHQ with 50 Mil in storage space, but no blueprints.

Save Included :

00.sav

Start Position :

The save game bypasses the Aspiring Explorer Start, putting you in a Disco in CBSE, with a few extra goodies in the cargo hold. You are just 1 jump away from your first salvage operation.


Beta version and my first attempt at a spk distrubution file, so please let me know if it works ok.


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

Original OP follows :

I just want to make a quick and dirty script that will find all ships in the universe with a neutral race, and print the sector onto the logbook. Position in sector optional.

I can learn how to embellish the message later, but for now, I just need the code to just find the ships and display in the log the sector they are in.

Anyone help ? Much appreciated if you can. :)

Posted: Mon, 15. Oct 07, 10:31
by LV

Code: Select all

007   $input.array =  array alloc: size=0
008   $ships =  get ship array: of race Neutral class/type=Moveable Ship
010   
011   $as =  size of array $ships
016   
017   while $as > -1
018    $single = $ships[$as]
019    if $single -> exists
020     $sec = $single -> get sector
023      append $single to array $input.array
024      append $sec to array $input.array
028    end
029 @  = wait 1 ms
030    dec $as = 
031   end
032   

write to logbook $input.array
That will return each ship and it's sector to log

for pos use get x,y,z in second general menu (press page down 2x to find)

Posted: Mon, 15. Oct 07, 10:46
by Nividium
Here's my version of the find abandon ships code:

Code: Select all

001   $ship.array =  get ship array: of race Neutral Race class/type=Moveable Ship
002   $ship.array.size =  size of array $ship.array
003   while $ship.array.size > 0
004    dec $ship.array.size = 
005    $ship = $ship.array[$ship.array.size]
006    $x = $ship -> get x position
007    $y = $ship -> get y position
008    $z = $ship -> get z position
009    $sector = $ship -> get sector
010    write to player logbook: printf: fmt='Ship = %s, Sector = %s, X = %s, Y = %s, Z = %s', $ship, $sector, $x, $y, $z
011 @  = wait 2 ms
012   end
013   
014   
015   return null

Posted: Mon, 15. Oct 07, 11:01
by apricotslice
Thankyou :)

Posted: Mon, 15. Oct 07, 12:11
by TycHouse
Could i just point out that in LV's script the 'dec $as' statement on line 030 should be on line 018 ie before the '$single = $ships[$as]' statement.

Edit: also noticed that the 'while' statement should just be 'while $as' (or perhaps 'while $as > 0').

Reasons ? An array of 4 elements is actually element [0] - [3] therefor you need to decrement the count before you assign the ship object otherwise you are trying to perform '$single = $ships[4]' in the first iteration which is clearly wrong.

{sorry LV, not trying to insult you just thought i'd clear that up for others reading}

Posted: Mon, 15. Oct 07, 12:45
by apricotslice
This is what I hate about this editor.

I know what to put, but where do I find the stupid line ?
$ship.array = get ship array: of race Neutral Race class/type=Moveable Ship
The only thing remotely like it is in universe but logic dictates it should be in general, arrays.

But nothing seems to allow this line to be built as written.

:oops:

HELP !

This call for help was brought to you by the Apricot Salvage Service, a wholey owned subsiduary of the Apricot Mapping Service.

Posted: Mon, 15. Oct 07, 12:53
by Carlo the Curious
Further down in Universe/Sector commands.

Posted: Mon, 15. Oct 07, 12:58
by apricotslice
I found that one, but it doesnt construct the same line.

It wants a variable, so I type in ship.array, then it wants an object of some kind, and thats it. Nothing about race or class.

I cant find any other command line that has get ship array in it.

Posted: Mon, 15. Oct 07, 13:00
by Carlo the Curious
There's more than one variant in Universe commands - look harder!

I think there is an external editor around someplace, but I don't have the link.

Posted: Mon, 15. Oct 07, 13:03
by apricotslice
External editor ????????

Where, gimme gimme gimme

:)

Edit :

Yay, crowd goes wild :)

Yes it was further down. The manual didnt say there were 2 variations either. :(

Posted: Mon, 15. Oct 07, 13:30
by apricotslice
Touch down !!!!

Crowd goes absolutely berzerk !

Next problem :)

What do I change to get it to print to an external file ?

Damn thing came back with more than I expected and I really need to print them out. :)

Posted: Mon, 15. Oct 07, 13:47
by B-O'F
Hi apricotslice,

Use the command:-


write to log file #<Var/Number> append=<Var/Number> printf: fmt=<Var/String>, <Value>, <Value>, <Value>, <Value>, <Value>

instead of the:-

write to player logbook: printf: fmt=<Var/String>,<Value>,<Value>,<Value>,<Value>,<Value>

It needs a numeric input for the 'log file #<Var/Number>' - I normally use the date, like 1015.

The rest of the information can be the same as used in the write to logbook command (you can pretty it up later).

Then just alt-tab out of the game and look for 'log1015.txt' in the reunion folder - it should have all your data ready for word processing or printing.

Hope that this helps,

Boron - Ol Fh'art

Posted: Mon, 15. Oct 07, 14:04
by apricotslice
Thanks. Got that working :)

Only thing thats not working now is putting a heading and footing on it. Do I need to do that in onother script and call this one from it ?

Just putting the heading at the top and footing at the bottom printed the heading half way down the report and no footing at all.

Hey, I'm learning this ! :)

Posted: Mon, 15. Oct 07, 17:56
by B-O'F
Hi apricotslice,

Headings and footings can be handled in the same script as the rest.

script

$message1 = 'string of stuff for the heading'
$message2 = 'string of stuff for the footing'

* write the heading
* change the TRUE to FALSE to start a new log
write to log file # 1015 append=[TRUE] value= $message1

the rest of your script to write stuff out

* write the footing
write to log file # 1015 append=[TRUE] value= $message2

End of script

You can make things easier by defining $log.id = 1015, and then using $log.id instead of entering 1015 in the write to log commands - this means that you can write data from each run to a different log file just by changing the $log.id = command. This is handy if you want multiple versions.

You can prettify things by using correct spacing - this works for a log file as it is monospaced - have a quick look at Prices of all wares for examples of spacing.

Any help,

Boron - Ol Fh'art

Posted: Mon, 15. Oct 07, 22:52
by LV
TycHouse wrote:Could i just point out that...
No worries, i've written every script that i have in that format because if it aint broke......

I know how arrays work now but it's down to the fact it works for me as i always have null checks

Posted: Tue, 16. Oct 07, 00:00
by TycHouse
No worries.
There is another reason to put the DEC at the top of the loop in that you can then use the continue statement within a conditional inside the while...end loop:

Code: Select all

001 $wareArray = find flying ware: sector....... etc
002 $wareCount = size of array $wareArray
003 while $wareCount
004   dec $wareCount
005   @ = wait 100ms
006   $ware = $wareArray[$wareCount]
007   skip if $ware == Energy Cells
008     continue
009   * we now know the ware we are dealing with is energy cells
010   * ...... do what you will with them !
....
026 end
027
028 return null
Just a quick example but you could easily use it to skip over if say the ware was illegal or not something we could carry etc, makes the coding much simpler.

Posted: Wed, 17. Oct 07, 11:04
by apricotslice
Thaks for all the help, that was very successful, albiet looking very rough.

For lesson 2 ...... :)

I'd like to vary the script so that it finds one random ship, and then jumps you to that sector and moves you to that position.

I'm not concerned with the niceties of checking for a jumpdrive, nav1 or ecells, if the ship doesnt have any, if doesnt go anywhere.

But I thought it would be nice for the ship to auto go where I want to go, and give me a nice surprise when it gets there. :)

Any suggestions ?

Edit : What is the name of the script that does the jump to position command ?

Edit 2 : Ok, I found that, but I'm having trouble putting a command in. I'm using 564 which doesnt seem to conflict with anything, but the command name doesnt appear in the commands list. I copied what has worked before, so its really weird that it doesnt work this time. Any clues ?

Edit 3 :
YYYYYYYYYYYYYYYYYYYEEEEEEEEEEEEEEEEEEEEEE
HHHHHHHHHHHHHHHHHHHHHHHHHHAAAAAAAAAAAAAAAAAAAAAAAAAA

Crowd goes absolutely bananas :)

I figured it out on my own !

Now I get a nice list of where the abanndonned ships are and the ship automatically jumps to 2km from the last one on the list. :)

Maybe I dont need the list now :gruebel:

Posted: Wed, 17. Oct 07, 13:08
by eladan
Congrats apricotslice! Have you caught the scripting bug now? :wink:

Posted: Wed, 17. Oct 07, 14:31
by apricotslice
Well as an ex-programmer, I never lost it, but up until now the editor has confounded me ! I've previously been able to just make minor cosmetic changes to existing scripts.

I'm still not ready for a bells and whistles script suite, but getting my own first script to work is definitely a step in the right direction. :)

Posted: Fri, 19. Oct 07, 08:11
by apricotslice
I went ahead and did a mod out of all that :)

Thanks for those who helped in the scripting.