Page 1 of 1

Set Weapon Condition and get count of ammo in Ammo Box

Posted: 04 Jan 2018, 07:53
by Arszi
Hello.

I would like to modify the weapons conditions by script, but I wasn't able to find any solution.

The Set_Condition()function is not defined for the weapon objects, and the .condition property is read-only. I have similar issue with the outfits.

Regarding ammo boxes in the inventory, how could I get, how much ammo is in the box? I find absolutely nothing in the lua helper for this.

Is it even possible to achieve these things from scripts?

Re: Set Weapon Condition and get count of ammo in Ammo Box

Posted: 06 Jan 2018, 00:44
by sLoPpYdOtBiGhOlE
I get/set condition on my slot weapons example:

Code: Select all

for i = 2,3 do
   local wpn = db.actor:item_in_slot(i)
   if (wpn) then
      if (wpn:condition() < 1) then
         wpn:set_condition(1)
      end
   end
end


You can do the same thing with iterate_inventory() function
Add a weapon check in the iterate function, and get/set condition example:

Code: Select all

local function itr(npc,itm)
   if (IsWeapon(itm)) then
      if (itm:condition() < 1) then
         itm:set_condition(1)
      end
   end
end
db.actor:iterate_inventory(itr,db.actor)

Re: Set Weapon Condition and get count of ammo in Ammo Box

Posted: 06 Jan 2018, 14:12
by Arszi
Thank you very much for your reply! It worked.