The difference between the dot (.) and colon (:) In the lua programming script is as follows:
When you declare a function in lua, you can use either of the following methods:
1.
Function ClassA. show ()
Print ("test1 ")
End
2.
Function ClassA: show ()
Print ("test2 ")
End
So what are the differences between the two methods? Simple
When defining: ClassA: show () is equivalent to ClassA. show (self). To achieve the colon (:) effect, add a self parameter to the first parameter.
During the call, AObj: show () is equivalent to AObj. test (AObj). The dot (.) must add the object itself to the first parameter.
Summary
Periods (.) can be viewed as static methods, while colons (:) can be viewed as member methods.
How to Learn lua scripts
I learned this way: Read the lua manual first to understand the syntax. Then let's take a look at the next lua Program Design ebook. Finally, let's take an example for practice. The examples are from simple to complex, step by step, and patience is required to learn things. Hope to help you
Q: Have you read the book "lua program design version 2?
Lua and python are the two most common scripting languages used in the game. lua program design only talks about some content in lua language, but does not show how to use it in the game, or how it works with other languages.
For specific game examples, you can check some examples of lua's usage in the game. There are many examples on the Internet, or you can go to a game company for work experience.