PDA

View Full Version : Lua help



benh
October 15th, 2006, 21:39
Hi all

I am helping make a lua app and i keep getting this error Image.load: error loading image now i dont think it can be a memoy leak because i have loadfile commands and not dofile commands and the script looks spotless!

Please help!

yaustar
October 15th, 2006, 21:52
Try loading a different image in the same place. Check if you have enough memory to actually load the image first. Check if the file path is correct.

benh
October 15th, 2006, 21:53
sorry heres the code

black = Color.new(0, 0, 0)

background = Image.load("backgrounds/1.png")
loadA = loadfile("index2.lua")

while true do

pad = Controls.read()
screen:blit(0, 0, background)

if pad:cross() then
loadA()
end

screen.waitVblankStart()
screen:flip()
end

Edit - iv tried all those things you said

yaustar
October 15th, 2006, 21:54
Try loading a different image in the same place. Check if you have enough memory to actually load the image first. Check if the file path is correct. Check if the image is valid. Check that the image exists.

benh
October 15th, 2006, 21:55
how do you check if you have enough memory and if i havnt how do i free up memory

yaustar
October 15th, 2006, 21:58
Use the LuaPlayer function to check for free system memory. TO free up memory, you let the variable fall out of scope and garbarge collection takes care of the rest.

benh
October 15th, 2006, 21:59
could you give me the garbage collection code please and tell me where to put in the script

yaustar
October 15th, 2006, 22:03
Garbarge Collection that exists in the languages available are automatic. Eg Java, C#.

eg
if true then
local blah -- memory is allocated and the variable/reference is onto pushed the stack
end
-- blah is no longer in scope and is popped off the stack and garbarge collection frees the memory allocated for it since there is no reference to it anymore

benh
October 15th, 2006, 22:05
i still dont get it, what is the garbage collection code

yaustar
October 15th, 2006, 22:06
There is no garbarge collection code. It is AUTOMATIC and part of the language feature.

benh
October 15th, 2006, 22:07
ok so i still have a problem if the memory is cleared automatically what is causing my error

yaustar
October 15th, 2006, 22:09
Try loading a different image in the same place. Check if you have enough memory to actually load the image first. Check if the file path is correct. Check if the image is valid. Check that the image exists.
Have you tried everything in this list?

benh
October 15th, 2006, 22:10
iv done everything on that list and i dont need to check the memory because it is cleared automatically

yaustar
October 15th, 2006, 22:13
Upload the project here. Images et all

benh
October 15th, 2006, 22:18
ok here it is

BTW this is gunntims0103's code please do not credit me for it i am just helping him get back on his feet.

yaustar
October 15th, 2006, 22:21
The images are too large in terms of Width and Height. I think the max size is 512 x 512

benh
October 15th, 2006, 22:23
ok thanks