Signup Now
Results 1 to 2 of 2
  1. #1
    Free User henqqq's Avatar
    Join Date
    Nov 2014
    Posts
    29
    Reputation
    10
    Rep Power
    0

    Show pickable tiles

    this is a simple HUD that shows pickables tiles
    p.s: I used some functions from ShowSpecialAreas HUD.

    pickable.jpg

    init start

    local worldWidth, worldHeight, x, y, z, width, height, avoidance, name, policy, areaType
    local specialAreaRect = {}
    local innerRect = {}

    function gettilepos(x, y, z)
    local tile = getobjectarea(x, y, z)

    if tile == nil then
    local xDiff, yDiff = x - $posx, y - $posy
    if math.abs($posx - x) <= 7 then
    tile = getobjectarea(x, $posy, $posz)
    xDiff = 0
    elseif math.abs($posy - y) <= 5 then
    tile = getobjectarea($posx, y, $posz)
    yDiff = 0
    else
    tile = getobjectarea($posx, $posy, $posz)
    end

    -- Some strange stuff happens when you go from 0 to -1, so I'm
    -- adding this as a precaution.
    if tile ~= nil then
    local width, height = $worldwin.width, $worldwin.height

    tile.left = tile.left + (width * xDiff)
    tile.right = tile.right + (width * xDiff)
    tile.centerx = tile.centerx + (width * xDiff)
    tile.top = tile.top + (height * yDiff)
    tile.bottom = tile.bottom + (height * yDiff)
    tile.centery = tile.centery + (height * yDiff)
    end
    end

    return tile
    end

    local function getAreaRect(x, y, w, h)
    local ret = {x = 0, y = 0, w = 0, h = 0}

    local topLeftTilePos = gettilepos(x, y, $posz)
    local botRightTilePos = gettilepos(x + w - 1, y + h - 1, $posz)

    if topLeftTilePos and botRightTilePos then
    ret.x = math.max(topLeftTilePos.left, 0)
    ret.y = math.max(topLeftTilePos.top, 0)
    ret.w = math.min(botRightTilePos.right, worldWidth) - ret.x
    ret.h = math.min(botRightTilePos.bottom, worldHeight) - ret.y
    end

    return ret
    end

    local function drawInnerRect(areaType, x, y, width, height)
    innerRect = {w = 0, h = 0}
    if areaType == 'Square (Border Only)' then
    innerRect = getAreaRect(x + 1, y + 1, width - 2, height - 2)
    elseif areaType == 'Square (Double Border)' then
    innerRect = getAreaRect(x + 2, y + 2, width - 4, height - 4)
    end

    if innerRect.w > 0 and innerRect.h > 0 then
    setfillstyle('color', 0xFF000000)
    drawroundrect(innerRect.x, innerRect.y, innerRect.w, innerRect.h, 10, 10)
    end
    end

    useworldhud()

    init end

    worldWidth, worldHeight = $worldwin.width - 2, $worldwin.height - 2
    for i=-8,9 do
    for j=-6,7 do
    local tile = gettile($posx + i, $posy + j, $posz)

    for k=1, tile.itemcount do
    local tileid = tile.item[k].id
    if (tileid == 372) then

    local test = gettilepos($posx + i, $posy + j, $posz)

    local xpos = tonumber($posx + i)
    local ypos = tonumber($posy + j)

    local retangulo = getAreaRect(xpos, ypos, 3, 3)
    --print(retangulo)

    setfillstyle('color', 0xFA0505)
    drawroundrect(retangulo.x, retangulo.y, 50, 50, 4, 4)

    print('found a pickable id on: ' ..'x: ' .. ($posx + i) .. ' y:' .. ($posy + j) )
    end
    end
    end
    end
    Last edited by Borges; 11-09-2015 at 12:00 PM. Reason: lua code

  2. #2
    Free User ozzix's Avatar
    Join Date
    Jan 2014
    Location
    Sweden
    Posts
    4,771
    Reputation
    151
    Rep Power
    31
    nice

    Level Latest Scripts
    250+
    Oramond Sewers [MAGE |RP X1 | RP X2 |RP X3|EK X2 | EK X1]
    200+
    Banuta X2 [MAGE | RP]
    280+
    Roshamuul Mountain [RP]
    280+
    Ferumbras Lair [RP]
    250+
    Roshamuul North Silencers [RP]

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •