Pickup ammo from floor
keywords: refill ammo, refill arrow, refill bolts, pickup ammo, pickup arrow, pickup bolts, take bolts, take ammo, take arrow, floor, ground
local MINIMUM_CAP = 100 -- The minimum amount of capacity that you want to have.
local AMMO = 'bolt' -- Ammo NAME or ID
local AMMO_OZ = 0.8 -- Ammo unit weight.
local AMMO_MAX_AMOUNT = 10 -- Max. amount that you wanna carry.
local AMMO_GROUND_CONTAINER = 'bag' -- Ammo's container on FLOOR.
local AMMO_GROUND_LOCATION = { X = 12345, Y = 12345, Z = 7 } -- Ammo's location on FLOOR.
local AMMO_CONTAINER = 'red backpack' -- Container that AMMO will be moved to.
local pickup_count = math.max(0, (AMMO_MAX_AMOUNT - itemcount(AMMO, AMMO_CONTAINER, true)))
if pickup_count > 0 then
local max_capacity = math.floor((cap() - MINIMUM_CAP) / AMMO_OZ)
if pickup_count > max_capacity then
pickup_count = max_capacity
end
if pickup_count > 100 then
pickup_count = 100
end
if pickup_count > 0 then
local AMMO_ID = itemid(AMMO)
while pickup_count > 0 do
local item_tile = topitem(AMMO_GROUND_LOCATION.X, AMMO_GROUND_LOCATION.Y, AMMO_GROUND_LOCATION.Z, false)
if item_tile.id == AMMO_ID then
if pickup_count >= item_tile.count or pickup_count > 100 then
pickup_count = 100
end
moveitems(AMMO_ID, AMMO_CONTAINER, AMMO_GROUND_CONTAINER, pickup_count)
wait(1000)
pickup_count = math.max(0, (AMMO_MAX_AMOUNT - itemcount(AMMO, AMMO_CONTAINER, true)))
max_capacity = math.floor((cap() - MINIMUM_CAP) / AMMO_OZ)
if pickup_count > max_capacity then
pickup_count = max_capacity
end
if pickup_count > 100 then
pickup_count = 100
end
else
break
end
end
end
end
keywords: refill ammo, refill arrow, refill bolts, pickup ammo, pickup arrow, pickup bolts, take bolts, take ammo, take arrow, floor, ground