# Lua utility module `Type`

Type - This molule contains functions that allow to check the data type of a variable.

It also contains functions that allow to check if the variable is a TEN primitive class or a LevelFuncs.

To use the functions within the scripts, the module must be called:

    local Type = require("Engine.Type")

Example usage: check if a variable is of type Vec3()

    local Type= require("Engine.Type")

    LevelFuncs.SetLaraPos = function (pos)
      if Type.IsVec3(pos) then
          Lara:SetPosition(pos)
      end
    end

You can use the `not` keyword together with the functions of the Type module.

Example: checking if variable does not have a null value

    LevelFuncs.AddProp = function (prop)
      if not Type.IsNull(prop) then
          LevelVars.property = prop
      end
    end

## Functions

IsNumber(variable) | Check if the variable is a number.
IsString(variable) | Check if the variable is a string.
IsBoolean(variable) | Check if the variable is a boolean.
IsTable(variable) | Check if the variable is a table.
IsNull(variable) | Check if the variable has a null value.
IsFunction(variable) | Check if the variable is a function.
IsColor(variable) | Check if the variable is a Color.
IsRotation(variable) | Check if the variable is a Rotation.
IsVec2(variable) | Check if the variable is a Vec2.
IsVec3(variable) | Check if the variable is a Vec3.
IsTime(variable) | Check if the variable is a Time object.
IsLevelFunc(variable) | Check if the variable is a LevelFunc.

## Functions

IsNumber(variable)
  Check if the variable is a number.

  ### Parameters:

  - variable variable to be check

  ### Returns:

  boolean true if the variable is a number, false if it isn't a number

  ### Usage:

      --example of use
       local num = 255
       if Type.IsNumber(num) then
           num = num + 1
       end

IsString(variable)
  Check if the variable is a string.

  ### Parameters:

  - variable variable to be check

  ### Returns:

  boolean true if the variable is a string, false if it isn't a string

  ### Usage:

      --example of use
       local str = "Hi"
       if Type.IsString(str) then
           TEN.Util.PrintLog(str .. "everyone!", Util.LogLevel.INFO)
       end

IsBoolean(variable)
  Check if the variable is a boolean.

  ### Parameters:

  - variable variable to be check

  ### Returns:

  boolean true if the variable is a boolean, false if it isn't a boolean

  ### Usage:

      --example of use
       LevelFuncs.test = function (test)
           if Type.IsBoolean(test) then
               LevelVars.test = test
           else
               TEN.Util.PrintLog("Error!", Util.LogLevel.ERROR)
           end
       end

IsTable(variable)
  Check if the variable is a table.

  ### Parameters:

  - variable variable to be check

  ### Returns:

  boolean true if the variable is a table, false if it isn't a table

  ### Usage:

      --example of use
       LevelFuncs.PairsTable = function (table)
           if Type.IsTable(table) then
               for k, v in pairs(table) do
                   TEN.Util.PrintLog(tostring(k) .. " - " .. tostring(v), Util.LogLevel.INFO)
               end
           end
       end

IsNull(variable)
  Check if the variable has a null value.

  ### Parameters:

  - variable variable to be check

  ### Returns:

  boolean true if the variable is a null, false if it isn't a null

  ### Usage:

      --example of use
       LevelFuncs.AddProp = function (prop)
           if Type.IsNull(prop) then
               TEN.Util.PrintLog("Error!", Util.LogLevel.ERROR)
           else
               LevelVars.property = prop
           end
       end

IsFunction(variable)
  Check if the variable is a function.

  ### Parameters:

  - variable variable to be check

  ### Returns:

  boolean true if the variable is a function, false if it isn't a function

  ### Usage:

      --example of use
       LevelFuncs.RunFunc = function (func)
           if Type.IsFunction(func) then
               func()
           end
       end

IsColor(variable)
  Check if the variable is a Color.

  ### Parameters:

  - variable variable to be check

  ### Returns:

  boolean true if the variable is a color, false if it isn't a color

  ### Usage:

      --example of use
       LevelFuncs.SetColor = function(color)
           if Type.IsColor(color) then
               string:SetColor(color)
           end
       end

IsRotation(variable)
  Check if the variable is a Rotation.

  ### Parameters:

  - variable variable to be check

  ### Returns:

  boolean true if the variable is a rotation, false if it isn't a rotation

  ### Usage:

      --example of use
       LevelFuncs.SetRotation = function (rot)
           if Type.IsRotation(rot) then
               Lara:SetRotation(rot)
           end
       end

IsVec2(variable)
  Check if the variable is a Vec2.

  ### Parameters:

  - variable variable to be check

  ### Returns:

  boolean true if the variable is a vec2, false if it isn't a vec2

  ### Usage:

      --example of use
       LevelFuncs.SetSpritePos = function (pos)
           if Type.IsVec2(pos) then
               sprite:SetPosition(pos)
           end
       end

IsVec3(variable)
  Check if the variable is a Vec3.

  ### Parameters:

  - variable variable to be check

  ### Returns:

  boolean true if the variable is a vec3, false if it isn't a vec3

  ### Usage:

      --example of use
      LevelFuncs.SetLaraPos = function (pos)
           if Type.IsVec3(pos) then
               Lara:SetPosition(pos)
           end
      end

IsTime(variable)
  Check if the variable is a Time object.

  ### Parameters:

  - variable variable to be check

  ### Returns:

  boolean true if the variable is a Time object, false if it isn't a Time object

  ### Usage:

      --example of use
      LevelFuncs.IncreaseTime = function (time)
           if Type.IsTime(time) then
               time + 1
           end
      end

IsLevelFunc(variable)
  Check if the variable is a LevelFunc.

  ### Parameters:

  - variable variable to be check

  ### Returns:

  boolean true if the variable is a LevelFunc, false if it isn't a IsLevelFunc

  ### Usage:

      --example of use
       LevelFuncs.SetCallback = function (func)
           if Type.IsFunction(func) then
               TEN.Logic.AddCallback(TEN.Logic.CallbackPoint.PRELOOP, func)
           end
       end

generated by TEN-LDoc (a fork of LDoc 1.4.6)