• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

otcv8, crash, pc restarted

mar173

Member
Joined
Aug 14, 2016
Messages
34
Reaction score
18
edit: can u explain, why it crashes windows?

I'm just testing stuff. PC restarted after clicking on BotSwitch in game. How should this be done right? I don't want the kind of window that evolunia_bot or game_bot have. The window should be borderless and without minimise or close icons. There should be a fixed position which the user cannot change.

bot.lua
Lua:
manaPotion = nil

function init()
    g_ui.importStyle("core_ui/basic.otui")
    g_ui.importStyle("core_ui/panels.otui")
    g_ui.importStyle("core_ui/config.otui")
    g_ui.importStyle("core_ui/icons.otui")
    g_ui.importStyle("core_ui/container.otui")

    manaPotion = g_ui.loadUI('bot_ui/manaPotion', modules.game_interface.getMapPanel())
end

function terminate()
    manaPotion:destroy()
end

manaPotion.otui
Code:
BotSwitch
  width: 177
  id: manaPotion_switch
  anchors.top: parent.top
  anchors.left: parent.left
  text-align: center
Post automatically merged:

_____________________

FIXED, but now i have another problem, how to automatically resize a panel to its elements, and how to add border or nice background to panel?

otcv8bo.png



Lua:
local UI_Parents = {}
local UI_Childrens = {}
local function Settings()
    SETTINGS = g_settings.getNode('MyBot')
    if not SETTINGS then
        SETTINGS = {}
    end
    local char = g_game.getCharacterName()
    if not SETTINGS[char] then
        SETTINGS[char] = {
            mana_potion_switch = true,
            mana_potion_textedit = '268'
        }
    end
    SETINGS_CHAR = SETTINGS[char]
    g_settings.setNode('MyBot', SETTINGS)
end
local function UI_Switch_TextEdit(id)
    local path = 'bot_ui/' .. id
    local panel = g_ui.loadUI(path, modules.game_interface.getMapPanel()) -- modules.game_interface.getLeftPanel())
    local id_switch = id .. '_switch'
    local switch = panel[id_switch]
    switch:setOn(SETINGS_CHAR[id_switch])
    switch.onClick = function(widget)
        SETINGS_CHAR[id_switch] = not SETINGS_CHAR[id_switch]
        widget:setOn(SETINGS_CHAR[id_switch])
        g_settings.setNode('MyBot', SETTINGS)
    end
    local id_textedit = id .. '_textedit'
    local textedit = panel[id_textedit]
    textedit:setText(SETINGS_CHAR[id_textedit])
    textedit.onTextChange = function(widget, text)
        SETINGS_CHAR[id_textedit] = text
        g_settings.setNode('MyBot', SETTINGS)
    end
    table.insert(UI_Parents, panel)
    table.insert(UI_Childrens, textedit)
    table.insert(UI_Childrens, switch)
end
local function UI()
    UI_Switch_TextEdit('mana_potion')
end
local function RefreshPlayerInfo()
    player = g_game.getLocalPlayer()
    playerName = g_game.getCharacterName()
    playerVocation = player:getVocation()
end
function OnTick()
    if not game_started then
        scheduleEvent(OnTick, 250)
        return
    end
    BotOnTick()
    scheduleEvent(OnTick, 10)
end
function OnGameLoad()
    if g_game.isOnline() and g_game.getLocalPlayer() and g_game.getCharacterName() and g_game.getLocalPlayer():getPosition() then
        -- settings, info and ui for different char
        RefreshPlayerInfo()
        Settings()
        UI()
        -- ^ need write new info first ^
        -- then game is fully started
        game_started = true
        -- load bot only once, we can add reload button to see coding changes in game
        if not bot_loaded then
            dofile('bot_src/main.lua')
            scheduleEvent(OnTick, 250)
        end
        bot_loaded = true
        return
    end
    scheduleEvent(OnGameLoad, 250)
end
local function Dispose()
    game_started = false
    for i = #UI_Childrens, 1, -1 do
        if UI_Childrens[i] then
            UI_Childrens[i]:destroy()
        end
        table.remove(UI_Childrens, i)
    end
    for i = #UI_Parents, 1, -1 do
        if UI_Parents[i] then
            UI_Parents[i]:destroy()
        end
        table.remove(UI_Parents, i)
    end
end
function OnLogin()
    scheduleEvent(OnGameLoad, 250)
end
function OnLogout()
    Dispose()
end
function init()
    g_ui.importStyle("core_ui/basic.otui")
    g_ui.importStyle("core_ui/panels.otui")
    g_ui.importStyle("core_ui/config.otui")
    g_ui.importStyle("core_ui/icons.otui")
    g_ui.importStyle("core_ui/container.otui")
    connect(g_game, {
        onGameStart = OnLogin,
        onGameEnd = OnLogout,
    })
end
function terminate()
    Dispose()
    disconnect(g_game, {
        onGameStart = OnLogin,
        onGameEnd = OnLogout,
    })
end

Code:
Panel
  width: 400
  height: 200
  id: mana_potion_panel
  anchors.top: game_stats.bottom
  anchors.left: game_stats.left
 
  BotSwitch
    text: Mana Potion
    id: mana_potion_switch
    anchors.top: parent.top
    anchors.left: parent.left
    text-align: center

  BotTextEdit
    id: mana_potion_textedit
    anchors.top: mana_potion_switch.bottom
    anchors.left: mana_potion_switch.left
    anchors.right: mana_potion_switch.right
    margin-top: 4
    margin-left: 2

bot_src/main.lua

Lua:
local prev_timer = 0

-- load other bot .lua files

function BotOnTick()
    local timer = os.clock()
    if timer >= prev_timer then
        prev_timer = timer + 1
        print('hello',timer)
    end
end
 
Last edited:
otui is a mess, no gui editor, but i think i understand better now
i have one more problem, maybe u safe my time: can u help me with sio list ui with add remove up down buttons and vbot cavebot ui? paste simple code, for me it's a mess, i need time to understand that code, maybe u know how to do that right now:)


ok.png
Post automatically merged:

okk.png
Post automatically merged:

okkk.png
Better one panel with coloured titles and values without background and border. Above i show many panels, not looks great.


Code:
Panel
  id: dungeon_panel
  width: 170
  height: 200
  anchors.top: food_panel.bottom
  anchors.left: food_panel.left
  margin-top: 20
  background-color: #00FFEA1C
  padding: 10 10
  border: 1 #00FFEA3C

  BotLabel
    id: boss_title_label
    color: #00FFEACC
    text: dungeon boss
    font: title-font-14px-rounded
    anchors.top: parent.top
    anchors.left: parent.left
    anchors.right: parent.right
 
  BotLabel
    id: boss_value_label
    text: unknown
    color: #FFFFFFCC
    font: verdana-11px-rounded
    anchors.top: prev.bottom
    anchors.left: parent.left
    anchors.right: parent.right
 
Last edited:
I started doing half an hour ago and extracted the list from the vbot, added a new functionality: moving items in the list.
 
Back
Top