Returns the number of items within a table.Īgain, like our function example, index_of works nearly the same way, except that it returns a value or nil.Īdds a value to a table. Like our function example, contains works nearly the same way, except it returns no value, only true or false. I don't often use table functions aside from getn, insert and remove, but these will provide you with extra mobility when dealing with your coding. but there are two similar functions to this for tables that exist. Could be very useful if you're trying to determine if you should add something to a table or not!. The above looks through a table and if the item you're looking for is in the table, will return the index (or key) for it. I cannibalized the following example from another IRE game's forums, though I can't recall which or who wrote it. However, you can pass variables into the function and do things with them, and then have the function return a value as well.įunction someOtherFunctionName (var1, var2, var3 ) Functions are best if you plan to repeat certain steps over and over. Reverse the order of characters in a string:įunctions make life a lot easier, and I've opted to avoid them until this point because I was hoping you'd get a hang of everything up until this point, first. If you want to learn more about patterns for gsub, take a swing over to this page. SomeStr = someStr:gsub("He%-Who%-Must%-Not%-Be%-Named", "Voldemort") He-Who-Must-Not-Be-Named needs his reign ended, now!" SomeStr = "He-Who-Must-Not-Be-Named is an evil man.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |