Function help plz

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

Moderators: Shine, Insert_witty_name

Post Reply
2Xtremes2004
Posts: 53
Joined: Wed Aug 31, 2005 1:43 am

Function help plz

Post by 2Xtremes2004 »

Can anyone help me turn this into a function? Im still haveing a few problems trying to learn functions.

Code: Select all

      if usb==1 then
      System.usbDiskModeActivate()
      screen:blit(1, 3, usba)
      end
    
      if usb==0 then
      System.usbDiskModeDeactivate()
      end
    
      pad = Controls.read()
      if pad:select() then
         screen.waitVblankStart(20)
         if usb==1 then
         usb = 0
         else
         usb = 1
         end

I want my money back!?
chaos
Posts: 135
Joined: Sun Apr 10, 2005 5:05 pm

Post by chaos »

Code: Select all

-- a function to toggle usb mode
function toggleUSB()
	if usb==0 then
		System.usbDiskModeActivate()
		screen:blit(1, 3, usba)
		usb = 1
	else
		System.usbDiskModeDeactivate()
		usb = 0
	end
end

-- the rest of this should be in your main loop
pad = Controls.read()
if pad:select() then
	toggleUSB()
end 
Chaosmachine Studios: High Quality Homebrew.
2Xtremes2004
Posts: 53
Joined: Wed Aug 31, 2005 1:43 am

Post by 2Xtremes2004 »

thank you so much, this will give me a good example to help me learn more! Again, thx
I want my money back!?
chaos
Posts: 135
Joined: Sun Apr 10, 2005 5:05 pm

Post by chaos »

glad i could help.
Chaosmachine Studios: High Quality Homebrew.
Post Reply