Skip to content

Instantly share code, notes, and snippets.

-- teaching our computer to make decisions
-- To start, let's create some variables that track our input
print( "Hey, are you tired right now? ( type yes or no ) " )
tired = io.flush() -- makes our tired variable what we type in
print( "I almost forgot, what's your name?" )
myName = io.flush()
-- Now we add some basic conditions
-- teaching our computer to make decisions
-- To start, let's create some variables that track our input
print( "Hey, are you tired right now? ( type yes or no ) " )
tired = io.flush() -- makes our tired variable what we type in
print( "I almost forgot, what's your name?" )
myName = io.flush()
-- Now we add some basic conditions
@Binso
Binso / Tables.lua
Last active August 29, 2015 14:06 — forked from Sun-Wukong/Tables.lua
-- How to create tables... or super variables and put them to use
-- Tables are containers for values
myTable = { 1, 2, 3, 4, 5, 6 }
-- now, let's walk through our table
for i = 1, 6 do
print( myTable[ i ] )-- i is the index or the current position in the table
end
-- Functions are special instructions packed into a function keyword
-- They allow you to pack complex instructions for reuse
local function addMe( a, b ) -- in this function, a and b are what's being fed in. We call these arguments
if tonumber( a ) and tonumber( b ) == true then
return a + b
else
return "You can't add these"
end
print( "Enter a number " )
-- Creating a class, or the blueprints for our objects in games and apps
-- Making a class is just like a function
function animalFactory( name )
local animal = { -- a table with the values of our animal object
name = "kitteh",
says = "nyan",
position = { x = 0, y = 0 }
}
# Setting up conditional statement
print("Enter Your age")
myAge = raw_input()
if myAge >= 10: # The state of an if / else statement
print( "You're not a kid anymore." )
elif myAge <= 19: # Use elif for additional conditions... kinda like elseif
print( "You must be a teen!" )
print ( "Welcome, to the World of Games and I'm the god of this world people call Kami, other knows me as the Narrator." )
print ( "Oh, great adventure could I ask you your name? (Insert Name)" )
myName = raw_input()
if myName == 'Kami':
print ( "Hey my name is Kami you can't use this name!" )
else
print ( "Uhh, nice name I guess. Well let's get the show on the road, oh yeah can I ask you how old you are? (Insert Age)" )
@Binso
Binso / app.js
Last active August 29, 2015 14:07
(function($){
var contacts = [
{ name: "Contact 1", address: "1, a street, a town, a city, AB12 3CD", tel: "5555555555", email: "myemail.me.com", type: "family" },
{ name: "Contact 2", address: "2, a street, a town, a city, AB12 3CD", tel: "4444444444", email: "youremail.me.com", type: "friend" },
{ name: "Contact 3", address: "3, a street, a town, a city, AB12 3CD", tel: "3333333333", email: "theiremail.me.com", type: "friend" },
{ name: "Contact 4", address: "4, a street, a town, a city, AB12 3CD", tel: "2222222222", email: "hisemail.me.com", type: "colleague" },
{ name: "Contact 5", address: "5, a street, a town, a city, AB12 3CD", tel: "1111111111", email: "heremail.me.com", type: "family" }
];
} (jquery));
display.setStatusBar( display.HiddenStatusBar )
local slotsGroup = display.newGroup()
local machineGroup = display.newGroup()
local _W = display.contentWidth
local _H = display.contentHeight
local mr = math.random
local credit = 10