Loops

--A while loop statement in Lua programming language repeatedly executes a target statement when the condition is true. --THere 42 type of loops --The while-loops. This statement or group of statements repeats itself when the giving condition is true. While the condition is met, it would execute itself repeatedly --The for-loops. This produces the statement …

Keywords

--[[Keywords in Lua--]] --[[The following key words are among the few--]] --[[That are reserved among a host--]] --[[They should not be used as identifiers ever--]] Examples of reserved keywords used in Lua. and, if, else, elseif, function, end, break, return, do, not , false, true for, repeat, local, until, nil, in , or, for. There …

Decision making using If

--Decision Making --if statements: You can us if statements --if else: You can use if else statements --nested if statement: You can use one if statements inside another if statements or if else statements insid another if else --An if statement consists of a boolen expression and one or more statements --The syntax for if …

Identifiers

--[[In here, we discuss about identifiers in lua.--]] --[[Identifiers are words or letter that are used to name a variable, function,--]] --[[or maybe any user defined item. --]] --[[It could range from 'A-Z', 'a-z', underscore with letters or numbers--]] --[[Or well numbers ranging from '0-9'--]] --[[Lua does not accept punctuation characters such as @, $ …

Functions

--Functions --Functions are also known as method, sub-routine or procedure. They act as containers for other statements. --This is the syntax operational_function function function_name(arguments 1, arguments 2 ..argn) Example function max(num1, num2) if (num1 > num2) then result num1; else result num2; end return result; end --------------------------- function average(...) result = 0 local arg={...} for …

Design and Debugging

# Designing and Debugging # Hope you enjoyed the previous game. # You would realise that we used the for-loops and while-loops together. # You enjoyed youself right? I did too. # Can you in anyway get it expanded the more? # In here we discuss about designs and debugging. # Debugging is basically the …

Decision Making

# Making decisions. # This is very important in basic programming. # We are using knowledge gained from previous exercises. # Making decisions based on user inputs. # See if you can expand the game and have fun with it. def prompt print "> " end puts "You enter a dark room with doors. Do …

Formatter

formatter = "%s %s %s %s" puts formatter % [1, 2, 3, 4] puts formatter % ["one", "two", "three", "four"] puts formatter % [true, false, false, true] puts formatter % [formatter, formatter, formatter, formatter] puts formatter % [ "I had this thing", "That you could type up right.", "But it didn't sing.", # If you …