Advertisement
w9s66v09c8x5o1fl3p0

Rifbot Small Stone Picker

Jan 11th, 2019
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.01 KB | None | 0 0
  1. --[[
  2.     Script Name:        Small Stone Picker
  3.     Description:        Pickup Small stones when amount on ground reach X. Range 1sqm
  4.     Author:             Ascer - example
  5. ]]
  6.  
  7.  
  8. -- LOCAL CONFIG:
  9.  
  10. local MAIN_DELAY = {1500, 2700}     -- Random delay in miliseconds between actions.
  11. local PICKUP_ID = 1781              -- Small Stone ID, 3277 -> spear id if someone need.
  12. local PICKUP_AMOUNT = {1, 6}        -- Random amount. We don't wanna pickup every single stone.
  13. local HAND = "right"                -- Hand to pickup, type: "left" for right hand.
  14. local ITEM_WEIGHT = 20              -- Weight in oz. single stone to calculate real pickup amount 20 for spear.
  15. local RANDOM_EACH_LOOP = true       -- Calculate random items to pickup each loop = true or just once until reach ground amount then next = false
  16.  
  17. -- DON'T EDIT BELOW THIS LINE
  18.  
  19. local randomAmount = -1
  20.  
  21. Module.New("Small Stone Picker", function (mod)
  22.     if Self.isConnected() then
  23.        
  24.         local cap = Self.Capity()
  25.         local hand = SLOT_WEAPON
  26.        
  27.         if string.lower(HAND) == "left" then -- get hand
  28.             hand = SLOT_SHIELD
  29.         end
  30.  
  31.         if (randomAmount < 0 and not RANDOM_EACH_LOOP) or RANDOM_EACH_LOOP then -- set random amount
  32.             randomAmount = math.random(PICKUP_AMOUNT[1], PICKUP_AMOUNT[2])
  33.         end
  34.  
  35.         if (cap - 1) > ITEM_WEIGHT then
  36.             local map = Map.getArea(1) -- load map with 1 sqm range
  37.             for i, square in pairs(map) do
  38.                 local sqareItems = square.items
  39.                 for j, item in pairs(sqareItems) do
  40.                     if item.id == PICKUP_ID then
  41.                         if item.count < randomAmount then
  42.                             break -- end loop cuz no enough items
  43.                         else
  44.                             local maxPickup = math.floor((cap - 1)/ITEM_WEIGHT) -- calculate amount to pickup
  45.                             local toPickup = item.count
  46.                             if maxPickup < item.count then
  47.                                 toPickup = maxPickup
  48.                             end
  49.  
  50.                             -- Pickup item
  51.                             Self.EquipItemFromGround(hand, square.x, square.y, square.z, item.id, toPickup)
  52.  
  53.                             -- set random to -1
  54.                             randomAmount = -1
  55.  
  56.                             break
  57.                         end
  58.                     end
  59.                 end        
  60.             end
  61.         end
  62.     end    
  63.     mod:Delay(MAIN_DELAY[1], MAIN_DELAY[2])
  64. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement