Skip to content

Commit

Permalink
lua: use local variables for vec3.mid() function
Browse files Browse the repository at this point in the history
  • Loading branch information
alexey-lysiuk committed Dec 21, 2023
1 parent 5e38738 commit 5967ea4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
19 changes: 10 additions & 9 deletions Misc/qs_pak/scripts/edicts.lua
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ local localize <const> = text.localize
local vec3origin <const> = vec3.new()
local vec3one <const> = vec3.new(1, 1, 1)
local vec3minusone <const> = vec3.new(-1, -1, -1)
local vec3mid <const> = vec3.mid

local FL_MONSTER <const> = edicts.flags.FL_MONSTER
local SOLID_NOT <const> = edicts.solidstates.SOLID_NOT
Expand Down Expand Up @@ -214,7 +215,7 @@ function edicts.issecret(edict)
if not count then
-- Regular or Arcane Dimensions secret that was not revealed yet
local origin = edict.origin
location = origin == vec3origin and vec3.mid(min, max) or origin
location = origin == vec3origin and vec3mid(min, max) or origin
elseif count == 0 then
-- Revealed Arcane Dimensions secret, skip it
return
Expand Down Expand Up @@ -305,7 +306,7 @@ function edicts.isteleport(edict)
end

local description = format('Teleport to %s (%s)', target, targetlocation or 'target not found')
local location = vec3.mid(edict.absmin, edict.absmax)
local location = vec3mid(edict.absmin, edict.absmax)

return description, location
end
Expand Down Expand Up @@ -348,7 +349,7 @@ function edicts.isdoor(edict)
local itemprefix = itemname and itemname .. ' ' or ''

local description = format('%s%sDoor', secretprefix, itemprefix)
local location = vec3.mid(edict.absmin, edict.absmax)
local location = vec3mid(edict.absmin, edict.absmax)

return description, location
end
Expand Down Expand Up @@ -438,7 +439,7 @@ function edicts.isbutton(edict, current)
end

local description = (edict.health > 0 and 'Shoot' or 'Touch') .. ' button'
local location = vec3.mid(edict.absmin, edict.absmax)
local location = vec3mid(edict.absmin, edict.absmax)

return description, location
end
Expand All @@ -455,7 +456,7 @@ function edicts.isexit(edict, current)

local mapname = edict.map or '???'
local description = 'Exit to ' .. (mapname == '' and '???' or mapname)
local location = vec3.mid(edict.absmin, edict.absmax)
local location = vec3mid(edict.absmin, edict.absmax)

return description, location
end
Expand All @@ -477,7 +478,7 @@ function edicts.ismessage(edict)
end

local description = '"' .. message .. '"'
local location = vec3.mid(edict.absmin, edict.absmax)
local location = vec3mid(edict.absmin, edict.absmax)

return description, location
end
Expand Down Expand Up @@ -569,7 +570,7 @@ function console.gazerefs(choice)
end

choice = choice and math.tointeger(choice) or 0
local pos = vec3.mid(edict.absmin, edict.absmax)
local pos = vec3mid(edict.absmin, edict.absmax)

if choice == 1 then
player.setpos(pos)
Expand Down Expand Up @@ -613,7 +614,7 @@ function console.gazerefs(choice)
end

edict = reflist[choice]
pos = vec3.mid(edict.absmin, edict.absmax)
pos = vec3mid(edict.absmin, edict.absmax)
player.setpos(pos)
else
print('\2Gazed entity')
Expand All @@ -629,7 +630,7 @@ function console.gazerefs(choice)
print(header)

for _, edict in ipairs(refs) do
pos = vec3.mid(edict.absmin, edict.absmax)
pos = vec3mid(edict.absmin, edict.absmax)
print(index .. ':', getname(edict), 'at', pos)

index = index + 1
Expand Down
3 changes: 2 additions & 1 deletion Misc/qs_pak/scripts/menus.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ local floor <const> = math.floor
local format <const> = string.format
local insert <const> = table.insert

local vec3mid <const> = vec3.mid
local pushpage <const> = menu.pushpage
local poppage <const> = menu.poppage
local clearpages <const> = menu.clearpages
Expand Down Expand Up @@ -356,7 +357,7 @@ local function describe(edict)
local location, angles

if not isfree(edict) then
location = vec3.mid(edict.absmin, edict.absmax)
location = vec3mid(edict.absmin, edict.absmax)
angles = edict.angles

if location == vec3origin then
Expand Down

0 comments on commit 5967ea4

Please sign in to comment.