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
Last revisionBoth sides next revision
lua_tutorial [2023/04/25 19:16] kalilua_tutorial [2023/04/29 07:42] – [Introducing Basic Lua Terms] kali
Line 83: Line 83:
 {{ ::luatutorial_multiple_similar_entities_3.png?direct&800 |}} {{ ::luatutorial_multiple_similar_entities_3.png?direct&800 |}}
  
-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 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.+  local target = Player:GetTarget() d("["..target.id.."] "..target.name.." is "..string.format("%.2f",target.distance).." yalms away"
 + 
 +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
 +  - modules for mmominion
lua_tutorial.txt · Last modified: 2023/04/29 07:52 by kali