Skip to content

Commit

Permalink
fix: remove side effect of Render.generic
Browse files Browse the repository at this point in the history
  • Loading branch information
swkeep committed Nov 15, 2024
1 parent 0dd1f97 commit 3f01b18
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions interactionMenu/lua/client/interact.lua
Original file line number Diff line number Diff line change
Expand Up @@ -340,14 +340,13 @@ exports("refresh", refresh)

function Render.generic(data, metadata, callbacks)
if not data then return end
StateManager.set('active', true)

-- onEnter callback
if callbacks.onEnter then
if not callbacks.onEnter(data, metadata) then return end
end

StateManager.set('active', true)

-- afterStart callback
if callbacks.afterStart then callbacks.afterStart(data, metadata) end

Expand Down Expand Up @@ -404,6 +403,7 @@ end
function Render.onEntity(model, entity)
local data = Container.getMenu(model, entity)
if not data then return end
if not canInteract(data, nil) then return end

local closestVehicleBone = Container.boneCheck(entity)
local offset = data.offset or vec3(0, 0, 0)
Expand All @@ -430,6 +430,7 @@ function Render.onEntity(model, entity)
scaleform.set3d(false)
scaleform.attach { entity = entity, offset = offset, bone = closestVehicleBone, static = data.static }
metadata.position = GetEntityCoords(entity)
UpdateNearbyObjects()
return canInteract(data, nil)
end,
validate = function()
Expand All @@ -447,6 +448,7 @@ end
function Render.onPosition(currentMenuId)
local data = Container.getMenu(nil, nil, currentMenuId)
if not data then return end
if not canInteract(data, nil) then return end

local metadata = Container.constructMetadata(data)
local position = data.position
Expand Down

0 comments on commit 3f01b18

Please sign in to comment.