This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Callback function to handle the upload events that are generated. | |
-- There will be several events: one to indicate the start and end of the | |
-- process and several to indicate the progress (depends on the file size). | |
-- Always test for your error conditions! | |
local function uploadListener( event ) | |
if ( event.isError ) then | |
print( "Network Error." ) | |
-- This is likely a time out or server being down. In other words, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local M = {} | |
function M.copyDatabaseTo( filename, destination ) | |
assert( type(filename) == "string", "string expected for the first parameter but got " .. type(filename) .. " instead." ) | |
assert( type(destination) == "table", "table expected for the second paramter but bot " .. type(destination) .. " instead." ) | |
local sourceDBpath = system.pathForFile( filename, system.ResourceDirectory ) | |
-- io.open opens a file at path. returns nil if no file found | |
local readHandle, errorString = io.open( sourceDBpath, "rb" ) | |
assert( readHandle, "Database at " .. filename .. " could not be read from system.ResourceDirectory" ) | |
assert( type( destination.filename) == "string", "filename should be a string, its a " .. type( destination.filename ) ) | |
print(type(destination.baseDir)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local widget = require( "widget" ) | |
local myList | |
local myData = {} | |
myData[1] = { name="Fred", phone="555-555-1234" } | |
myData[2] = { name="Barney", phone="555-555-1235" } | |
myData[3] = { name="Wilma", phone="555-555-1236" } | |
myData[4] = { name="Betty", phone="555-555-1237" } | |
myData[5] = { name="Pebbles", phone="555-555-1238" } | |
myData[6] = { name="BamBam", phone="555-555-1239" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
math.randomseed( os.time() ) | |
local function rollDice( dicePattern ) | |
-- Dice pattern 3d6+3k3 | |
-- First number : number of dice | |
-- d : required string | |
-- Second number : sides to the dice | |
-- +/- : optional modifier | |
-- ^/k : optional string; '^' keeps the high values, 'k' keeps the low values | |
-- Third number : number of dice to keep, i.e. 4d6^3 keeps the best three numbers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local sqlite3 = require( "sqlite3" ) | |
local dbfunc = require("copyDBto") | |
local filename = "data.db" | |
local baseDir = system.DocumentsDirectory | |
-- Open "data.db". If the file doesn't exist, it will be created | |
local path = system.pathForFile( filename, baseDir ) | |
local doesExist = io.open(path, "r") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
display.setDefault("background", 0.2, 0.2, 0.4 ) | |
-- Keep track of time in seconds | |
local secondsLeft = 20 * 60 -- 20 minutes * 60 seconds | |
local clockText = display.newText("20:00", display.contentCenterX, 80, native.systemFontBold, 80) | |
clockText:setFillColor( 0.7, 0.7, 1 ) | |
local function updateTime() | |
-- decrement the number of seconds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if "simulator" == system.getInfo( "environment" ) then | |
native.showAlert( "Build for device", "This plugin is not supported on the Corona Simulator, please build for an iOS device or Xcode simulator", { "OK" } ) | |
end | |
-- Require the widget library | |
local widget = require( "widget" ) | |
-- Use the iOS 7 theme for this sample | |
widget.setTheme( "widget_theme_android_holo_dark" ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local GRID_WIDTH = 8 | |
local GRID_HEIGHT = 8 | |
local CELL_WIDTH = 40 | |
local CELL_HEIGHT = 40 | |
-- | |
-- Create a 2D array to hold our objects. | |
local grid = {} | |
for i = 1, GRID_HEIGHT do | |
grid[i] = {} | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local requestRateApp = | |
{ | |
name = "rateApp", | |
} | |
Runtime:dispatchEvent(requestRateApp) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void OnCoronaRuntimeLoaded( | |
object sender, CoronaLabs.Corona.WinRT.CoronaRuntimeEventArgs e) | |
{ | |
// Keep a reference to the Corona runtime environment. | |
// It's needed so that your login window's results can be dispatched to Corona. | |
fCoronaRuntimeEnvironment = e.CoronaRuntimeEnvironment; | |
fCoronaRuntimeEnvironment.AddEventListener("rateApp", rateApp); | |
} |
NewerOlder