shortValueString
Definition
-- @/lua/common/extensions/ui/flowgraph/editor.lua:190
local function shortValueString(value, tpe)
if value == nil then
return ("(nil)")
end
if tpe == nil or type(tpe) == 'table' or tpe == 'any' then
-- guess type
if type(value) == 'boolean' or type(value) == 'string' or type(value) == 'number' then
tpe = type(value)
elseif type(value) == 'table' then
if #value == 3 then
tpe = 'vec3'
elseif #value == 4 then
tpe = 'quat'
end
else
tpe = 'string' -- treat as generic usin "tostring"
end
end
if tpe == 'flow' then
return (value and "Flowing" or "Not Flowing")
elseif tpe == 'string' or tpe == 'bool' or tpe == 'boolean' then
return (tostring(value):sub(0, 10) .. (tostring(value):len() > 10 and "..." or ""))
elseif tpe == 'number' then
return (string.format("%0.2f", value))
elseif tpe == 'vec3' then
return (string.format("{%0.1f, %0.1f, %0.1f}", value[1], value[2], value[3]))
elseif tpe == 'quat' then
return (string.format("{%0.1f, %0.1f, %0.1f, %0.1f}", value[1], value[2], value[3], value[4]))
elseif tpe == 'color' then
return (string.format("{%0.1f, %0.1f, %0.1f, %0.1f}", value[1], value[2], value[3], value[4]))
end
return "???"
end
Callers
@/lua/ge/extensions/flowgraph/pin.lua
im.SameLine()
im.TextUnformatted(tostring(displayName) .. '=' .. ui_flowgraph_editor.shortValueString(constValue, self.type)) --formatValueForDisplay(constValue))
-- else
@/lua/common/extensions/ui/flowgraph/editor.lua
end
im.Text(M.shortValueString(value, tpe))
end
@/lua/ge/extensions/editor/flowgraph/variables.lua
local valueText = ui_flowgraph_editor.shortValueString(variable.value, variable.type)
local width = im.GetContentRegionAvailWidth()
--local variable = target:getFull(nm)
--local vName = ui_flowgraph_editor.shortValueString(variable.value, variable.type)
--if im.TreeNode2(nm..variable.index..'-'..id, nm .. ' = ' .. vName) then