Skip to content

Commit

Permalink
Add 'cursorHighlight.lua'.
Browse files Browse the repository at this point in the history
  • Loading branch information
inkounter committed Nov 20, 2021
1 parent 8424a96 commit 6fd943b
Showing 1 changed file with 93 additions and 0 deletions.
93 changes: 93 additions & 0 deletions cursorHighlight.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
-------------------------------------------------------------------------------
-- TSU: MODIFIER_STATE_CHANGED, PLAYER_STARTED_TURNING, PLAYER_STOPPED_TURNING, PLAYER_STARTED_LOOKING, PLAYER_STOPPED_LOOKING

function(allstates, event, ...)
if event == "MODIFIER_STATE_CHANGED" then
local modifier, active = ...
active = (active == 1)

-- Initialize the state.

local state = allstates[1]
if state == nil then
state = {
["show"] = true,
["changed"] = true,
["modify"] = false,
}

allstates[1] = state

return true
end

-- Return early if ignoring modifiers.

if (aura_env.config.blockModifierWhenLooking and aura_env.looking)
or (aura_env.config.blockModifierWhenTurning and aura_env.turning) then
return false
end

-- Update the state.

local wasModified = state.modify
if not wasModified and active then
state.modify = true
state.changed = true
return true
elseif wasModified and not active then
state.modify = false
state.changed = true
return true
end

return false
else
if aura_env.config.blockModifierWhenLooking then
if event == "PLAYER_STARTED_LOOKING" then
aura_env.looking = true

-- Reset the state to be not modified.

local state = allstates[1]
if state.modify then
state.modify = false
state.changed = true
return true
end

return false
elseif event == "PLAYER_STOPPED_LOOKING" then
aura_env.looking = false
return false
end
end

if aura_env.config.blockModifierWhenTurning then
if event == "PLAYER_STARTED_TURNING" then
aura_env.turning = true

-- Reset the state to be not modified.

local state = allstates[1]
if state.modify then
state.modify = false
state.changed = true
return true
end

return false
elseif event == "PLAYER_STOPPED_TURNING" then
aura_env.turning = false
return false
end
end
end
end

-------------------------------------------------------------------------------
-- custom variables

{
["modify"] = "bool"
}

0 comments on commit 6fd943b

Please sign in to comment.