Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lua/entities/gmod_wire_expression2/core/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,9 @@ end
---@param name string
---@param args table?
function E2Lib.triggerEvent(name, args)
assert(E2Lib.Env.Events[name], "E2Lib.triggerEvent on nonexisting event: '" .. name .. "'")
if not E2Lib.Env.Events[name] then
error("E2Lib.triggerEvent on nonexisting event: '" .. name .. "'", 2)
end

local event_listeners = E2Lib.Env.Events[name].listening

Expand All @@ -264,7 +266,9 @@ end
---@param args table
---@param ignore table<Entity, true>
function E2Lib.triggerEventOmit(name, args, ignore)
assert(E2Lib.Env.Events[name], "E2Lib.triggerEventOmit on nonexisting event: '" .. name .. "'")
if not E2Lib.Env.Events[name] then
error("E2Lib.triggerEventOmit on nonexisting event: '" .. name .. "'", 2)
end

local event_listeners = E2Lib.Env.Events[name].listening

Expand Down
13 changes: 7 additions & 6 deletions lua/entities/gmod_wire_expression2/core/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@

local function UpdateKeys(ply, bind, key, state)
local uid = ply:SteamID()
if table.IsEmpty(KeyAlert) then return end

local keystate = {
runByKey = ply,
Expand Down Expand Up @@ -363,14 +364,14 @@
end)
end

hook.Add("PlayerBindDown", "Exp2KeyReceivingDown", function(player, binding, button)
triggerKey(player,binding,button,true)
E2Lib.triggerEvent("keyPressed", {player, keys_lookup[button], 1, binding or ""})
hook.Add("PlayerBindDown", "Exp2KeyReceivingDown", function(ply, binding, button)
triggerKey(ply,binding,button,true)
E2Lib.triggerEvent("keyPressed", {ply, keys_lookup[button], 1, binding or ""})
end)

hook.Add("PlayerBindUp", "Exp2KeyReceivingUp", function(player, binding, button)
triggerKey(player,binding,button,false)
E2Lib.triggerEvent("keyPressed", {player, keys_lookup[button], 0, binding or ""})
hook.Add("PlayerBindUp", "Exp2KeyReceivingUp", function(ply, binding, button)
triggerKey(ply,binding,button,false)
E2Lib.triggerEvent("keyPressed", {ply, keys_lookup[button], 0, binding or ""})
end)

local function toggleRunOnKeys(self,ply,on,filter)
Expand Down Expand Up @@ -542,7 +543,7 @@

else

e2function array entity:friends()

Check warning on line 546 in lua/entities/gmod_wire_expression2/core/player.lua

View workflow job for this annotation

GitHub Actions / lint

"Unused variable"

Unused variable: this
return {}
end

Expand Down
20 changes: 12 additions & 8 deletions lua/wire/wireshared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1197,16 +1197,20 @@ do
end
end)

hook.Add("PlayerButtonDown", MESSAGE_NAME, function(player, button)
if not player.SyncedBindings then return end
local binding = player.SyncedBindings[button]
hook.Run("PlayerBindDown", player, binding, button)
hook.Add("PlayerButtonDown", MESSAGE_NAME, function(ply, button)
local syncedBinds = ply.SyncedBindings
if not syncedBinds then return end

local binding = syncedBinds[button]
hook.Run("PlayerBindDown", ply, binding, button)
end)

hook.Add("PlayerButtonUp", MESSAGE_NAME, function(player, button)
if not player.SyncedBindings then return end
local binding = player.SyncedBindings[button]
hook.Run("PlayerBindUp", player, binding, button)
hook.Add("PlayerButtonUp", MESSAGE_NAME, function(ply, button)
local syncedBinds = ply.SyncedBindings
if not syncedBinds then return end

local binding = syncedBinds[button]
hook.Run("PlayerBindUp", ply, binding, button)
end)
end
end
Expand Down
Loading