Skip to content

Instantly share code, notes, and snippets.

@joshk6656
Created June 3, 2020 03:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshk6656/8bc627a28eab27f6924844685227863f to your computer and use it in GitHub Desktop.
Save joshk6656/8bc627a28eab27f6924844685227863f to your computer and use it in GitHub Desktop.
_addon.name = 'nyzullamp'
_addon.version = '1.00'
_addon.author = 'joshk6656'
_addon.command = 'nyzullamp'
require 'pack'
require('chat')
packets,fields = require 'packets'
parseincoming = false
clicklamp = false
mode = 'up'
function click_NPC_By_Index(index)
targ = windower.ffxi.get_mob_by_index(index)
if targ then
windower.packets.inject_outgoing(0x1A,string.char(0x1A,8,0,0)..'I':pack(targ.id)..'H':pack(targ.index)..string.char(0)..'I':pack(0)..string.char(0):rep(12))
end
end
windower.register_event('incoming text',function (original, modified, color)
nocolorsorig = string.strip_format(original)
if string.find(nocolorsorig, 'objective complete.') then
clicklamp = true
elseif string.find(nocolorsorig, 'Transfer complete.') then
clicklamp = false
elseif string.find(nocolorsorig, 'exitonnext') then
windower.add_to_chat(8,'changed to exit on next lamp')
mode = 'exit'
end
return modified,color
end)
function findvalidlamp()
local mob_array = windower.ffxi.get_mob_array()
for str_index,mob in pairs(mob_array) do
if mob then
if mob.valid_target and mob.name == 'Rune of Transfer' and mob.is_npc and math.sqrt(mob.distance)<6 then
return mob.index
end
end
end
return nil
end
windower.register_event('incoming chunk',function(id,original,modified,is_injected,is_blocked)
if id == 0x34 and clicklamp then
local p = packets.parse('incoming',original)
local mob = windower.ffxi.get_mob_by_id(original:unpack('I',5))
if mob and mob.name == "Rune of Transfer" then
clicklamp = false
windower.add_to_chat(8,'Injecting menu')
local inject = packets.new("outgoing", 0x5b, {
['Target'] = p['NPC'],
['Option Index'] = 0x00,
['Target Index'] = p['NPC Index'],
['Zone'] = p['Zone'],
['Automated Message'] = true,
['Menu ID'] = p['Menu ID']
})
packets.inject(inject)
if mode == 'up' then
optionindex = 0x02
else
optionindex = 0x01
end
local inject = packets.new("outgoing", 0x5b, {
['Target'] = p['NPC'],
['Option Index'] = optionindex,
['Target Index'] = p['NPC Index'],
['Zone'] = p['Zone'],
['Automated Message'] = false,
['Menu ID'] = p['Menu ID']
})
packets.inject(inject)
return true
end
end
end)
windower.register_event('zone change', function(new_zone, old_zone)
mode = 'up'
clicklamp = false
end)
windower.register_event('addon command', function (command,...)
if command == 'changemode' then
if mode == 'up' then
windower.add_to_chat(8,'changed mode to exit')
mode = 'exit'
else
windower.add_to_chat(8,'changed mode to up')
mode = 'up'
end
elseif command == 'up' then
clicklamp = true
end
end)
function mainthread()
while true do
if clicklamp then
local lamp = findvalidlamp()
if lamp then
windower.add_to_chat(8,'clicking lamp')
click_NPC_By_Index(lamp)
coroutine.sleep(3)
end
end
coroutine.sleep(.1)
end
end
co = coroutine.create(mainthread())
coroutine.start(co,0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment