Page 1 of 1

New equipment migration questions

Posted: Wed Jul 09, 2014 1:40 am
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.

Re: New equipment migration questions

Posted: Wed Jul 09, 2014 2:14 am
by walterar
ship:GetEquipFree("laser") and ship:GetEquipSlotCapacity("laser") return 0 in all circumstances.

Re: New equipment migration questions

Posted: Wed Jul 09, 2014 7:55 am
by impaktor
Might be worth while to add examples to the existing wiki page:
http://pioneerwiki.com/wiki/Lua-based_equipment

Re: New equipment migration questions

Posted: Wed Jul 09, 2014 8:30 am
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]

Re: New equipment migration questions

Posted: Wed Jul 09, 2014 9:05 am
by walterar
ship:GetEquipFree("laser_front") and ship:GetEquipSlotCapacity("laser_rear") return 0 in all circumstances.

Re: New equipment migration questions

Posted: Wed Jul 09, 2014 11:02 am
by walterar
Rectified: laser_front seems to work. I will check better.

Re: New equipment migration questions

Posted: Wed Jul 09, 2014 11:03 am
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.