function blitCursor()
cursorscreen:clear
cursorscreen:blit(x,y,cursor)
screen:blit(0,0,cursorscreen)
screen.flip()
end
D:\pspstuff\devel\LuaIDE\luac.exe: D:\pspstuff\devel\luaplayeremu\gfxtest2.lua:46: function arguments expected near `cursorscreen'
It looks like the debugger thinks that 'cursorscreen' is a function. How can I get this to work? The code works if I place it outside function blitCursor()
function blitCursor()
System.sleep(100)
cursorscreen:clear()
cursorscreen:blit(x,y,cursor)
screen:blit(0,0,cursorscreen)
screen.waitVblankStart()
screen.flip()
end
Lowser briefly flashes through the screen and then my programme comes up
again. Anyone knows why? At the fifth line of my app I called screen:clear(black). And lowser is rendered to screen, so it should be wiped clean, right?
-edit- This doesn't happen if I call cursorscreen:clear(black), but all is wiped from the screen :-( sigh
I hope someone can give me a solution. it's a real pain! Another example: two functions: one for blitting a list of Directory contents and the other for blitting the cursor. both blitted to screen. I call screen:clear(black) and then both functions. The sript waits for imput and on down, edits y value of cursor, screem:clear(black) again and both functions etc. etc.
What happens? I get a screen filled with vertical stacked cursors! And I told it to clear the screen! That's weird, isn't it?
--System.usbDiskModeActivate()
white = Color.new( 255, 255, 255)
black = Color.new(0,0,0)
screen:clear(black)
icon = { dir = Image.load("dir.png"), txt = Image.load("txt.png") }
--browser = Image.createEmpty(480,272)
--cursorscreen = Image.createEmpty(20,272)
cursor = Image.load("cursor.png")
CurrentDir = "ms0:/psp/music"
contents = System.listDirectory("ms0:/psp/music")
DimC = table.getn(contents)
-- first, all functions are defined. Program execution starts later.
function cleandir()
i = 3
while i <= DimC do --delete unsupported entries from contents
--print(i,contents[i].name)
dot = string.find (contents[i].name, "%.")
--print(i,dot)
if dot == nil then -- if it is a dir
else
prevdot = 0
init = 1
while dot ~= nil do
prevdot = dot
init = dot + 1
dot = string.find (contents[i].name, "%.",init)
end
ext = string.sub (contents[i].name, prevdot + 1)-- read last 3 chars from filename
--print(ext)
if ext ~= "TXT" then -- WARNING case sensitive
table.remove (contents, i)
--print("removed")
i = i - 1
DimC = table.getn(contents)
--print(DimC,i)
end
end
i = i + 1
end
end
function blitCursor()
--screen:clear(black)
screen:blit(u-25,v,cursor)
--screen:blit(80,0,cursorscreen)
screen.waitVblankStart()
screen.flip()
end
--print(y)
-- output contents
function OutputContents()
i = 1
x = 100
y = 10
screen:clear(black)
DimC = table.getn(contents)
--print(DimC)
while i <= DimC do
dot = string.find (contents[i].name, "%.")
if contents[i].directory == 1 then
screen:blit(x,y,icon.dir)
screen:print(x+25,y,contents[i].name,white)
y = y + 14
else
screen:print(x+25,y,contents[i].name,white)
screen:blit(x,y,icon.txt)
y = y +14
end
i = i +1
end
screen.flip()
end
--x = 100 unneeded?
--y = 10
--i = 1
function ButtonResponse()
n = 1
u = 100
v = 10
confirm = 0
DirDepth = 0
while confirm == 0 do
pad = Controls.read()
if pad:down() then
if v+14<=10+DimC*14 then
n = n+1
v = v + 14
--screen.flip()
screen:clear(black)
OutputContents()
blitCursor()
System.sleep(100)
end
elseif pad:up() then
if v>10 then
n = n - 1
v = v - 14
--screen.flip()
OutputContents()
blitCursor()
System.sleep(100)
end
elseif pad:cross() then
print(i)
if contents[i].directory == 1 then
if DirDepth > 0 then
-- nothing
else
CurrentDir, PrevDir = CurrentDir..contents[i].name, CurrentDir
contents = System.listDirectory(CurrentDir)
DirDepth = DirDepth + 1
CleanDir()
OutputContents()
end
else
File = CurrentDir..contents[i].name
confirm = 1
end
end
end
end
--end
-- execute code
cleandir()
OutputContents()
n = 1
u = 100
v = 10
ButtonResponse()
-- draw result
screen.flip()
System.sleep(3000)
--while true do
--screen.waitVblankStart()
--end