Created
June 19, 2013 17:05
-
-
Save SkyTheCoder/5815974 to your computer and use it in GitHub Desktop.
LitMesh Demo AutoInstall
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
--LitMesh Demo Single Install | |
--Installer created by @Briarfox | |
--- This will pull the LitMesh Demo project into Codea for you | |
-- Instructions: | |
-- * Create a new project in Codea named LitMesh Demo If you chose another name please change the variable Below | |
--This is case sensitive | |
ProjectName = "LitMesh Demo" | |
-- * Paste this into the Main (not from the raw view, as iSafari will escape special characters) | |
-- * Make sure there is a single tab in the project | |
-- * Run and wait for success! | |
-- If all went well, you should have a LitMesh Demo project now | |
function setup() | |
local jsonCode | |
getJsonLib() | |
end | |
function getJsonLib() | |
local tabs = listProjectTabs() | |
if #tabs == 1 then | |
print("Attempting to load json...") | |
local handleSuccess = function(data) | |
--saveProjectTab("json", data) | |
jsonCode = data | |
--sound(SOUND_POWERUP, 42179) | |
print("json code loaded...") | |
if jsonCode then | |
print("Attempting to pull project...") | |
l = loadstring(jsonCode) | |
l() | |
GetProject() | |
end | |
end | |
http.request("https://dl.dropboxusercontent.com/s/9e4nvqeu4hsux2q/Json.lua?token_hash=AAFyMB98j4bnt_1gawf9wSke52hsoC7hsIvARcTuZNeOEw&dl=1", handleSuccess) | |
end | |
end | |
function GetProject() | |
local handleSuccess = function(data,i,j) | |
if listProjectTabs(ProjectName) == nil then | |
sound(SOUND_EXPLODE, 32351) | |
error("AutoGist project must exist first") | |
end | |
local gist = json.decode(data) | |
local projName = ProjectName | |
if gist.files["1aTabOrder"] then | |
print("***Tab Order Found***") | |
local taborder = gist.files["1aTabOrder"].content | |
local strStart =1 | |
local strEnd =0 | |
strStart = string.find(taborder,"#",strEnd) | |
strEnd = string.find(taborder,"\n",strStart) | |
while strStart do | |
local tmp = string.sub(taborder,strStart+1,strEnd-1) | |
local name = ProjectName..":"..tmp | |
tmp = tmp..".lua" | |
saveProjectTab(name,gist.files[tmp].content) | |
strStart = string.find(taborder,"#",strEnd) | |
strEnd = string.find(taborder,"\n",strStart) | |
end | |
else | |
for k,v in pairs(gist.files) do | |
local name = ProjectName .. ":" .. string.gsub(k,".lua","") | |
saveProjectTab(name, v.content) | |
end | |
end | |
sound(SOUND_PICKUP, 11797) | |
print("Success!") | |
end | |
local handleFailure = function(data) | |
sound(SOUND_EXPLODE, 32351) | |
print(data) | |
end | |
http.request("https://api.github.com/gists/742325c8f57fd9a30a8b",handleSuccess, handleFailure) | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment