User Tools

Site Tools



lua_tutorial

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
lua_tutorial [2023/04/25 19:20] kalilua_tutorial [2023/04/29 07:52] (current) kali
Line 87: Line 87:
 Now what did I do there? I simply utilized the information we learned with 3 variables and [[https://www.merriam-webster.com/dictionary/concatenate|concatenated]] them together in the same string. In one simple line it demonstrates that 5 entities all have the same name, but all have different id's and distances from the Player. ''local target = Player:GetTarget()'' is defining **target** as the Player's current target, ''"["..target.id.."] "'' is concatenating brackets on each end of the target id, ''..target.name.." is "..string.format("%.2f",target.distance).." yalms away")'' is formatting the number from distance and [[https://www.merriam-webster.com/dictionary/truncate|truncating]] it to two decimals. It's a bit more advanced, but it should be easy enough to understand I think, but I think it's time we take a few steps back and introduce basic Lua terms so you can be on the same page. Now what did I do there? I simply utilized the information we learned with 3 variables and [[https://www.merriam-webster.com/dictionary/concatenate|concatenated]] them together in the same string. In one simple line it demonstrates that 5 entities all have the same name, but all have different id's and distances from the Player. ''local target = Player:GetTarget()'' is defining **target** as the Player's current target, ''"["..target.id.."] "'' is concatenating brackets on each end of the target id, ''..target.name.." is "..string.format("%.2f",target.distance).." yalms away")'' is formatting the number from distance and [[https://www.merriam-webster.com/dictionary/truncate|truncating]] it to two decimals. It's a bit more advanced, but it should be easy enough to understand I think, but I think it's time we take a few steps back and introduce basic Lua terms so you can be on the same page.
 ===== Introducing Basic Lua Terms ===== ===== Introducing Basic Lua Terms =====
 +
 +  - explain what a variable is
 +  - comments
 +  - identifiers, and how they are case sensitive
 +  - the 21 reserved keywords
 +  - whitespace and readability
 +  - variable definition, lists, and declaration
 +  - the 8 "types"
 +    - nil, boolean, number, string, function, userdata, thread, and table
 +  - the type function
 +  - arithmetic operators
 +  - relational operators
 +  - logical operators
 +  - miscellaneous operators
 +  - operator precedence
 +  - loops, break, and infinite loops
 +  - if statements
 +  - functions
 +    - defining
 +    - arguments
 +    - calling
 +    - assigning and passing
 +    - variable arguments
 +  - strings and string manipulation
 +  - replacing a substring, find and match
 +  - string formatting
 +  - character and byte representation
 +  - arrays and multi-dimensional arrays
 +  - iterators
 +  - tables and table manipulation
 +
 +===== Making our First Module =====
 +
 +===== Common Functions and Standard Libraries =====
 +
 +===== Error Handling and Debugging =====
 +
 +===== Garbage Collection and Performance Impact =====
 +
 +===== Object Oriented and Inheritance =====
lua_tutorial.1682450433.txt.gz · Last modified: 2023/04/25 19:20 by kali