Skip to content

Commit

Permalink
lua: reduce decimal digits count in output of numerical edict fields
Browse files Browse the repository at this point in the history
fix #143
  • Loading branch information
alexey-lysiuk committed Dec 9, 2023
1 parent 3c53715 commit 1ba5e42
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion Misc/qs_pak/scripts/edicts.lua
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ local vec3minusone <const> = vec3.new(-1, -1, -1)
local FL_MONSTER <const> = edicts.flags.FL_MONSTER
local SOLID_NOT <const> = edicts.solidstates.SOLID_NOT
local SUPER_SECRET <const> = edicts.spawnflags.SUPER_SECRET
local float <const> = edicts.valuetypes.float

local foreach <const> = edicts.foreach
local isclass <const> = edicts.isclass
Expand Down Expand Up @@ -508,7 +509,8 @@ function console.gaze()
local fieldformat = '%-' .. maxlen .. 's: %s'

for _, field in ipairs(fields) do
print(format(fieldformat, field.name, field.value))
local value = field.type == float and format('%.1f', field.value) or field.value
print(format(fieldformat, field.name, value))
end
end

Expand Down
4 changes: 3 additions & 1 deletion Misc/qs_pak/scripts/menus.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ local playlocal <const> = sound.playlocal
local realtime <const> = host.realtime
local tint <const> = text.tint
local text <const> = menu.text
local float <const> = edicts.valuetypes.float


local defaultkeyremap <const> =
Expand Down Expand Up @@ -324,7 +325,8 @@ function menu.edictinfopage(edict)
local fieldformat = '%-' .. maxlen .. 's: %s'

for _, field in ipairs(fields) do
local line = fieldformat:format(field.name, field.value)
local value = field.type == float and format('%.1f', field.value) or field.value
local line = fieldformat:format(field.name, value)
insert(page.text, elide(line))
end

Expand Down

0 comments on commit 1ba5e42

Please sign in to comment.