Advertisement
Guest User

Targetinfo.Lua

a guest
Feb 22nd, 2017
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.78 KB | None | 0 0
  1. _addon.name = 'TargetInfo'
  2. _addon.author = 'Arcon'
  3. _addon.version = '1.0.1.0'
  4. _addon.language = 'English'
  5.  
  6. require('luau')
  7. texts = require('texts')
  8.  
  9. -- Config
  10.  
  11. defaults = {}
  12. defaults.ShowHexID = true
  13. defaults.ShowFullID = true
  14. defaults.ShowSpeed = true
  15. defaults.ShowClaimName = true
  16. defaults.ShowClaimID = true
  17. defaults.ShowTargetName = true
  18. defaults.ShowTargetID = true
  19. defaults.display = {}
  20. defaults.display.pos = {}
  21. defaults.display.pos.x = 0
  22. defaults.display.pos.y = 0
  23. defaults.display.bg = {}
  24. defaults.display.bg.red = 0
  25. defaults.display.bg.green = 0
  26. defaults.display.bg.blue = 0
  27. defaults.display.bg.alpha = 102
  28. defaults.display.text = {}
  29. defaults.display.text.font = 'Consolas'
  30. defaults.display.text.red = 255
  31. defaults.display.text.green = 255
  32. defaults.display.text.blue = 255
  33. defaults.display.text.alpha = 255
  34. defaults.display.text.size = 12
  35.  
  36. settings = config.load(defaults)
  37.  
  38. text_box = texts.new(settings.display, settings)
  39.  
  40. -- Constructor
  41.  
  42. initialize = function(text, settings)
  43.     local properties = L{}
  44.     if settings.ShowFullID then
  45.         properties:append('ID:            ${full||%08s}')
  46.     end
  47.     if settings.ShowHexID then
  48.         properties:append('Hex ID:        ${hex||%.8X}')
  49.     end
  50.     if settings.ShowSpeed then
  51.         properties:append('Speed:           ${speed}')
  52.     end
  53.     if settings.ShowClaimName then
  54.         properties:append('Claim: ${claim_name||%16s}')
  55.     end
  56.     if settings.ShowClaimID then
  57.         properties:append('Claim ID: ${claim_id||%13s}')
  58.     end
  59.     if settings.ShowTargetName then
  60.         properties:append('Target: ${target_name||%15s}')
  61.     end
  62.     if settings.ShowTargetID then
  63.         properties:append('Target ID: ${target_id||%12s}')
  64.     end
  65.  
  66.     text:clear()
  67.     text:append(properties:concat('\n'))
  68. end
  69.  
  70. text_box:register_event('reload', initialize)
  71.  
  72. windower.register_event('incoming chunk',function(id)
  73.     if id == 0xB and text_box:visible() then
  74.         zoning_bool = true
  75.     elseif id == 0xA and zoning_bool then
  76.         zoning_bool = nil
  77.     end
  78. end)
  79.  
  80. -- Events
  81.  
  82. windower.register_event('prerender', function()
  83.     local mob = windower.ffxi.get_mob_by_target('st') or windower.ffxi.get_mob_by_target('t')
  84.     local player = windower.ffxi.get_player()
  85.     if zoning_bool then
  86.         text_box:hide()
  87.         return
  88.     end
  89.     if mob and mob.id > 0 then
  90.         local mobclaim = windower.ffxi.get_mob_by_id(mob.claim_id)
  91.         local target = windower.ffxi.get_mob_by_index(mob.target_index)
  92.         local info = {}
  93.         info.hex = mob.id % 0x100000000
  94.         info.full = mob.id
  95.         local speed
  96.         if mob.status == 5 or mob.status == 85 then
  97.             speed = (100 * (mob.movement_speed / 4)):round(2)
  98.         else
  99.             speed = (100 * (mob.movement_speed / 5 - 1)):round(2)
  100.         end
  101.         info.speed = (
  102.             speed > 0 and
  103.                 '\\cs(0,255,0)' .. ('+' .. speed):lpad(' ', 5)
  104.             or speed < 0 and
  105.                 '\\cs(255,0,0)' .. speed:string():lpad(' ', 5)
  106.             or
  107.                 '\\cs(102,102,102)' .. ('+' .. speed):lpad(' ', 5)) .. '%\\cr'
  108.         if mob.id == player.id then
  109.             info.claim_name = mobclaim and mobclaim.name or 'None'
  110.             info.claim_id = mobclaim and mobclaim.id or 'None'
  111.             info.target_name = mob and mob.name or 'None'
  112.             info.target_id = mob and mob.id or 'None'
  113.         elseif mobclaim and mobclaim.id > 0 then
  114.             info.claim_name = mobclaim and mobclaim.name or 'None'
  115.             info.claim_id = mobclaim and mobclaim.id or 'None'
  116.             info.target_name = target and target.name or 'None'
  117.             info.target_id = target and target.id or 'None'
  118.         elseif target and target.id > 0 then
  119.             info.claim_name = mobclaim and mobclaim.name or 'None'
  120.             info.claim_id = mobclaim and mobclaim.id or 'None'
  121.             info.target_name = target and target.name or 'None'
  122.             info.target_id = target and target.id or 'None'
  123.         else
  124.             info.claim_name = mobclaim and mobclaim.name or 'None'
  125.             info.claim_id = mobclaim and mobclaim.id or 'None'
  126.             info.target_name = target and target.name or 'None'
  127.             info.target_id = target and target.id or 'None'
  128.         end
  129.         text_box:update(info)
  130.         text_box:show()
  131.     else
  132.         text_box:hide()
  133.     end
  134. end)
  135.  
  136. --[[
  137. Copyright © 2013-2015, Windower
  138. All rights reserved.
  139. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
  140.     * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  141.     * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  142.     * Neither the name of Windower nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
  143. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Windower BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  144. ]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement