Last active
August 29, 2015 13:56
-
-
Save indrora/8800011 to your computer and use it in GitHub Desktop.
Test socks please ignore
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
foo = nil | |
foo() |
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
print("Hello, world!") | |
local tArgs = { ... } | |
print("Got ",#tArgs," args") | |
textutils.tabulate(unpack(tArgs)) |
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 loadgist(gist,name) | |
content = http_get_gist(gist,name) | |
if content then | |
func, err = loadstring(content) | |
if not err then | |
return func | |
else | |
print("Error: "..err) | |
end | |
end | |
end | |
function savegist(gist,name,call) | |
if not call then | |
print("No output gile given") | |
return nil | |
end | |
content = http_get_gist(gist,name) | |
-- print(content) | |
if content then | |
print(call) | |
fhandle = fs.open(call, "w") | |
print(fhandle) | |
fhandle.write(content) | |
fhandle.close() | |
else | |
print("Error saving file...") | |
end | |
end | |
function http_get_gist(gistid,name) | |
if not gistid then return nil end | |
url="https://gist.github.com/"..gistid.."/raw" | |
if name then | |
url = url .. "/" .. name | |
end | |
-- Debug: Write out the URL | |
handle = http.get(url) | |
content = handle.readAll() | |
handle.close() | |
return content | |
end | |
--[[-- | |
USAGE: loadgist returns a function when presented with two options | |
loadgist("indrora/8800011","loadgist.lua") -- Loads this script | |
loadgist("indrora/8800011",nil) -- Gets whatever Gisthub decides is the default file (usu. the first) | |
Bootstrapper: | |
Placing this into a turtle or computer in the lua shell will pull this script and begin loading it | |
assert( loadstring( http.get( "https://gist.github.com/indrora/8800011" ).readAll() ) )() | |
--]]-- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment