0

Learning Lua Scripting – Part 2: Print and Comments

Posted by Dr. Burton on March 14, 2017 in Amazon Lumberyard, Corona, Lua, Lumberyard, Tutorials |

In this Learning Lua Scripting tutorial, we will cover the use of print for displaying information to the console and how to comment a line.

Tutorial

While I go into a much longer explanation in the video, here is the least you need to know:
Using print, you can easily see where you are at in your program and the value of variables:

print ("Made it to line 20 in game.lua")
print (varable1, variable2, "Values of Variable1 and Variable2")
									

As all good programmers know, comments are an essential to being able to keep track of where you are at on a large program or just to remember why you did something a specific way when you resume coding after a long weekend:

-- Inline comment
local variable1 = "Example of code"   -- Everything after 2 dashes is a comment

--[[
This is an example of a block comment
]]
									

Resources

If you would like print resources, there are several books on Lua available.

Programming in Lua by Roberto Ierusalimschy, one of the lead architects of Lua.  Great technical intro to the language.



Lua 5.2 Reference Manual
also by Roberto Ierusalimschy, is, as the name implies, a less expensive reference manual.  Useful for the experienced coder who just needs to look up some of the details of
the language.

Lua Programming Gems by L. de Figueiredo, W. Celes, and R. Ierusalimschy is an older (2008) collection of code snippets that can be useful.


Editor –

We used the Zerobrane editor in all of our video demonstrations.

Our books:
We have several books on Corona and Amazon Lumberyard (both of which use Lua as their scripting language):
Learning Mobile Application & Game Development with Corona – Learn to program in Lua and how to make mobile apps! eTextbook for those who are new to programming.

Beginning Mobile App Development with Corona – Introduces mobile application development for those who already know how to program.

Game Design Fundamentals with Amazon Lumberyard – For those who are new 3D Game development, this eTextbook introduces how to make a game using Blender, GIMP, and Amazon Lumberyard.

The idea of writing a textbook on the Lua Scripting language has been floated to me.  While I greatly value Dr. Ierusalimschy, our styles of instruction are very different.  Leave me a comment if you would like to see a Lua Scripting textbook.

 

Next Lesson: Part 3 – Variables in Lua

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Copyright © 2010-2019 Burtons Media Group All rights reserved.
This site is using the Desk Mess Mirrored theme, v2.5, from BuyNowShop.com.