Search
 
SCRIPT & CODE EXAMPLE
 

LUA

roblox __index and __newindex

myMetaTable = {
	__index = function(table, index)
		print("Sorry, but the element ".. tostring(index).. " does not exist.")
		-- runs when you try to index a nil element of the table this metatable is connected to, table[index]
	end,
	__newindex = function(table, index, value)
		print("Sorry, but the element ".. tostring(index).. " can't be set to ".. tostring(value).. " because this element does not exist.")
		-- runs when you try to index and set a nil element of the table this metatable is connected to, table[index] = value
	end
}
Comment

PREVIOUS NEXT
Code Example
Lua :: roblox difference between __index and __newindex 
Lua :: lua string to number 
Lua :: luau debounce 
Lua :: how to teleport all players in roblox studio 
Lua :: lua wrap number 
Lua :: lua hello world 
Lua :: roblox table.find() 
Lua :: roblox lua brick color randomiser 
Lua :: lua printing 
Lua :: lua what is _ENV 
Lua :: prompt developer product purchase roblox 
Lua :: round to the nearest number lua 
Lua :: append to array lua 
Lua :: get index of value in table lua 
Lua :: lua string replace 
Lua :: roblox lua how to apply gravity to a object 
Lua :: how to make a number adding in roblox studio 
Lua :: lua roblox hack scripts 
Lua :: genarating random number 
Lua :: animation event firing too many times roblox 
Matlab :: how to read dat file in matlab 
Matlab :: matlab stop running function 
Basic :: cmd cant change directory 
Basic :: how to remove characters from the end of a string visual basic 
Elixir :: elixir replace string 
Elixir :: phoenix ecto query bindingess 
Scala :: How to declare constant variable in scala 
Actionscript :: hello world in actionscript 
Excel :: excel column number 
Perl :: perl make a new directory 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =