GE Lua Documentation

Press F to search!

getAutoTypeFromName

Definition


-- @/lua/common/extensions/ui/flowgraph/editor.lua:875

local function getAutoTypeFromName(name)
  local n = string.lower(name)
  if string.endswith(n, "pos") or
          string.startswith(n, "pos") or
          string.endswith(n, "scl") or
          string.startswith(n, "scl") or
          string.endswith(n, "vec") or
          string.startswith(n, "vec") or
          string.endswith(n, "vec3") or
          string.startswith(n, "vec3") or
          string.find(n, "position") or
          string.find(n, "scale") or
          string.find(n, "vector")
  then
    return "vec3"
  elseif
  string.endswith(n, "rot") or
          string.startswith(n, "rot") or
          string.endswith(n, "quat") or
          string.startswith(n, "quat") or
          string.find(n, "rotation") or
          string.find(n, "quaternion") or
          string.find(n, "orientation")
  then
    return "quat"
  elseif
  string.endswith(n, "clr") or
          string.startswith(n, "clr") or
          string.find(n, "color")
  then
    return "color"
  elseif
  string.endswith(n, "num") or
          string.startswith(n, "num") or
          string.endswith(n, "id") or
          string.find(n, "number") or
          string.find(n, "amount") or
          string.find(n, "score") or
          string.find(n, "count") or
          string.find(n, "time") or
          string.find(n, "duration") or
          string.find(n, "length") or
          string.find(n, "distance") or
          string.find(n, "dist") or
          string.find(n, "points") or
          string.find(n, "threshold") or
          string.find(n, "velocity")
  then
    return "number"
  elseif
  string.find(n, "bool") or
          string.find(n, "enabled") or
          string.find(n, "disabled") or
          string.find(n, "contains") or
          string.startswith(n, "has") or
          string.startswith(n, "uses") or
          string.startswith(n, "with")
  then
    return "bool"
  else
    return "string"
  end
end

Callers

@/lua/ge/extensions/editor/util/editorElementHelper.lua
  for _, field in ipairs(ret) do
    field.type = ui_flowgraph_editor.getAutoTypeFromName(field.label)
    --print(string.format("%s (%s) from %s", field.fieldName, field.type, field.elemLabel))
@/lua/ge/extensions/gameplay/missions/missionTypes/editorHelper.lua
  for _, field in ipairs(ret) do
    field.type = ui_flowgraph_editor.getAutoTypeFromName(field.label)
    --print(string.format("%s (%s) from %s", field.fieldName, field.type, field.elemLabel))
@/lua/ge/extensions/editor/flowgraph/variables.lua
      end
      local typeText = self.addVariableSettings.type=="auto" and ("Automatic Type: ("..self:getAutoTypeFromName(ffi.string(self.addVariableSettings.name))..")") or "self.addVariableSettings.type"
      if im.BeginCombo("##typeSelectorNewVariable", typeText, im.ComboFlags_HeightLarge) then
          if varType == 'auto' then
            varType = self:getAutoTypeFromName(name)
          end

function C:getAutoTypeFromName(name)
  return ui_flowgraph_editor.getAutoTypeFromName(name)
function C:getAutoTypeFromName(name)
  return ui_flowgraph_editor.getAutoTypeFromName(name)
end