Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.9 kB
3
Indexable
-- Auto drop item on specific position
-- Tags: hold flower sqm

-- vBot scripting services: F.Almeida#8019
-- if you like it, consider making a donation:
-- https://www.paypal.com/donate/?business=8XSU4KTS2V9PN&no_recurring=0&item_name=OTC+AND+OTS+SCRIPTS&currency_code=USD


-- START CONFIG:
local itemIds = {2983,2984,2985}
-- YOU CAN USE ABSOLUTE POSITIONS, RELATIVE POSITIONS OR BOTH
local absolutePositions = {{x=33229,y=32392,z=7},{x=33234,y=32391,z=7}}
local relativePositions = {"south","southwest"}
-- END CONFIG



-- Don't edit below this line unless you know what you're doing.
-- Posible relative positions:
local relative = {
  center = {0,0},
  south = {0,1},
  north = {0,-1},
  west = {-1,0},
  east = {1,0},
  southeast = {1,1},
  northeast = {1,-1},
  southwest = {-1,1},
  northwest = {-1,-1},
}

local dropitem = macro(200,"Hold Flower",function()
  local positions = {}
  for p, pos in pairs(absolutePositions) do
    table.insert(positions,pos)
  end
  for o, off in pairs(relativePositions) do
    if relative[off:lower()] then
      local p = pos()
      local off = relative[off:lower()]
      local pos = {x = p.x + off[1] , y = p.y + off[2] , z = p.z}
      table.insert(positions,pos)
    end
  end

  for p, pos in pairs(positions) do
    local tile = g_map.getTile({x=pos.x,y=pos.y,z=pos.z})
    local find = findPath(player:getPosition(), tile:getPosition(), 7, {ignoreNonPathable=true})
    if tile and find then
      local topUse = tile:getTopUseThing()
      if topUse then
        local topId = topUse:getId()
        if not table.find(itemIds,topId) then
          for i, item in pairs(itemIds) do
            local dropItem = findItem(item)
            if dropItem then
              return g_game.move(dropItem,pos,1)
            end
          end
        end
      end
    end
  end
end)