I want to be able to post zip files that contain all the custom art for my projects.
I generally have all my custom art in my Documents folder–it’s very easy to just move them there with the Files app–but it seems like, to get them into the actual project, I have to load them one by one with the asset picker UI while inside that project.
Is there a faster way to get a bunch of assets into a project all at once?
{ BTW, I see that there’s a tag called “Import asset pictures”, which it would be useful to look up–how do I search the forums by tag? }
@UberGoober I think if you put stuff in the Project folder, then everything goes with the project. Since I don’t post large projects with my own assets, I’m not 100% sure.
@UberGoober I just tried it. I put a unique sprite in the Project folder. I then zipped the project and saved it in the Files app folder. From there I loaded the project and the unique sprite was in that project and usable.
@UberGoober Create a project and put sprite() in setup. Tap between the () and an asset list will show. Scroll to the top and the folder will be there with the project name.
Depending on where they are you might be able to mass move. If they’re in photos, I think you can mass move them. If they’re in one of the Codea folders, you can write a simple program that can read from the folder and save them in the project folder.
The program should be easy. Just read the assets in Documents and ask if it should be copied to Project. If Yes, copy, if No skip and read the next asset name.
@UberGoober Here’s something simple. Change the folder name to what you want. Try to copy just a few to start. You might have to exit the code to see them in the project folder, maybe not.
viewer.mode=STANDARD
function setup()
folder=asset.builtin.Planet_Cute
tab=folder.all
pos=1
fill(255)
stroke(255)
strokeWidth(2)
end
function draw()
background(0)
if pos<#tab then
text(tab[pos].name,WIDTH/2,HEIGHT/2-200)
sprite(folder..tab[pos].name,WIDTH/2,HEIGHT/2)
text("Copy",WIDTH/2,HEIGHT-100)
text("Skip",WIDTH/2,HEIGHT-200)
text("End",WIDTH/2,HEIGHT-300)
line(0,HEIGHT-50,WIDTH,HEIGHT-50)
line(0,HEIGHT-150,WIDTH,HEIGHT-150)
line(0,HEIGHT-250,WIDTH,HEIGHT-250)
line(0,HEIGHT-350,WIDTH,HEIGHT-350)
else
text("Done",WIDTH/2,HEIGHT/2)
end
end
function touched(t)
if t.state==BEGAN then
if t.y>HEIGHT-150 and t.y<HEIGHT-50 then
img=readImage(folder..tab[pos].name)
saveImage(asset..tab[pos].name,img)
print(tab[pos].name.." copied")
elseif t.y>HEIGHT-250 and t.y<HEIGHT-150 then
print(tab[pos].name.." skipped")
else
pos=#tab
end
if pos<#tab then
pos=pos+1
end
end
end
Here’s an updated version. This only looks at png files so if you use the Documents folder you’ll only see png files and not all the projects. Unfortunately I haven’t found a way to update a Project folder other than the Project folder of this program. One way around that is to copy this code to another project, copy what you want into that Project folder, delete this code in that project and then copy the code of the program you want into that project.
viewer.mode=STANDARD
function setup()
folder=asset.builtin.Planet_Cute -- change folder name
tab=folder.all
for z=#tab,1,-1 do
if tab[z].ext~="png" then -- only keep png files in the table
table.remove(tab,z)
end
end
rectMode(CENTER)
pos=1
stroke(255,0,0)
strokeWidth(5)
end
function draw()
background(0)
if pos<=#tab then
sprite(folder..tab[pos].name,WIDTH/2,HEIGHT/2)
buttons()
end
if pos>#tab then
fill(255)
text("Done",WIDTH/2,HEIGHT/2)
end
end
function buttons()
fill(101, 210, 229)
rect(WIDTH-50,HEIGHT-100,100,50)
rect(WIDTH-50,HEIGHT-170,100,50)
rect(WIDTH-50,HEIGHT-240,100,50)
rect(WIDTH/2,HEIGHT-30,300,50)
fill(0)
text("COPY",WIDTH-50,HEIGHT-100)
text("SKIP",WIDTH-50,HEIGHT-170)
text("EXIT",WIDTH-50,HEIGHT-240)
text(tab[pos].name,WIDTH/2,HEIGHT-30)
end
function touched(t)
if t.state==BEGAN and pos<=#tab then
if t.y>HEIGHT-150 and t.y<HEIGHT-50 then
img=readImage(folder..tab[pos].name)
saveImage(asset..tab[pos].name,img)
print(tab[pos].name.." copied")
pos=pos+1
elseif t.y>HEIGHT-220 and t.y<HEIGHT-120 then
print(tab[pos].name.." skipped")
pos=pos+1
elseif t.y>HEIGHT-290 and t.y<HEIGHT-190 then
viewer.close()
end
end
end
Another way I was able to update the Project folder of some other project was to create a new tab named Zzz in whatever project you wanted updated. Then put this code into that tab. Since Zzz should be the last thing loaded, then all the functions in my code should override any other same named functions. So when it’s run, my code should run and allow you to update the Project folder. When done, delete the tab Zzz and the Project folder should have what you copied into it.