Roan Holler
New Member
- Joined
- Aug 20, 2024
- Messages
- 16
- Reaction score
- 4
At the top of the buttons, the combat controls button does not appear to me.
These are the files found in modules\game_combatcontrols
I've checked and tried several things and I can't find the solution. I hope you can help me, please.
This is in combatcontrols.lua
This is in combatcontrols.otui
This is in combatcontrols.otmod

These are the files found in modules\game_combatcontrols
I've checked and tried several things and I can't find the solution. I hope you can help me, please.
This is in combatcontrols.lua
LUA:
combatControlsButton = nil
combatControlsWindow = nil
fightOffensiveBox = nil
fightBalancedBox = nil
fightDefensiveBox = nil
chaseModeButton = nil
safeFightButton = nil
fightModeRadioGroup = nil
function init()
combatControlsButton = modules.client_topmenu.addLeftGameToggleButton('combatControlsButton', tr('Combat Controls'), '/images/topbuttons/combatcontrols', toggle)
combatControlsButton:setOn(true)
combatControlsWindow = g_ui.loadUI('combatcontrols', modules.game_interface.getRightPanel())
combatControlsWindow:disableResize()
fightOffensiveBox = combatControlsWindow:recursiveGetChildById('fightOffensiveBox')
fightBalancedBox = combatControlsWindow:recursiveGetChildById('fightBalancedBox')
fightDefensiveBox = combatControlsWindow:recursiveGetChildById('fightDefensiveBox')
chaseModeButton = combatControlsWindow:recursiveGetChildById('chaseModeBox')
safeFightButton = combatControlsWindow:recursiveGetChildById('safeFightBox')
fightModeRadioGroup = UIRadioGroup.create()
fightModeRadioGroup:addWidget(fightOffensiveBox)
fightModeRadioGroup:addWidget(fightBalancedBox)
fightModeRadioGroup:addWidget(fightDefensiveBox)
connect(fightModeRadioGroup, { onSelectionChange = onSetFightMode })
connect(chaseModeButton, { onCheckChange = onSetChaseMode })
connect(safeFightButton, { onCheckChange = onSetSafeFight })
connect(g_game, {
onGameStart = online,
onGameEnd = offline,
onFightModeChange = update,
onChaseModeChange = update,
onSafeFightChange = update,
onWalk = check,
onAutoWalk = check
})
if g_game.isOnline() then
online()
update()
end
update()
combatControlsWindow:setup()
end
function terminate()
if g_game.isOnline() then
offline()
end
fightModeRadioGroup:destroy()
combatControlsWindow:destroy()
combatControlsButton:destroy()
disconnect(g_game, {
onGameStart = online,
onGameEnd = offline,
onFightModeChange = update,
onChaseModeChange = update,
onSafeFightChange = update,
onWalk = check,
onAutoWalk = check
})
end
function update()
local fightMode = g_game.getFightMode()
if fightMode == FightOffensive then
fightModeRadioGroup:selectWidget(fightOffensiveBox)
elseif fightMode == FightBalanced then
fightModeRadioGroup:selectWidget(fightBalancedBox)
else
fightModeRadioGroup:selectWidget(fightDefensiveBox)
end
local chaseMode = g_game.getChaseMode()
chaseModeButton:setChecked(chaseMode == ChaseOpponent)
local safeFight = g_game.isSafeFight()
safeFightButton:setChecked(not safeFight)
end
function check()
if modules.client_options.getOption('autoChaseOverride') then
if g_game.isAttacking() and g_game.getChaseMode() == ChaseOpponent then
g_game.setChaseMode(DontChase)
end
end
end
function online()
local player = g_game.getLocalPlayer()
if player then
local char = g_game.getCharacterName()
local lastCombatControls = g_settings.getNode('LastCombatControls')
end
update()
end
function offline()
local lastCombatControls = g_settings.getNode('LastCombatControls')
if not lastCombatControls then
lastCombatControls = {}
end
local player = g_game.getLocalPlayer()
if player then
local char = g_game.getCharacterName()
lastCombatControls[char] = {
fightMode = g_game.getFightMode(),
chaseMode = g_game.getChaseMode(),
safeFight = g_game.isSafeFight()
}
-- save last combat control settings
g_settings.setNode('LastCombatControls', lastCombatControls)
end
end
function toggle()
if combatControlsButton:isOn() then
combatControlsWindow:close()
combatControlsButton:setOn(false)
else
combatControlsWindow:open()
combatControlsButton:setOn(true)
end
end
function onSetFightMode(self, selectedFightButton)
if selectedFightButton == nil then return end
local buttonId = selectedFightButton:getId()
local fightMode
if buttonId == 'fightOffensiveBox' then
fightMode = FightOffensive
elseif buttonId == 'fightBalancedBox' then
fightMode = FightBalanced
else
fightMode = FightDefensive
end
g_game.setFightMode(fightMode)
end
function onSetChaseMode(self, checked)
local chaseMode
if checked then
chaseMode = ChaseOpponent
else
chaseMode = DontChase
end
g_game.setChaseMode(chaseMode)
end
function onSetSafeFight(self, checked)
g_game.setSafeFight(not checked)
end
function onMiniWindowClose()
combatControlsButton:setOn(false)
end
This is in combatcontrols.otui
LUA:
CombatBox < UICheckBox
size: 20 20
image-clip: 0 0 20 20
anchors.top: parent.top
margin: 0 4
$first:
margin: 0 1
$last:
margin: 0 1
$checked:
image-clip: 0 20 20 20
FightOffensiveBox < CombatBox
image-source: /images/game/combatmodes/fightoffensive
FightBalancedBox < CombatBox
image-source: /images/game/combatmodes/fightbalanced
FightDefensiveBox < CombatBox
image-source: /images/game/combatmodes/fightdefensive
ChaseModeBox < CombatBox
image-source: /images/game/combatmodes/chasemode
SafeFightBox < CombatBox
image-source: /images/game/combatmodes/safefight
MiniWindow
id: combatControlsWindow
!text: tr('Combat Controls')
icon: /images/topbuttons/combatcontrols
height: 48
&save: true
@onClose: modules.game_combatcontrols.onMiniWindowClose()
MiniWindowContents
FightOffensiveBox
id: fightOffensiveBox
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
FightBalancedBox
id: fightBalancedBox
anchors.left: prev.right
anchors.verticalCenter: parent.verticalCenter
FightDefensiveBox
id: fightDefensiveBox
anchors.left: prev.right
anchors.verticalCenter: parent.verticalCenter
ChaseModeBox
id: chaseModeBox
anchors.right: next.left
anchors.verticalCenter: parent.verticalCenter
SafeFightBox
id: safeFightBox
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
This is in combatcontrols.otmod
LUA:
Module
name: game_combatcontrols
description: Combat controls window
author: edubart, BeniS
website: www.otclient.info
sandboxed: true
scripts: [ combatcontrols ]
@onLoad: init()
@onUnload: terminate()