Fix table copy function, combat controls now hideable

This commit is contained in:
Henrique Santiago 2012-08-17 02:31:23 -03:00
parent 4793908657
commit 42ccff8596
3 changed files with 17 additions and 9 deletions

View File

@ -16,8 +16,12 @@ end
function table.copy(t) function table.copy(t)
local res = {} local res = {}
for k,v in pairs(t) do for k,v in pairs(t) do
if type(v) == "table" then
res[k] = table.copy(v)
else
res[k] = v res[k] = v
end end
end
return res return res
end end

View File

@ -78,8 +78,8 @@ function update()
end end
function check() function check()
if(Options.getOption('autoChaseOverride')) then if Options.getOption('autoChaseOverride') then
if(g_game.isAttacking() and g_game.getChaseMode() == ChaseOpponent) then if g_game.isAttacking() and g_game.getChaseMode() == ChaseOpponent then
g_game.setChaseMode(DontChase) g_game.setChaseMode(DontChase)
end end
end end
@ -87,13 +87,13 @@ end
function online() function online()
local player = g_game.getLocalPlayer() local player = g_game.getLocalPlayer()
if(player) then if player then
local char = player:getName() local char = player:getName()
local lastCombatControls = g_settings.getNode('LastCombatControls') local lastCombatControls = g_settings.getNode('LastCombatControls')
if(not table.empty(lastCombatControls)) then if not table.empty(lastCombatControls) then
if(lastCombatControls[char]) then if lastCombatControls[char] then
g_game.setFightMode(lastCombatControls[char].fightMode) g_game.setFightMode(lastCombatControls[char].fightMode)
g_game.setChaseMode(lastCombatControls[char].chaseMode) g_game.setChaseMode(lastCombatControls[char].chaseMode)
g_game.setSafeFight(lastCombatControls[char].safeFight) g_game.setSafeFight(lastCombatControls[char].safeFight)
@ -101,18 +101,17 @@ function online()
end end
end end
combatControlsWindow:setVisible(combatControlsButton:isOn())
update() update()
end end
function offline() function offline()
local lastCombatControls = g_settings.getNode('LastCombatControls') local lastCombatControls = g_settings.getNode('LastCombatControls')
if(not lastCombatControls) then if not lastCombatControls then
lastCombatControls = {} lastCombatControls = {}
end end
local player = g_game.getLocalPlayer() local player = g_game.getLocalPlayer()
if(player) then if player then
local char = player:getName() local char = player:getName()
lastCombatControls[char] = { lastCombatControls[char] = {
fightMode = g_game.getFightMode(), fightMode = g_game.getFightMode(),
@ -162,3 +161,7 @@ end
function onSetSafeFight(self, checked) function onSetSafeFight(self, checked)
g_game.setSafeFight(not checked) g_game.setSafeFight(not checked)
end end
function onMiniWindowClose()
combatControlsButton:setOn(false)
end

View File

@ -28,6 +28,7 @@ MiniWindow
icon: combatcontrols.png icon: combatcontrols.png
height: 48 height: 48
&save: true &save: true
@onClose: onMiniWindowClose()
MiniWindowContents MiniWindowContents
FightOffensiveBox FightOffensiveBox