Book Image

Corona SDK Mobile Game Development: Beginner's Guide

By : Michelle M Fernandez
Book Image

Corona SDK Mobile Game Development: Beginner's Guide

By: Michelle M Fernandez

Overview of this book

Table of Contents (19 chapters)
Corona SDK Mobile Game Development Beginner's Guide Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Time for action – getting our hands full of strings


We're starting to familiarize ourselves with several blocks of code and how they interact with each other. Let's see what happens when we add in some expressions using strings and how different they are from just regular strings that you print out in the terminal:

  1. Create a new project folder on your desktop and name it Working With Strings.

  2. Make a new main.lua file in your text editor and save it to your folder.

  3. Type out the following lines (do not include the line numbers in the code, they are only used for line reference):

    1 print("This is a string!") -- This is a string!
    2 print("15" + 1) -- Returns the value 16
  4. Add in the following variables. Notice that it uses the same variable name:

    3 myVar = 28
    4 print(myVar)  -- Returns 28
    
    
    5 myVar = "twenty-eight"
    6 print(myVar) -- Returns twenty-eight
  5. Let's add in more variables with some string values and compare them using different operators:

    7 Name1, Phone = "John Doe", "123-456-7890"
    8 Name2 =...