Skip to content

Instantly share code, notes, and snippets.

@gpedro
Created August 2, 2020 22:41
Show Gist options
  • Save gpedro/2ba6515f1f78699d853cc0dc887f8881 to your computer and use it in GitHub Desktop.
Save gpedro/2ba6515f1f78699d853cc0dc887f8881 to your computer and use it in GitHub Desktop.
auto equip set for otcv8
autoEquipWidgets = {}
local gpAutoEquipSet = addTab("EquipSet")
local slots = 4
for slot = 1, slots do
autoEquipWidgets[slot] = {
head = {},
armor = {},
legs = {},
boots = {}
}
local headParams = { on = false, slot = 1, title = string.format("Slot Head %d", slot) }
autoEquipWidgets[slot].head = UI.TwoItemsAndSlotPanel(headParams, function(widget, newParams)
if not newParams.on then
warn('equip head ' .. slot .. ' offline')
return
end
warn('equip head' .. slot .. ' online')
if newParams and newParams.item1 then
warn('equip head' .. slot .. ' equip ' .. newParams.item1)
equipItem(newParams.slot, newParams.item1)
end
widget.title:setOn(false)
end, gpAutoEquipSet)
local armorParams = { on = false, slot = 4, title = string.format("Slot Armor %d", slot) }
autoEquipWidgets[slot].armor = UI.TwoItemsAndSlotPanel(armorParams, function(widget, newParams)
if not newParams.on then
warn('equip armor ' .. slot .. ' offline')
return
end
warn('equip armor' .. slot .. ' online')
if newParams and newParams.item1 then
warn('equip armor' .. slot .. ' equip ' .. newParams.item1)
equipItem(newParams.slot, newParams.item1)
end
widget.title:setOn(false)
end, gpAutoEquipSet)
local legsParams = { on = false, slot = 7, title = string.format("Slot Legs %d", slot) }
autoEquipWidgets[slot].legs = UI.TwoItemsAndSlotPanel(legsParams, function(widget, newParams)
if not newParams.on then
warn('equip legs ' .. slot .. ' offline')
return
end
warn('equip legs' .. slot .. ' online')
if newParams and newParams.item1 then
warn('equip legs' .. slot .. ' equip ' .. newParams.item1)
equipItem(newParams.slot, newParams.item1)
end
widget.title:setOn(false)
end, gpAutoEquipSet)
local bootsParams = { on = false, slot = 10, title = string.format("Slot Boots %d", slot) }
autoEquipWidgets[slot].boots = UI.TwoItemsAndSlotPanel(bootsParams, function(widget, newParams)
if not newParams.on then
warn('equip boots ' .. slot .. ' offline')
return
end
warn('equip boots' .. slot .. ' online')
if newParams and newParams.item1 then
warn('equip boots' .. slot .. ' equip ' .. newParams.item1)
equipItem(newParams.slot, newParams.item1)
end
widget.title:setOn(false)
end, gpAutoEquipSet)
macro(250, string.format("equip set %d", slot), "F" .. slot, function (widget)
for inventorySlot, slotWidget in pairs(autoEquipWidgets[slot]) do
schedule(math.random(250, 1000), function ()
slotWidget.title:onClick()
end)
end
widget:setOff()
end, gpAutoEquipSet)
UI.Separator(gpAutoEquipSet)
end
function equipItem(slot, itemid)
local containers = g_game.getContainers()
local slotItem = getSlot(slot)
if not slotItem or slotItem:getId() ~= itemid then
for _, container in pairs(containers) do
for __, item in ipairs(container:getItems()) do
if item:getId() == itemid then
g_game.move(item, {x=65535, y=slot, z=0}, item:getCount())
return
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment