Userdata

From Legacy Roblox Wiki
Revision as of 18:19, 7 August 2010 by >Blocco
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.

WARNING: newproxy is temporarily disabled due to maintenance on _G

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