New equipment migration questions

Post Reply
jpab
Posts: 77
Joined: Thu Jul 18, 2013 12:30 pm
Location: UK

New equipment migration questions

Post by jpab »

I'm creating this thread for questions about how to migrate Lua scripts to work with the new equipment code.

-----

First question is from walterar, and is taken from issue #3027:
I'm not sure how to migrate this, to new code:

Code: Select all

if (ship:GetEquipFree ("LASER") < ShipDef [ship.shipId] equipSlotCapacity.LASER)
Some idea?
Something like this should work:

Code: Select all

if (ship:GetEquipFree("laser_front") < ship:GetEquipSlotCapacity("laser_front"))
Slot "laser_rear" should also work.

Edit: Fix example, which used wrong slot name.
walterar
Posts: 95
Joined: Sat Sep 14, 2013 4:48 pm

Re: New equipment migration questions

Post by walterar »

ship:GetEquipFree("laser") and ship:GetEquipSlotCapacity("laser") return 0 in all circumstances.
impaktor
Posts: 1008
Joined: Fri Dec 20, 2013 9:54 am
Location: Tellus
Contact:

Re: New equipment migration questions

Post by impaktor »

Might be worth while to add examples to the existing wiki page:
http://pioneerwiki.com/wiki/Lua-based_equipment
impaktor
Posts: 1008
Joined: Fri Dec 20, 2013 9:54 am
Location: Tellus
Contact:

Re: New equipment migration questions

Post by impaktor »

Code: Select all

<laarmen> For the forum thread on Lua equipment, walterar needs to use the
          laser_front and /or laser_rear  [10:10]
<laarmen> Slots. 
<laarmen> Also, it might be a good idea to error out whenever the slot name
          doesn't exist.   [10:17]
walterar
Posts: 95
Joined: Sat Sep 14, 2013 4:48 pm

Re: New equipment migration questions

Post by walterar »

ship:GetEquipFree("laser_front") and ship:GetEquipSlotCapacity("laser_rear") return 0 in all circumstances.
walterar
Posts: 95
Joined: Sat Sep 14, 2013 4:48 pm

Re: New equipment migration questions

Post by walterar »

Rectified: laser_front seems to work. I will check better.
laarmen
Posts: 34
Joined: Fri Jul 05, 2013 8:49 am

Re: New equipment migration questions

Post by laarmen »

Well, it works for me (tested on the latest windows build)

To be clearer, the laser_front and laser_rear slots are different slots. The first one is for the weapon that shoots forward, the second one for the weapon shooting backwards. Thus, most ships will always have GetEquipSlotCapacity("laser_rear") at 0, and the starting ship on Earth will have GetEquipFree("laser_front") at 0 as well since it can only be fitted one gun at the front. But GetEquipSlotCapacity("laser_front") will usually be 1, except for ships such as the lunar shuttle.
Post Reply