Lua Coding Tips Sheet

July 18, 2011 2:24 pm 1,486 comments

Share this Article

Author:

Working with the insertion into IOS programming first challenge was to sort through  all the different code.

I now have a library of  books on C,  C+, Objective C, and Lua

All Similar

All Different

The main thing (I have found)  to move between each programming language is the ability to forget or separate  one syntax and pickup another.

This is my Lua Quick Reference coding Tips sheet for review when I need a jump start

In doing serious brain dumps with C and objective C and then retooling for Lua your brain starts to seize and melt and then I found the short converted German to english guide (link below) For me to understand Ansca Corona I needed to be a little clearer on Lua and  once I went back and read through the beginners guide  (Written by LUA I understood better what is going on in the code.

Essentially Lua is Algebra  Statements with rules

With Algebra you can and do have several ways to get to the same answer that being so it is important to organize your thoughts and if things work use the same methods so

If all else fails go back and read this Lua Guide

Programming in Lua manual is  on line 1st Edition by Roberto Ierusalimschy   Make sure if you purchase the book since first edition is online you purchase the  updated  Programming in Lua 2nd edition ISBN 8590379825

Confusing  Same Name just Edition changes you want the Dark Blue Cover not the Light Blue

Some hard set Rules and at the bottom are rules – for me to make coding  easier to  read and stick to rules I try to follow

Variables – Names
It doesn’t matter how we call a variable. However, there are some rules to consider.

  • A variable name has to start either with a letter (character) or an underscore.
  • Variables are case sensitive   Upper case and lower case in a name of a variable is very important: player1 is not equal to Player1
  • Only characters, numbers an underscores are allowed.
  • Reserved words are not allowed for using as name for a variable.
  • Great Coding includes Comments  – Is the Lua symbol to identify what follows is a comment A comment in Lua starts with a double-hyphen and runs to the end of the line. –[[ Multi-line strings & comments are adorned with double square brackets. ]]

Variables can be Global or Local

A local variable only exists in the block it was created in

Variables have the following values

  • NIL (nothing)(empty)(not existing)
  • numbers
  • characters (letters, words, etc.)
  • conditions (true/false)(yes/no)(1/0)
  • functions (as special case of a block)
  • tables (with a lot of others variables stored inside)

FUNCTIONS

Functions are variables that are doing something when they are called.

Functions will be started either with

Calculate = function()
– or with
function Calculate()

and they will be finished with

    end

Tables
Tables are variables storing other variables inside them.

Chunks
The unit of Execution of Lua is called a chunk.

Achunk is simply a sequence of statements  huge tip is chunks flow they are executed sequentially

Chunks

Can define varibles, recieve arguments and return values

My Rules to Follow (Not Rules of LUA)

  • In general my variables will start with a lower case
  • Names of my functions will start with an upper case
  • Parameters (we will learn about later) will be started with an underscore
  • Every new word inside a name of a variable will have an upper case letter.
  • Tables are variables storing other variables inside them.

Leave a Reply


Other News

  • Hardware Microsoft Software Uncategorized When is your Microsoft Product Obsolete?

    When is your Microsoft Product Obsolete?

    Like the storyline to many a Sci Fi  tale an application and  process can  continue to solve and work indefinitely in a closed,  maintained and serviced environment. Many a PC with solid programs and maintained hardware can and have performed  without fail for many years. Problem is  by design our universal connectivity to a local LAN and  then the need for connectivity to the Internet  does not define a closed environment. Did you know?  Since 2002 Microsoft has planned and published  lifetime and support life cycle for [...]

    Read more →
  • Uncategorized ADIOS Sherrif XP ~ How do we live without you?

    ADIOS Sherrif XP ~ How do we live without you?

      Microsoft XP Operating System  & Office 2003 end of  support life is April 8, 2014 Microsoft Official Link Wow! how many XP systems have I installed over the life of MS XP operating system? Laptops ~ Desktops  and even a few XP servers. New out of  the box installs, the many builds &  rebuilds,  the crashes, updates,  patches, phoenix builds,  restores and  even those last chance disaster recovery  before burying and burning late night wish and prayer installs. By design [...]

    Read more →
  • Uncategorized

    Lua Coding Tips Sheet

    Working with the insertion into IOS programming first challenge was to sort through  all the different code. I now have a library of  books on C,  C+, Objective C, and Lua All Similar All Different The main thing (I have found)  to move between each programming language is the ability to forget or separate  one syntax and pickup another. This is my Lua Quick Reference coding Tips sheet for review when I need a jump start In doing serious brain [...]

    Read more →
  • Uncategorized

    CORONA DEFAULT SETTINGS

    My Corona SDK Quick Reference Items Credit this page  to  Fully Croisend As I stumbled upon his website and cut and pasted these notes as I too had all this written in 22 different places files and documents  This is just a quick list of reminders and tips that I look at when working on a project…I have these printed out, scribbled and post-it noted all over my desk so i figured I would make this post and clean up [...]

    Read more →
  • Uncategorized

    Journal into Writing and IOS iPhone or Android App

    Made the decision to sink my teeth  (and my time)  into developing IOS and Android Apps. Why??? Lots of reasons but the main is it is where the fun is and also where the money is at and it challenges my change button. A little background on myself is I have been in the Computer /App industry for many years now. Have seen/witnessed  many trends and the ones that have the paradigm  shifts are the ones to watch. Thing is [...]

    Read more →
  • Uncategorized

    REXP

    Welcome to REXP This is the very first post. Time to  start blogging!

    Read more →