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
Next revisionBoth sides next revision
lua_tutorial [2023/04/25 19:00] kalilua_tutorial [2023/04/25 19:20] 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://en.wikipedia.org/wiki/Concatenation|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 =====
lua_tutorial.txt · Last modified: 2023/04/29 07:52 by kali