Bot update - waypoints, attacking, looting

This commit is contained in:
OTCv8
2019-11-02 08:43:11 +01:00
parent 62ff2b1cf5
commit 6dd9a54749
15 changed files with 1640 additions and 63 deletions

View File

@@ -79,8 +79,22 @@ context.onUseWith = function(callback)
return context.callback("onUseWith", callback)
end
-- onContainerOpen -- callback = function(container, previousContainer)
context.onContainerOpen = function(callback)
return context.callback("onContainerOpen", callback)
end
-- custom callbacks
-- onContainerUpdateItem -- callback = function(container)
context.onContainerClose = function(callback)
return context.callback("onContainerClose", callback)
end
-- onContainerUpdateItem -- callback = function(container, slot, item)
context.onContainerUpdateItem = function(callback)
return context.callback("onContainerUpdateItem", callback)
end
-- CUSTOM CALLBACKS
-- listen(name, callback) -- callback = function(text, channelId, pos)
context.listen = function(name, callback)

View File

@@ -36,7 +36,7 @@ context.macro = function(timeout, name, hotkey, callback, parent)
local switch = nil
if name:len() > 0 then
if context.storage._macros[name] == nil then
context.storage._macros[name] = true
context.storage._macros[name] = false
end
switch = context._addMacroSwitch(name, hotkey, parent)
end

View File

@@ -10,6 +10,19 @@ context.getSpectators = function(multifloor)
return g_map.getSpectators(context.player:getPosition(), multifloor)
end
context.getCreatureById = function(id, multifloor)
if type(id) ~= 'number' then return nil end
if multifloor ~= true then
multifloor = false
end
for i, spec in ipairs(g_map.getSpectators(context.player:getPosition(), multifloor)) do
if spec:getId() == id then
return spec
end
end
return nil
end
context.getCreatureByName = function(name, multifloor)
if not name then return nil end
name = name:lower()
@@ -70,6 +83,10 @@ context.autoWalk = function(destination, maxDist, ignoreFields, ignoreCreatures)
if #path < 1 then
return false
end
g_game.autoWalk(path, context.player:getPosition())
if g_game.getFeature(GameNewWalking) then
g_game.autoWalk(path, context.player:getPosition())
else
g_game.autoWalk(path, {x=0,y=0,z=0})
end
return true
end

View File

@@ -5,6 +5,7 @@ context.setupUI = function(otml, parent)
parent = context.panel
end
local widget = g_ui.loadUIFromString(otml, parent)
widget.botWidget = true
return widget
end