forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

function arguments?

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development
View previous topic :: View next topic  
Author Message
the underminer



Joined: 03 Oct 2005
Posts: 124
Location: Netherlands

PostPosted: Fri Dec 09, 2005 5:16 am    Post subject: function arguments? Reply with quote

Code:

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
Back to top
View user's profile Send private message
JEK



Joined: 03 Sep 2005
Posts: 12
Location: Norway

PostPosted: Fri Dec 09, 2005 5:47 am    Post subject: Reply with quote

Change:
Code:

cursorscreen:clear


to something like this:
Code:

black = Color.new(0, 0, 0)
cursorscreen:clear(black)

_________________
--
JEK
Back to top
View user's profile Send private message Send e-mail
the underminer



Joined: 03 Oct 2005
Posts: 124
Location: Netherlands

PostPosted: Fri Dec 09, 2005 11:45 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
cancan



Joined: 18 Nov 2005
Posts: 30
Location: France

PostPosted: Sat Dec 10, 2005 12:18 am    Post subject: Reply with quote

I think that
Code:
cursorscreen:clear()

should be enough.
Back to top
View user's profile Send private message Visit poster's website
JoshDB



Joined: 05 Oct 2005
Posts: 87

PostPosted: Sat Dec 10, 2005 1:05 am    Post subject: Reply with quote

^^^^^^^^^

That's correct. Same thing for pad:sqaure(), etc. I'm pretty sure it's because they're bools.
Back to top
View user's profile Send private message Send e-mail AIM Address
the underminer



Joined: 03 Oct 2005
Posts: 124
Location: Netherlands

PostPosted: Mon Dec 12, 2005 3:04 am    Post subject: Reply with quote

excuses too all. JEK was right. Works now.

It's strange though, when I call this func:
Code:
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
Back to top
View user's profile Send private message
the underminer



Joined: 03 Oct 2005
Posts: 124
Location: Netherlands

PostPosted: Sat Dec 17, 2005 6:43 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
the underminer



Joined: 03 Oct 2005
Posts: 124
Location: Netherlands

PostPosted: Sun Dec 18, 2005 8:03 am    Post subject: Reply with quote

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

--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

_________________
Behold! The Underminer got hold of a PSP
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group