mirror of
https://github.com/OTCv8/otclientv8.git
synced 2025-10-20 06:33:26 +02:00
Bug fixes for bot
This commit is contained in:
@@ -181,7 +181,13 @@ function editConfig()
|
||||
configWindow:raise()
|
||||
configWindow:focus()
|
||||
editorText = {botConfig.configs[config].script or "", ""}
|
||||
configEditorText:setText(botConfig.configs[config].script)
|
||||
if #editorText[1] <= 2 then
|
||||
editorText[1] = "--config name\n\n"
|
||||
for k, v in ipairs(tabs) do
|
||||
editorText[1] = editorText[1] .. "--#" .. v .. "\n\n"
|
||||
end
|
||||
end
|
||||
configEditorText:setText(editorText[1])
|
||||
configEditorText:setEditable(true)
|
||||
activeTab = mainTab
|
||||
configTab:selectTab(mainTab)
|
||||
@@ -208,8 +214,12 @@ function restoreMainTab()
|
||||
editorText = {configEditorText:getText(), ""}
|
||||
return
|
||||
end
|
||||
editorText = {editorText[1] .. "--#" .. activeTab:getText():lower() .. "\n" .. configEditorText:getText() .. editorText[2], ""}
|
||||
configEditorText:setText(editorText[1])
|
||||
local currentText = configEditorText:getText()
|
||||
if #currentText > 0 and currentText:sub(#currentText, #currentText) ~= '\n' then
|
||||
currentText = currentText .. '\n'
|
||||
end
|
||||
editorText = {editorText[1] .. "--#" .. activeTab:getText():lower() .. "\n" .. currentText .. editorText[2], ""}
|
||||
configEditorText:setText(editorText[1])
|
||||
end
|
||||
|
||||
function editorTabChanged(holder, tab)
|
||||
@@ -279,7 +289,7 @@ function refreshConfig()
|
||||
local status, result = pcall(function() return executeBot(config.script, config.storage, botPanel, botMsgCallback) end)
|
||||
if not status then
|
||||
errorOccured = true
|
||||
statusLabel:setText(tr("Error: " .. tostring(result)))
|
||||
statusLabel:setText("Error: " .. tostring(result))
|
||||
return
|
||||
end
|
||||
compiledConfig = result
|
||||
@@ -300,7 +310,7 @@ function executeConfig()
|
||||
local status, result = pcall(function() return compiledConfig.script() end)
|
||||
if not status then
|
||||
errorOccured = true
|
||||
statusLabel:setText(tr("Error: " .. result))
|
||||
statusLabel:setText("Error: " .. result)
|
||||
return
|
||||
end
|
||||
end
|
||||
@@ -337,7 +347,7 @@ function botKeyDown(widget, keyCode, keyboardModifiers)
|
||||
local status, result = pcall(function() compiledConfig.callbacks.onKeyDown(keyCode, keyboardModifiers) end)
|
||||
if not status then
|
||||
errorOccured = true
|
||||
statusLabel:setText(tr("Error: " .. result))
|
||||
statusLabel:setText("Error: " .. result)
|
||||
end
|
||||
return false
|
||||
end
|
||||
@@ -347,7 +357,7 @@ function botKeyUp(widget, keyCode, keyboardModifiers)
|
||||
local status, result = pcall(function() compiledConfig.callbacks.onKeyUp(keyCode, keyboardModifiers) end)
|
||||
if not status then
|
||||
errorOccured = true
|
||||
statusLabel:setText(tr("Error: " .. result))
|
||||
statusLabel:setText("Error: " .. result)
|
||||
end
|
||||
return false
|
||||
end
|
||||
@@ -357,7 +367,7 @@ function botKeyPress(widget, keyCode, keyboardModifiers, autoRepeatTicks)
|
||||
local status, result = pcall(function() compiledConfig.callbacks.onKeyPress(keyCode, keyboardModifiers, autoRepeatTicks) end)
|
||||
if not status then
|
||||
errorOccured = true
|
||||
statusLabel:setText(tr("Error: " .. result))
|
||||
statusLabel:setText("Error: " .. result)
|
||||
end
|
||||
return false
|
||||
end
|
||||
@@ -367,7 +377,7 @@ function botOnTalk(name, level, mode, text, channelId, pos)
|
||||
local status, result = pcall(function() compiledConfig.callbacks.onTalk(name, level, mode, text, channelId, pos) end)
|
||||
if not status then
|
||||
errorOccured = true
|
||||
statusLabel:setText(tr("Error: " .. result))
|
||||
statusLabel:setText("Error: " .. result)
|
||||
end
|
||||
return false
|
||||
end
|
||||
@@ -377,7 +387,7 @@ function botAddThing(tile, thing, asd)
|
||||
local status, result = pcall(function() compiledConfig.callbacks.onAddThing(tile, thing) end)
|
||||
if not status then
|
||||
errorOccured = true
|
||||
statusLabel:setText(tr("Error: " .. result))
|
||||
statusLabel:setText("Error: " .. result)
|
||||
end
|
||||
return false
|
||||
end
|
||||
@@ -387,7 +397,7 @@ function botRemoveThing(tile, thing)
|
||||
local status, result = pcall(function() compiledConfig.callbacks.onRemoveThing(tile, thing) end)
|
||||
if not status then
|
||||
errorOccured = true
|
||||
statusLabel:setText(tr("Error: " .. result))
|
||||
statusLabel:setText("Error: " .. result)
|
||||
end
|
||||
return false
|
||||
end
|
@@ -13,15 +13,21 @@ BotLabel < Label
|
||||
text-align: center
|
||||
text-wrap: true
|
||||
|
||||
BotItem < UIItem
|
||||
virtual: true
|
||||
size: 32 32
|
||||
border: 1 black
|
||||
&selectable: true
|
||||
|
||||
BotSeparator < HorizontalSeparator
|
||||
margin-top: 5
|
||||
margin-bottom: 3
|
||||
|
||||
BotPanel < Panel
|
||||
margin-top: 2
|
||||
layout:
|
||||
type: verticalBox
|
||||
fit-children: true
|
||||
|
||||
BotSeparator < HorizontalSeparator
|
||||
margin-top: 5
|
||||
margin-bottom: 3
|
||||
|
||||
MiniWindow
|
||||
id: botWindow
|
||||
@@ -33,7 +39,7 @@ MiniWindow
|
||||
|
||||
MiniWindowContents
|
||||
margin-left: 5
|
||||
margin-right: 5
|
||||
margin-right: 3
|
||||
|
||||
ComboBox
|
||||
id: config
|
||||
|
@@ -55,7 +55,7 @@ MainWindow
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.left: parent.left
|
||||
width: 150
|
||||
@onClick: scheduleEvent(function() g_platform.openUrl("https://github.com/OTCv8/otclient_bot") end, 50)
|
||||
@onClick: scheduleEvent(function() g_platform.openUrl("https://github.com/OTCv8/otclientv8_bot") end, 50)
|
||||
|
||||
Button
|
||||
id: okButton
|
||||
|
@@ -1,10 +1,11 @@
|
||||
botDefaultConfig = {
|
||||
configs = {
|
||||
{name = "Example", script = [[
|
||||
--#Example config
|
||||
{name = "Example", script = [=[
|
||||
--#Example
|
||||
info("Tested on 10.99")
|
||||
|
||||
--#main
|
||||
local widget = setupUI(%[%[
|
||||
local widget = setupUI([[
|
||||
Panel
|
||||
id: redPanel
|
||||
background: red
|
||||
@@ -16,7 +17,7 @@ Panel
|
||||
anchors.fill: parent
|
||||
text: custom ui, otml based
|
||||
text-align: center
|
||||
%]%])
|
||||
]])
|
||||
|
||||
--#macros
|
||||
macro(5000, "macro send link", "f5", function()
|
||||
@@ -25,7 +26,7 @@ macro(5000, "macro send link", "f5", function()
|
||||
end)
|
||||
|
||||
macro(1000, "flag tiles", function()
|
||||
tile:setText("Hello =)", "red")
|
||||
player:getTile():setText("Hello =)", "red")
|
||||
end)
|
||||
|
||||
macro(25, "auto healing", function()
|
||||
@@ -85,8 +86,154 @@ HTTP.getJSON("https://api.ipify.org/?format=json", function(data, err)
|
||||
info("HTTP: My IP is: " .. tostring(data['ip']))
|
||||
end)
|
||||
|
||||
|
||||
]]},
|
||||
|
||||
]=]},
|
||||
{name = "UI & Healing", script = [=[
|
||||
-- UI & healing
|
||||
info("Tested on 10.99")
|
||||
|
||||
--#main
|
||||
local healthPanel = setupUI([[
|
||||
Panel
|
||||
id: healingPanel
|
||||
height: 150
|
||||
margin-top: 3
|
||||
|
||||
Label
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
text: Use item if
|
||||
text-align: center
|
||||
|
||||
BotItem
|
||||
id: item1
|
||||
anchors.left: parent.left
|
||||
anchors.top: prev.bottom
|
||||
|
||||
Label
|
||||
id: label1
|
||||
anchors.left: prev.right
|
||||
anchors.right: parent.right
|
||||
anchors.top: prev.top
|
||||
margin: 0 5 0 5
|
||||
text-align: center
|
||||
|
||||
HorizontalScrollBar
|
||||
id: scroll1
|
||||
anchors.left: prev.left
|
||||
anchors.right: prev.right
|
||||
anchors.top: prev.bottom
|
||||
margin-top: 5
|
||||
minimum: 0
|
||||
maximum: 100
|
||||
step: 1
|
||||
|
||||
BotItem
|
||||
id: item2
|
||||
anchors.left: parent.left
|
||||
anchors.top: item1.bottom
|
||||
margin-top: 3
|
||||
|
||||
Label
|
||||
id: label2
|
||||
anchors.left: prev.right
|
||||
anchors.right: parent.right
|
||||
anchors.top: prev.top
|
||||
margin: 0 5 0 5
|
||||
text-align: center
|
||||
|
||||
HorizontalScrollBar
|
||||
id: scroll2
|
||||
anchors.left: label2.left
|
||||
anchors.right: label2.horizontalCenter
|
||||
anchors.top: label2.bottom
|
||||
margin-top: 5
|
||||
minimum: 0
|
||||
maximum: 100
|
||||
step: 1
|
||||
|
||||
HorizontalScrollBar
|
||||
id: scroll3
|
||||
anchors.left: label2.horizontalCenter
|
||||
anchors.right: label2.right
|
||||
anchors.top: label2.bottom
|
||||
margin-top: 5
|
||||
minimum: 0
|
||||
maximum: 100
|
||||
step: 1
|
||||
|
||||
Label
|
||||
anchors.top: item2.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
margin-top: 3
|
||||
text: Drag item to change it
|
||||
text-align: center
|
||||
|
||||
HorizontalSeparator
|
||||
anchors.top: prev.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
margin-top: 3
|
||||
]])
|
||||
|
||||
healthPanel.item1:setItemId(storage.healItem1 or 266)
|
||||
healthPanel.item1.onItemChange = function(widget, item)
|
||||
storage.healItem1 = item:getId()
|
||||
widget:setItemId(storage.healItem1)
|
||||
end
|
||||
|
||||
healthPanel.item2:setItemId(storage.healItem2 or 268)
|
||||
healthPanel.item2.onItemChange = function(widget, item)
|
||||
storage.healItem2 = item:getId()
|
||||
widget:setItemId(storage.healItem2)
|
||||
end
|
||||
|
||||
healthPanel.scroll1.onValueChange = function(scroll, value)
|
||||
storage.healPercent1 = value
|
||||
healthPanel.label1:setText("0% <= hp <= " .. storage.healPercent1 .. "%")
|
||||
end
|
||||
healthPanel.scroll1:setValue(storage.healPercent1 or 50)
|
||||
|
||||
healthPanel.scroll2.onValueChange = function(scroll, value)
|
||||
storage.healPercent2 = value
|
||||
healthPanel.label2:setText("" .. storage.healPercent2 .. "% <= mana <= " .. storage.healPercent3 .. "%")
|
||||
end
|
||||
healthPanel.scroll3.onValueChange = function(scroll, value)
|
||||
storage.healPercent3 = value
|
||||
healthPanel.label2:setText("" .. storage.healPercent2 .. "% <= mana <= " .. storage.healPercent3 .. "%")
|
||||
end
|
||||
healthPanel.scroll2:setValue(storage.healPercent2 or 40)
|
||||
healthPanel.scroll3:setValue(storage.healPercent3 or 60)
|
||||
|
||||
macro(25, function()
|
||||
if not storage.healItem1 then
|
||||
return
|
||||
end
|
||||
if healthPanel.scroll1:getValue() >= hppercent() then
|
||||
useWith(storage.healItem1, player)
|
||||
delay(500)
|
||||
end
|
||||
end)
|
||||
macro(25, function()
|
||||
if not storage.healItem2 then
|
||||
return
|
||||
end
|
||||
if storage.healPercent2 <= manapercent() and manapercent() <= storage.healPercent3 then
|
||||
useWith(storage.healItem2, player)
|
||||
delay(500)
|
||||
end
|
||||
end)
|
||||
|
||||
--#macros
|
||||
|
||||
--#hotkeys
|
||||
|
||||
--#callbacks
|
||||
|
||||
--#other
|
||||
]=]},
|
||||
{}, {}, {}
|
||||
},
|
||||
enabled = false,
|
||||
|
@@ -8,7 +8,7 @@ function setupFunctions(context)
|
||||
context.hp = function() return context.player:getHealth() end
|
||||
context.mana = function() return context.player:getMana() end
|
||||
context.hppercent = function() return context.player:getHealthPercent() end
|
||||
context.manapercent = function() return context.player:getManaPercent() end
|
||||
context.manapercent = function() if context.player:getMaxMana() <= 1 then return 100 else return math.floor(context.player:getMana() * 100 / context.player:getMaxMana()) end end
|
||||
context.maxhp = function() return context.player:getMaxHealth() end
|
||||
context.maxmana = function() return context.player:getMaxMana() end
|
||||
context.hpmax = function() return context.player:getMaxHealth() end
|
||||
|
Reference in New Issue
Block a user