PICO-8 Wiki
Advertisement
type( value )
Returns the basic type of a given value as a string.
value
The value whose type to test.

The type() function is similar to the corresponding Lua built-in function.

Examples

print(type(1))        -- "number"
print(type("hello"))  -- "string"
print(type(false))    -- "boolean"
print(type({}))       -- "table"
print(type(nil))      -- "nil"

function print_is_number(v)
  if type(v) == "number" then
    print("it's a number")
  else
    print("it's not a number")
  end
end

See also

Advertisement