This is a simple little project that allows you to copy code and upon rentering codea the project is ran. I’ve been using it to test out project without having to create a project to store the code in.
I had wrote then when testing 2.0 in beta so I havent put any time into tracking down bugs.
--# Main
-- PasteBoard Run
-- Use this function to perform your initial setup
PasteBoard = {}
PasteBoard.cTime = tonumber(os.date("%S"))
PasteBoard.code = ""
function setup()
print("Copy any valid project and re-enter Codea")
PasteBoard.o_setup()
PasteBoard.runCode()
end
-- This function gets called once every frame
function draw()
local t = tonumber(os.date("%S"))
if t - PasteBoard.cTime >1 then
PasteBoard.runCode()
end
PasteBoard.cTime = t
-- This sets a dark background color
-- Do your drawing here
end
PasteBoard.o_setup = function()
parameter.clear()
output.clear()
parameter.action("Open Browser",function() PasteBoard.resetProject() openURL("http://codea.io/talk",true) end)
parameter.action("Reset Project",PasteBoard.resetProject)
end
PasteBoard.resetProject = function()
PasteBoard.cTime = tonumber(os.date("%S"))
draw = function()
background(0,0,0,255)
local t = tonumber(os.date("%S"))
if t - PasteBoard.cTime >1 then
PasteBoard.runCode()
end
PasteBoard.cTime = t
end
touched = function() end
keyboard = function() end
PasteBoard.o_setup()
end
PasteBoard.runCode = function()
PasteBoard.code = pasteboard.text
local run = loadstring(PasteBoard.code.."setup()")
if pcall(run) then
print("Project Loaded")
else
print("Error in pasteboard code.")
end
end