Page 3 of 4

Re: [WIP] CargoScanner.OXP

Posted: Tue May 17, 2011 7:40 pm
by JensAyton
Okti wrote:
That is right Thargoid, I only scan for a display name "Cargo container", so most of the ones spawned from other OXP's will not be scanned.
I’d suggest checking for a property like ship.$okti_cargoDescription first (or ship.scriptInfo.okti_cargoDescription; that can be set in shipdata.plist, but is read-only). This way, OXPs defining custom pods can choose to integrate with your scanner.
Smivs wrote:
But by that token, most things would be illegal. Aspirin is toxic to Feline species for example.
It’s toxic to humans. As is water. :-)

Re: [WIP] CargoScanner.OXP

Posted: Tue May 17, 2011 7:45 pm
by Commander McLane
Switeck wrote:
Commander McLane wrote:
This is also why your scooped escape pods are unloaded automatically before anything else happens, whether you want it or not. Actually, the escape pod handling is another reason why your cargo cannot remain on your ship while you're docked. The Space Farers' Guild gets furious just from the mere idea that a scooped escape pod could be withheld from the port authorities in an attempt to enslave the pilot.
I wish that were true...I'm often caught leaving the station with a ton of "slaves" thanks to an escape pod that lacked a named pilot.
Yes, sometimes a blind passenger, or someone unknown to the insurance company has forced entry into the escape pod. Naturally the insurance companies want to strongly discourage this apparent breach of their contracts. What better way than to have those fraudsters publicly sold into slavery? :twisted:

Re: [WIP] CargoScanner.OXP

Posted: Tue May 17, 2011 7:49 pm
by Okti
Ahruman wrote:
Okti wrote:
That is right Thargoid, I only scan for a display name "Cargo container", so most of the ones spawned from other OXP's will not be scanned.
I’d suggest checking for a property like ship.$okti_cargoDescription first (or ship.scriptInfo.okti_cargoDescription; that can be set in shipdata.plist, but is read-only). This way, OXPs defining custom pods can choose to integrate with your scanner.
Smivs wrote:
But by that token, most things would be illegal. Aspirin is toxic to Feline species for example.
It’s toxic to humans. As is water. :-)
Is there a way script wise obtaining cargo information?

Re: [WIP] CargoScanner.OXP

Posted: Tue May 17, 2011 8:12 pm
by JensAyton
Okti wrote:
Is there a way script wise obtaining cargo information?
Hrm. Maybe I should have read the top of the thread properly before acknowledging its existence. :-)

No, there isn’t. The contents of a cargo pod can be represented in several different ways and is notionally determined at scooping time, although this doesn’t seem to serve any real purpose except for the scripted case, and there should probably be a nominal type (like “Equipment”, “People” etc.) for scripted pods.

Issue #13 for Oolite 2.

Re: [WIP] CargoScanner.OXP

Posted: Tue May 17, 2011 8:22 pm
by Okti
Ahruman wrote:
Okti wrote:
Is there a way script wise obtaining cargo information?
Hrm. Maybe I should have read the top of the thread properly before acknowledging its existence. :-)

No, there isn’t. The contents of a cargo pod can be represented in several different ways and is notionally determined at scooping time, although this doesn’t seem to serve any real purpose except for the scripted case, and there should probably be a nominal type (like “Equipment”, “People” etc.) for scripted pods.

Issue #13 for Oolite 2.
So I will prefer to release a proper version with Oolite 2, for the time being this OXP gives a chance not to scoop slaves and leave them to dye for the commanders :mrgreen:

Re: [WIP] CargoScanner.OXP

Posted: Tue Jul 22, 2014 9:58 pm
by timer
Hi, Okti!

Can I suggest u new script version with using target.commodity property? It looks well working in 1.77+

main content:

Code: Select all

this.shipTargetAcquired = function(target) {
    if ( ! target.isCargo || target.isPiloted
         || player.ship.equipmentStatus('EQ_CARGO_SCANNER') !== 'EQUIPMENT_OK' ) {
        return;
    }

    if ( target.commodity !== 'goods' ) {
        var ca = +target.commodityAmount;
        target.displayName = 'Cargo container (' + displayNameForCommodity( target.commodity )
                + ( ca === 1 ? '' : ' ['+ca+']' ) + ')';
    }
    else {
        target.displayName = 'Cargo container (Unknown/Broken RFID)';
    }
};

Re: [WIP] CargoScanner.OXP

Posted: Tue Jul 29, 2014 10:05 am
by timer
I am going to create oxz version (with tiny code update) and create wiki page for this very good expansion - any objections? :)

PS I am do not claim to change ownership, Okti forever ;)

Re: [WIP] CargoScanner.OXP

Posted: Tue Jul 29, 2014 10:46 am
by Wildeblood
timer wrote:
I am going to create oxz version (with tiny code update) and create wiki page for this very good expansion - any objections? :)
Good idea. It's an obvious piece of equipment that should be in the game. This line:

Code: Select all

target.displayName = 'Cargo container (' + displayNameForCommodity( target.commodity )
would be better as:

Code: Select all

target.displayName += " " + displayNameForCommodity( target.commodity )

Re: [WIP] CargoScanner.OXP

Posted: Tue Jul 29, 2014 10:52 am
by timer
Yep, this version of name (with += ) was my first too, but it accumulate and after second targeting - you has "Cargo Conatainer Cargo Conatainer (Alloys)"

Maybe later I decide this problem and use src displayName, but now... :)

thanks for answer!

Re: [WIP] CargoScanner.OXP

Posted: Tue Jul 29, 2014 11:19 am
by Wildeblood
Put the commodity type into target.shipUniqueName and let Oolite handle merging the displayName.

Re: [WIP] CargoScanner.OXP

Posted: Tue Jul 29, 2014 11:27 am
by Zireael
Great to see this being OXZified.

Re: [WIP] CargoScanner.OXP

Posted: Tue Jul 29, 2014 11:32 am
by timer
Wildeblood wrote:
Put the commodity type into target.shipUniqueName and let Oolite handle merging the displayName.
great! Thanks!

Re: [WIP] CargoScanner.OXP

Posted: Tue Jul 29, 2014 12:24 pm
by timer
Done. Can anybody test it?

And also review wiki page http://wiki.alioth.net/index.php/Cargo_Scanner_OXP

english is not my native )

Re: [WIP] CargoScanner.OXP

Posted: Thu Jul 31, 2014 8:49 am
by timer
Smivs, mike! I took your description of the device and put it in the wiki: http://wiki.alioth.net/index.php/Cargo_ ... P#Overview

Re: [WIP] CargoScanner.OXP

Posted: Thu Feb 02, 2017 12:50 pm
by Rustem
No error - invalid arguments with part:

Code: Select all

    if ( target.commodity !== 'goods' ) {
        if ( ! target.shipUniqueName ) {
            var cn = target.commodity;
            var ca = +target.commodityAmount; //log(this.name, this.name+" : target : "+cn+"["+ca+"]");
            if (cn) target.shipUniqueName = displayNameForCommodity( cn )
                    + ( ca === 1 ? '' : ' ['+ca+']' )
            else {
                    target.shipUniqueName = 'Broken RFID'; // or 'Unknown RFID' /surprise-cargo /cloak
            }
        }
    }
Check with cargo : cloak-device and random cargo, no output error.
Full tweak