AtomicTorch Studio Forums

VoidExpanse => Modding info => Topic started by: Afaut on August 23, 2017, 05:31:34 AM

Title: Problem with script
Post by: Afaut on August 23, 2017, 05:31:34 AM
Hi, i'm working on a new mod, a device to restore ammunition it work but i have a problem

i've this
var ballisticWeapons = ship.GetWeaponsOfType(args.ship_id, 2);

   
   

//check weapon
if (ballisticWeapons == null)
    {
ship.DeviceDeactivate(args.ship_id, args.slot_id, true);
        game.SendNotificationError(game.GetShipOwner(args.ship_id), "No Ballistic Weapon"); // Repair is not required: Repair is not required.
        return;
    }


not working, the game just ignore the if.
i've tried if (ballisticWeapons == undefined)
if (!ballisticWeapons )
and nothing work.
Is someone have an idea why it's not working?
Title: Re: Problem with script
Post by: ai_enabled on August 23, 2017, 05:35:37 AM
Hello!

it always returns an array of IDs (weapon items IDs).
If there are no ballistic weapons, the array will be empty.
So you can simply check the array length: if (ballisticWeapons.length == 0)...

Regards!
Title: Re: Problem with script
Post by: Afaut on August 23, 2017, 05:53:34 AM
i'll try and i'll tell you if it work.
Edit: It work! thank you, i don't know why in specialobject.js if (ballisticWeapons == null) work and not in my script but now it work
Title: Re: Problem with script
Post by: Teerawut on October 29, 2017, 10:06:34 PM
I'm looking for a solution to the problem with script.sbobet (http://www.fastdetroitgaragedoor.com/sbobet-club/)
Title: Re: Problem with script
Post by: ai_enabled on October 29, 2017, 10:09:01 PM
@Teerawut, ok, post it here and we will try to help!