Roblox Lua Pairs
Unlike standard lua 51 robloxs lua cannot load the binary version of lua using loadstring.
Roblox lua pairs. So i finally decided to truly learn lua and im a little bit confused. Posted december 15 2011. Additionally to avoid all metamethods use the. For instance adding players to a dictionary when they join the game and then starting them off with 0 points.
The next method and the table itself. So it is slightly faster but the difference is so minuscule that you shouldnt prefer one over the other. Next is another iterator function pairs actually calla this function every iteration. From what i can tell ipairs seems to be more useful for iterating.
In part 13 we learn about pairs and ipairs also known as generic for loop. Pairs and ipairs are functions that can be used with a for loop to go through each element of an array or dictionary without needing to set starting or ending pointspairs is used with dictionaries and ipairs is used with arraysthe i in ipairs stands for index. Marcus 15 marcus 15 members. Reply to this topic.
Userdata newproxy bool addmetatable false creates a blank userdata. Adding key value pairs. Pairs vs ipairs by marcus december 15 2011 in programming. Playerpointsname on the same line set the value.
In this series dr. Type the name of the dictionary followed by the name of the key in brackets. Youll often need to add key value pairs to an existing dictionary. Function table pairs table t returns an iterator function the passed table t and nil so that the.
For a faster version that ignores the pairs metamethod. Brian burton walks through the basics of using lua.