Game Development Reference
In-Depth Information
We can test how these work as follows:
testing = nil
print(testing)
print(testing and 5)
print(testing or 5)
print(not testing)
testing = 15
print(testing)
print(testing and 5)
print(testing or 5)
print(not testing)
# operator can also be used with arrays.
..
Concatenation operator:
#
Length operator:
.. ). It is used to add
print("one, two, " .. " buckle my shoe")
The length operator returns the length of the string.
print(#"this is a long string") -- prints 21 as the length of the string
Summary
The portability of Lua means that we can run our code on various devices and desktops. The small
footprint of Lua and a very flexible and forgiving syntax allows for rapid prototyping and code testing.
We have seen that Lua is increasing in popularity with game developers. In the next chapter, we shall
take a closer look at the standard Lua libraries that provide all the commands that make up standard Lua.
 
Search WWH ::




Custom Search