If any of you use the Spritely example program for images, here is a quick little program that saves an image made in Spritely to your Dropbox
--# Main
-- SpritelyToDropbox
-- Use this function to perform your initial setup
function setup()
print("Hello World!")
aloader = SpritelyLoader()
-- Change "YourImageNameHere" to the name of your image
Name = "YourImageNameHere"
end
-- This function gets called once every frame
function draw()
-- This sets a dark background color
background(40, 40, 50)
-- This sets the line thickness
strokeWidth(5)
-- Do your drawing here
createImage = loadstring( readProjectData(Name))
anImage = createImage()
saveImage("Dropbox:"..Name, anImage)
-- Quits program as soon as image is saved
close()
end
--# SpritelyLoader
SpritelyLoader = class()
-- SpriteLoader
-- ver. 1.0
-- moves data from global to project storage
-- ====================
-- This class takes data from global and dumps it into your project.
--
-- To use this class, create an instance in your project.
-- For example: aloader = SpritelyLoader()
--
-- This call will read both keys and images from the global Spritely
-- storage and copy them into your project space.
--
-- Once in the project data, load the saved string to
-- an image using it's key. For example:
--
-- createImage = loadstring( readProjectData("bob"))
-- anImage = createImage()
-- To display your images, you'll need to load them into
-- a sprite. The command looks like this
-- sprite(anImage, 100, 100, 32, 32)
-- Good luck!
function SpritelyLoader:init()
local keys, k, s
if readGlobalData("SpritelyKeys") == nil then
print("No Spritely data found.")
else
-- read global keys
keys = readGlobalData("SpritelyKeys")
saveProjectData("SpritelyKeys", keys)
print("Moving...")
for k in string.gmatch(keys,"([^,]+)") do
print(k)
s = readGlobalData(k)
saveProjectData(k, s)
end
print("Move complete.")
end
end
Just change Name = “YourImageNameHere” to your image name and after running the program sync your Dropbox from within Codea
Also note, if you want it to save to documents just change saveImage(“Dropbox:”) to saveImage(“Documents:”)
The program is supposed to close as soon as the image is saved so do not be alarmed when it quits, the image should have been saved
Enjoy!