![]() This table is very large and may take up the entireity of your current page length.įor our purposes, we will be looking at table. To view your own gmcp table, send the command lua display(gmcp). In Aetolia some character data can be found in a table the game creates serverside called gmcp. This function is safe to define at a top-level of a Mudlet script: in fact it is recommended you run this function at a top-level without any kind of guards. If you already have this, great! We’ll be using it. It uses the Trim function to strip both types of spaces. Dim upperCase As String UCase (lowerCase) Example: LTrim This example uses the LTrim function to strip leading spaces and the RTrim function to strip trailing spaces from a string variable. pattern: lua (.*) - script: local f,e = loadstring( "return ". Dim lowerCase As String 'Hello World 1234' ' Returns 'HELLO WORLD 1234'. In the example below the iterative for function is used to define elements of a table. Iteration is a process in which a set of instructions are repeated in a sequence for a specified number of times or until a condition is met. The latter is a table indexed by the variable x and not yet initialized. The former is a which is a table indexed by the string "x". ![]() X.name -> "bosworth" x -> "bosworthīe careful not to confuse a.x with a. Moreover, tables have no fixed size you can add as many elements as you want to a table dynamically.Tables are created by means of a constructor expression, which in its simplest form is written as Tables are associative arrays wich is an array that can be indexed not only with numbers, but also with strings or any other value of the lua language, except nil. arrayName for the first element or arrayName for the second element arrays can be accessed though a index eg. Collection typesĪrrays are data structures that represent a list of elements. There are a few concepts important to understand before working with tables. This tutorial should not be taken as the ‘best method’ for constructing a defense tracking system it’s intended to teach the application and use of tables. I’ll explain how Lua uses tables and how you can use tables to create a system. It is assumed you have installed Mudlet and have a working familiarity in its environment. I know how to do both of these, and could write up a mini primer for each, but that takes a long time and a lot of patience.This tutorial will show you how to create a simple defense tracker in the IRE MUD, Aetolia. If you're interested in databases, you'll want to take a look at LuaSQL lite. If you're interested in doing GUI stuff, you'll want to learn CSS before Mudlet's Geyser. Table.insert(tableName, location, value ) It has an optional parameter that tells it where in the table the value should be added. 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") Variables that contain strings separated by the bar character are called string lists in zMUD and there are several built-in functions described in the. He-Who-Must-Not-Be-Named needs his reign ended, now!" Beginners should use Mudlets automated highlight triggers in the beginning to highlight the text that has been triggered on to get the hang of the different trigger and pattern types. 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 |