This page contains changes which are not marked for translation.

Available since: Gideros 2016.08
Class: debug


Set meta table type

From Useful to extend Lua syntax and for some tricks.

Adds new method to debug library: debug.settypemt(type, metatable) Supported types: "nil","boolean","lightuserdata","number","string","table","function","userdata","thread".

For example:

-- enable string indexing (s[n]) to get character at utf8 position
string.__index = function(s, n) return utf8.sub(s, n, n) end
debug.settypemt("string", string)
local s = "Hello, world!"
print(s[8]) --> w

Also sets table library as default type metatable for all tables without user defined metatables i.e. enables following syntax: t:insert(3); t:remove(2); t:sort(func); etc.