assert failed: game over :( - LUA Scripting - CHDK Forum

assert failed: game over :(

  • 4 Replies
  • 4176 Views
assert failed: game over :(
« on: 23 / June / 2012, 22:40:19 »
Advertisements
So I got this message while using the following script.  My camera proceeded to crash gracefully.

Code: [Select]
--[[
@title DeletePics
]]
dir = os.listdir("A/DCIM/100CANON", false)
if #dir ~= 0 then
for i=1, #dir do
os.remove(dir[i])
end
else
print("Directory Empty")
end
print("Memory Cleared")

The script is supposed to delete all the images in the 100CANON directory, but it gives me the error message shown in the title.  I just realized that it will also have an error with no pictures in 100CANON because in that case 100CANON does not exist, I'll fix that.  Any ideas how to make it work though?  Do I need to do this?

Code: [Select]
os.remove("A/DCIM/100CANON/" .. dir[i])

Re: assert failed: game over :(
« Reply #1 on: 23 / June / 2012, 23:04:14 »
Code: [Select]
--[[
@title DeletePics
]]
dir = os.listdir("A/DCIM/100CANON", false)
if #dir ~= 0 then
for i=1, #dir do
os.remove("A/DCIM/100CANON" .. dir[i])
end
else
print("Directory Empty")
end
print("Memory Cleared")

I tried the above code, and it printed "Memory Cleared".  The pictures however were still there, nothing happened.  I printed the names of the pictures in another script, and they were "IMG_XXXX.JPG", which should work with the above script.  Could someone please help me out with this?

*

Offline reyalp

  • ******
  • 14082
Re: assert failed: game over :(
« Reply #2 on: 23 / June / 2012, 23:06:44 »
Yes, you need to give the full path to the file you to remove.

I didn't realize the debug hooks on sd1100 were hooked up in the autobuild. Neat ;)
Don't forget what the H stands for.

*

Offline reyalp

  • ******
  • 14082
Re: assert failed: game over :(
« Reply #3 on: 23 / June / 2012, 23:08:12 »
Code: [Select]
--[[
@title DeletePics
]]
dir = os.listdir("A/DCIM/100CANON", false)
if #dir ~= 0 then
for i=1, #dir do
os.remove("A/DCIM/100CANON" .. dir[i])
end
else
print("Directory Empty")
end
print("Memory Cleared")

I tried the above code, and it printed "Memory Cleared".  The pictures however were still there, nothing happened.  I printed the names of the pictures in another script, and they were "IMG_XXXX.JPG", which should work with the above script.  Could someone please help me out with this?
You need a / between the directory and file.

I suggest using print to help debug your scripts. Two things you can print are: the path of the file you are trying to remove, and the status of the os.remove call.
Don't forget what the H stands for.


Re: assert failed: game over :(
« Reply #4 on: 24 / June / 2012, 01:19:19 »
Ah, I didn't notice that, thanks!  Works like a charm  :)

 

Related Topics