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
<?php | |
// :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | |
// :: HEX.PHP | |
// :: | |
// :: Author: | |
// :: Tim Holt, [email protected] | |
// :: Description: | |
// :: Generates a random hex map from a set of terrain types, then | |
// :: outputs HTML to display the map. Also outputs Javascript | |
// :: to handle mouse clicks on the map. When a mouse click is |
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
function doesFileExist( fname) | |
local results = false | |
local filePath = system.pathForFile( fname, system.DocumentsDirectory ) | |
if ( filePath ) then | |
local file, errorString = io.open( filePath, "r" ) | |
if not file then | |
print( "File error: " .. errorString ) | |
else | |
print( "File found: " .. fname ) | |
results = true |
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
cipher = "10101111" -- must be eight digit binary number | |
--Returns the XOR of two binary numbers | |
function xor(a,b) | |
local r = 0 | |
local f = math.floor | |
for i = 0, 31 do | |
local x = a / 2 + b / 2 | |
if x ~= f(x) then | |
r = r + 2^i |