Set Weapon Condition and get count of ammo in Ammo Box

Arszi
Scavenger
Posts: 16
Joined: 04 Jan 2018, 06:45

Set Weapon Condition and get count of ammo in Ammo Box

Postby Arszi » 04 Jan 2018, 07:53

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?

sLoPpYdOtBiGhOlE
Scavenger
Posts: 35
Joined: 12 Jun 2017, 23:44

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

Postby sLoPpYdOtBiGhOlE » 06 Jan 2018, 00:44

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)
Last edited by sLoPpYdOtBiGhOlE on 06 Jan 2018, 22:57, edited 1 time in total.

Arszi
Scavenger
Posts: 16
Joined: 04 Jan 2018, 06:45

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

Postby Arszi » 06 Jan 2018, 14:12

Thank you very much for your reply! It worked.


Return to “General Discussion”

Who is online

Users browsing this forum: Bing [Bot] and 2 guests