function arguments?

Discuss using and improving Lua and the Lua Player specific to the PSP.

Moderators: Shine, Insert_witty_name

Post Reply
the underminer
Posts: 123
Joined: Mon Oct 03, 2005 4:25 am
Location: Netherlands

function arguments?

Post by the underminer »

Code: Select all

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()
Behold! The Underminer got hold of a PSP
JEK
Posts: 12
Joined: Sat Sep 03, 2005 12:04 am
Location: Norway

Post by JEK »

Change:

Code: Select all

cursorscreen:clear
to something like this:

Code: Select all

black = Color.new(0, 0, 0)
cursorscreen:clear(black)
--
JEK
the underminer
Posts: 123
Joined: Mon Oct 03, 2005 4:25 am
Location: Netherlands

Post by the underminer »

Line 46 is the line below that one, with the blit function, so I don't think there's anything wrong with the :clear line. I'll try it though
Behold! The Underminer got hold of a PSP
cancan
Posts: 30
Joined: Fri Nov 18, 2005 9:15 pm
Location: France
Contact:

Post by cancan »

I think that

Code: Select all

cursorscreen:clear()
should be enough.
User avatar
JoshDB
Posts: 87
Joined: Wed Oct 05, 2005 3:54 am

Post by JoshDB »

^^^^^^^^^

That's correct. Same thing for pad:sqaure(), etc. I'm pretty sure it's because they're bools.
the underminer
Posts: 123
Joined: Mon Oct 03, 2005 4:25 am
Location: Netherlands

Post by the underminer »

excuses too all. JEK was right. Works now.

It's strange though, when I call this func:

Code: Select all

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
Behold! The Underminer got hold of a PSP
the underminer
Posts: 123
Joined: Mon Oct 03, 2005 4:25 am
Location: Netherlands

Post by the underminer »

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?
Behold! The Underminer got hold of a PSP
the underminer
Posts: 123
Joined: Mon Oct 03, 2005 4:25 am
Location: Netherlands

Post by the underminer »

I think i'm not making things clear. the full code:

Code: Select all

--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&#40;i,contents&#91;i&#93;.name&#41;
      dot = string.find &#40;contents&#91;i&#93;.name, "%."&#41;
      --print&#40;i,dot&#41;
         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 &#40;contents&#91;i&#93;.name, "%.",init&#41;
            end
         ext = string.sub &#40;contents&#91;i&#93;.name, prevdot + 1&#41;-- read last 3 chars from filename
         --print&#40;ext&#41;
         
         if  ext ~= "TXT"  then -- WARNING case sensitive
            table.remove &#40;contents, i&#41;
            --print&#40;"removed"&#41;
            i = i - 1
            DimC = table.getn&#40;contents&#41;
            --print&#40;DimC,i&#41;
         end
         
      end
   i = i + 1
   end
end

function  blitCursor&#40;&#41;
--screen&#58;clear&#40;black&#41;
screen&#58;blit&#40;u-25,v,cursor&#41;
--screen&#58;blit&#40;80,0,cursorscreen&#41;
screen.waitVblankStart&#40;&#41;
screen.flip&#40;&#41;
end

--print&#40;y&#41;
-- output contents
function OutputContents&#40;&#41;
i = 1
x = 100
y = 10
screen&#58;clear&#40;black&#41;
DimC = table.getn&#40;contents&#41;
--print&#40;DimC&#41;
while i <= DimC do
dot = string.find &#40;contents&#91;i&#93;.name, "%."&#41;

   if contents&#91;i&#93;.directory == 1 then
      screen&#58;blit&#40;x,y,icon.dir&#41;
      screen&#58;print&#40;x+25,y,contents&#91;i&#93;.name,white&#41;
      y = y + 14
   
   else
      screen&#58;print&#40;x+25,y,contents&#91;i&#93;.name,white&#41;
      screen&#58;blit&#40;x,y,icon.txt&#41;
      y = y +14
   end
i = i +1
end
screen.flip&#40;&#41;
end


--x = 100 unneeded?
--y = 10
--i = 1

function ButtonResponse&#40;&#41;
n = 1
u = 100
v = 10
confirm = 0
DirDepth = 0
while confirm == 0 do
pad = Controls.read&#40;&#41;
 
   if pad&#58;down&#40;&#41; then
    if v+14<=10+DimC*14 then
       n = n+1
       v = v + 14
       --screen.flip&#40;&#41;
       screen&#58;clear&#40;black&#41;
       OutputContents&#40;&#41;
       blitCursor&#40;&#41;
       System.sleep&#40;100&#41;
    end
    
    elseif pad&#58;up&#40;&#41; then
    if v>10 then
       n = n - 1
       v = v - 14
       --screen.flip&#40;&#41;
       OutputContents&#40;&#41;
       blitCursor&#40;&#41;
       System.sleep&#40;100&#41;
    end
    
   elseif pad&#58;cross&#40;&#41; then
      print&#40;i&#41;
      if contents&#91;i&#93;.directory == 1 then
         if DirDepth > 0 then
            -- nothing
         else
            CurrentDir, PrevDir = CurrentDir..contents&#91;i&#93;.name, CurrentDir
            contents = System.listDirectory&#40;CurrentDir&#41;
            DirDepth = DirDepth + 1 
            CleanDir&#40;&#41;
            OutputContents&#40;&#41;
         end
      else
       File = CurrentDir..contents&#91;i&#93;.name
       confirm = 1
      end
   end

end
end
--end

-- execute code
cleandir&#40;&#41;
OutputContents&#40;&#41;
n = 1
u = 100
v = 10
ButtonResponse&#40;&#41;

-- draw result
screen.flip&#40;&#41;
System.sleep&#40;3000&#41;
--while true do
--screen.waitVblankStart&#40;&#41;
--end 
Behold! The Underminer got hold of a PSP
Post Reply