Userdata

From Legacy Roblox Wiki
Revision as of 02:01, 29 June 2010 by >Mattchewy (New page: A userdata is just another way to represent data. It is very similar to a metatable. You can create a new userdata by passing true to the newproxy function. <pre> local N...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

A userdata is just another way to represent data. It is very similar to a metatable. You can create a new userdata by passing true to the newproxy function.

local NewUserData = newproxy(true) -- New userdata; Returns an empty metatable
getmetatable(NewUserData).__index = {Name = "Foo", FooValue = "EPIC"} -- index MetaMethod
print(type(NewUserData), NewUserData.Name, NewUserData.FooValue)

In the output window, you should see

userdata Foo EPIC