mirror of
https://github.com/OTCv8/otclientv8.git
synced 2025-12-15 00:19:47 +01:00
Added waypoints for bot
This commit is contained in:
@@ -26,7 +26,13 @@ function init()
|
||||
dofile("defaultconfig")
|
||||
dofile("executor")
|
||||
|
||||
connect(g_game, { onGameStart = online, onGameEnd = offline, onTalk = botOnTalk})
|
||||
connect(g_game, {
|
||||
onGameStart = online,
|
||||
onGameEnd = offline,
|
||||
onTalk = botOnTalk,
|
||||
onUse = botOnUse,
|
||||
onUseWith = botOnUseWith
|
||||
})
|
||||
|
||||
connect(rootWidget, { onKeyDown = botKeyDown,
|
||||
onKeyUp = botKeyUp,
|
||||
@@ -56,6 +62,9 @@ function init()
|
||||
else
|
||||
botConfig = botDefaultConfig
|
||||
end
|
||||
|
||||
botConfig.configs[1].name = botDefaultConfig.configs[1].name
|
||||
botConfig.configs[1].script = botDefaultConfig.configs[1].script
|
||||
|
||||
botButton = modules.client_topmenu.addRightGameToggleButton('botButton',
|
||||
tr('Bot'), '/images/topbuttons/bot', toggle)
|
||||
@@ -136,7 +145,13 @@ function terminate()
|
||||
onKeyUp = botKeyUp,
|
||||
onKeyPress = botKeyPress })
|
||||
|
||||
disconnect(g_game, { onGameStart = online, onGameEnd = offline, onTalk = botOnTalk})
|
||||
disconnect(g_game, {
|
||||
onGameStart = online,
|
||||
onGameEnd = offline,
|
||||
onTalk = botOnTalk,
|
||||
onUse = botOnUse,
|
||||
onUseWith = botOnUseWith
|
||||
})
|
||||
|
||||
disconnect(Tile, { onAddThing = botAddThing, onRemoveThing = botRemoveThing })
|
||||
|
||||
@@ -177,7 +192,7 @@ function online()
|
||||
botButton:show()
|
||||
updateEnabled()
|
||||
if botConfig.enabled then
|
||||
scheduleEvent(refreshConfig, 1)
|
||||
scheduleEvent(refreshConfig, 20)
|
||||
else
|
||||
clearConfig()
|
||||
end
|
||||
@@ -337,7 +352,7 @@ function refreshConfig()
|
||||
end
|
||||
errorOccured = false
|
||||
g_game.enableTileThingLuaCallback(false)
|
||||
local status, result = pcall(function() return executeBot(config.script, config.storage, botTabs, botMsgCallback) end)
|
||||
local status, result = pcall(function() return executeBot(config.script, config.storage, botTabs, botMsgCallback, saveConfig) end)
|
||||
if not status then
|
||||
errorOccured = true
|
||||
statusLabel:setText("Error: " .. tostring(result))
|
||||
@@ -454,3 +469,13 @@ function botCraetureHealthPercentChange(creature, healthPercent)
|
||||
if compiledConfig == nil then return false end
|
||||
safeBotCall(function() compiledConfig.callbacks.onCreatureHealthPercentChange(creature, healthPercent) end)
|
||||
end
|
||||
|
||||
function botOnUse(pos, itemId, stackPos, subType)
|
||||
if compiledConfig == nil then return false end
|
||||
safeBotCall(function() compiledConfig.callbacks.onUse(pos, itemId, stackPos, subType) end)
|
||||
end
|
||||
|
||||
function botOnUseWith(pos, itemId, target, subType)
|
||||
if compiledConfig == nil then return false end
|
||||
safeBotCall(function() compiledConfig.callbacks.onUseWith(pos, itemId, target, subType) end)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user