Seite 118 von 342 ErsteErste ... 18 68 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 168 218 ... LetzteLetzte
Zeige Ergebnis 3.511 bis 3.540 von 10238

Lua Programming Help Thread

This is a discussion on Lua Programming Help Thread within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; well...in the beginning you already made "RN9" equal to "complete". plus, it seems all this is pointless...: Code: if RN0 ...

  
  1. #3511
    QJ Gamer Green
    Points: 13.310, Level: 75
    Level completed: 15%, Points required for next Level: 340
    Overall activity: 0%

    Registriert seit
    Dec 2005
    Ort
    Here
    Beiträge
    2.715
    Points
    13.310
    Level
    75
    Downloads
    0
    Uploads
    0

    Standard

    well...in the beginning you already made "RN9" equal to "complete".

    plus, it seems all this is pointless...:
    Code:
    if RN0 == 1 and RN9 == complete then
    RN9 = one
    end
    
    if RN1 == 1 and RN9 == one then
    RN9 = two
    end
    
    if RN2 == 1 and RN9 == two then
    RN9 = three
    end


    [CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]

  2. #3512
    QJ Gamer Silver
    Points: 10.263, Level: 67
    Level completed: 54%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    2.326
    Points
    10.263
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    complete, one, two and three are all nil variables rather then string literals (which is what I assume you are trying to use).

  3. #3513
    QJ Gamer Green
    Points: 11.800, Level: 71
    Level completed: 38%, Points required for next Level: 250
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Ort
    Middle Europe
    Beiträge
    1.281
    Points
    11.800
    Level
    71
    Downloads
    0
    Uploads
    0

    Standard

    i have 2 questions:

    1st. how do i save text which i typed in MagicianFBs keyboard???

    Code:
    keyyellow = Color.new(255, 255, 0)
    keywhite = Color.new(255, 255, 255)
    keyblue = Color.new(0, 0, 255)
    keyblack = Color.new(0, 0, 0)
    keygreen = Color.new(0, 127, 0)
    keyorange = Color.new(255, 100, 0)
    keygray = Color.new(127, 127, 127)
    
    text = ""
    
    function drawRect(where, x, y, width, height, color)
    	where:drawLine(x, y, x+width, y, color)
    	where:drawLine(x+width, y, x+width, y+height, color)
    	where:drawLine(x+width, y+height, x, y+height, color)
    	where:drawLine(x, y+height, x, y, color)
    end
    
    keyscreen = Image.createEmpty(480, 272)
    keyscreen:clear(keyyellow)
    
    textdisp = Image.createEmpty(300, 172)
    textdisp:clear(keywhite)
    keyscreen:blit(150, 50, textdisp)
    
    key0123 = Image.createEmpty(26, 26)
    key4567 = Image.createEmpty(26, 26)
    key89 = Image.createEmpty(26, 26)
    keyabcd = Image.createEmpty(26, 26)
    keyefgh = Image.createEmpty(26, 26)
    keyijkl = Image.createEmpty(26, 26)
    keymnop = Image.createEmpty(26, 26)
    keyqrst = Image.createEmpty(26, 26)
    keyuvwx = Image.createEmpty(26, 26)
    keyyz = Image.createEmpty(26, 26)
    keysymb = Image.createEmpty(26, 26)
    keysymb2 = Image.createEmpty(26, 26)
    
    
    keybrd = Image.createEmpty(80, 106)
    keybrd:clear(keywhite)
    keybrd:blit(1, 1, key0123)
    keybrd:blit(27, 1, key4567)
    keybrd:blit(53, 1, key89)
    keybrd:blit(1, 27, keyabcd)
    keybrd:blit(27, 27, keyefgh)
    keybrd:blit(53, 27, keyijkl)
    keybrd:blit(1, 53, keymnop)
    keybrd:blit(27, 53, keyqrst)
    keybrd:blit(53, 53, keyuvwx)
    keybrd:blit(1, 79, keyyz)
    keybrd:blit(27, 79, keysymb)
    keybrd:blit(53, 79, keysymb2)
    
    keybrdsel = Image.createEmpty(78, 104)
    --Line 50
    keyposx = 1
    keyposy = 2
    
    function keysel()
    	keybrdsel:clear()
    	keyscreen:blit(40, 91, keybrd)
    	drawRect(keybrdsel, ((keyposx*26)-26), ((keyposy*26)-26), 26, 26, keyblue)
    	keyscreen:blit(41, 92, keybrdsel)
    	screen:blit(0, 0, keyscreen)
    	screen:flip()
    end
    
    function lowercase()
    	case = "lower"
    
    	key0123:clear()
    	key4567:clear()
    	key89:clear()
    	keyabcd:clear()
    	keyefgh:clear()
    	keyijkl:clear()
    	keymnop:clear()
    	keyqrst:clear()
    	keyuvwx:clear()
    	keyyz:clear()
    	keysymb:clear()
    	keysymb2:clear()
    
    	key0123:print(10, 4, "0", keyblack)
    	key0123:print(16, 10, "1", keyblack)
    	key0123:print(4, 10, "3", keyblack)
    	key0123:print(10, 16, "2", keyblack)
    
    	key4567:print(10, 4, "4", keyblack)
    	key4567:print(16, 10, "5", keyblack)
    	key4567:print(10, 16, "6", keyblack)
    	key4567:print(4, 10, "7", keyblack)
    
    	key89:print(10, 4, "8", keyblack)
    	key89:print(16, 10, "9", keyblack)
    
    	keyabcd:print(10, 4, "a", keyblack)
    	keyabcd:print(16, 10, "b", keyblack)
    	keyabcd:print(10, 16, "c", keyblack)
    	keyabcd:print(4, 10, "d", keyblack)
    
    	keyefgh:print(10, 4, "e", keyblack)
    	keyefgh:print(16, 10, "f", keyblack)
    	keyefgh:print(10, 16, "g", keyblack)
    	keyefgh:print(4, 10, "h", keyblack)
    
    -- Line 100
    	keyijkl:print(10, 4, "i", keyblack)
    	keyijkl:print(16, 10, "j", keyblack)
    	keyijkl:print(10, 16, "k", keyblack)
    	keyijkl:print(4, 10, "l", keyblack)
    
    	keymnop:print(10, 4, "m", keyblack)
    	keymnop:print(16, 10, "n", keyblack)
    	keymnop:print(10, 16, "o", keyblack)
    	keymnop:print(4, 10, "p", keyblack)
    
    	keyqrst:print(10, 4, "q", keyblack)
    	keyqrst:print(16, 10, "r", keyblack)
    	keyqrst:print(10, 16, "s", keyblack)
    	keyqrst:print(4, 10, "t", keyblack)
    
    	keyuvwx:print(10, 4, "u", keyblack)
    	keyuvwx:print(16, 10, "v", keyblack)
    	keyuvwx:print(10, 16, "w", keyblack)
    	keyuvwx:print(4, 10, "x", keyblack)
    	
    	keyyz:print(10, 4, "y", keyblack)
    	keyyz:print(16, 10, "z", keyblack)
    	
    	keysymb:print(10, 4, ":", keyblack)
    	keysymb:print(16, 10, ";", keyblack)
    	keysymb:print(10, 16, "-", keyblack)
    	keysymb:print(4, 10, "+", keyblack)
    
    	keysymb2:print(10, 4, ",", keyblack)
    	keysymb2:print(16, 10, "<", keyblack)
    	keysymb2:print(10, 16, ".", keyblack)
    	keysymb2:print(4, 10, ">", keyblack)
    
    	keybrd:clear(keywhite)
    	keybrd:blit(1, 1, key0123)
    	keybrd:blit(27, 1, key4567)
    	keybrd:blit(53, 1, key89)
    	keybrd:blit(1, 27, keyabcd)
    	keybrd:blit(27, 27, keyefgh)
    	keybrd:blit(53, 27, keyijkl)
    	keybrd:blit(1, 53, keymnop)
    	keybrd:blit(27, 53, keyqrst)
    	keybrd:blit(53, 53, keyuvwx)
    	keybrd:blit(1, 79, keyyz)
    	keybrd:blit(27, 79, keysymb)
    	keybrd:blit(53, 79, keysymb2)
    	keyscreen:blit(40, 91, keybrd)
    	keyscreen:blit(41, 92, keybrdsel)
    	screen:blit(0, 0, keyscreen)
    
    	screen:flip()
    end
    
    function uppercase()
    	case = "upper"
    
    	key0123:clear()
    	key4567:clear()
    	key89:clear()
    	keyabcd:clear()
    	keyefgh:clear()
    	keyijkl:clear()
    	keymnop:clear()
    --Line 150
    	keyqrst:clear()
    	keyuvwx:clear()
    	keyyz:clear()
    	keysymb:clear()
    	keysymb2:clear()
    
    	key0123:print(10, 4, "!", keyblack)
    	key0123:print(16, 10, "@", keyblack)
    	key0123:print(4, 10, "#", keyblack)
    	key0123:print(10, 16, "$", keyblack)
    
    	key4567:print(10, 4, "%", keyblack)
    	key4567:print(16, 10, "^", keyblack)
    	key4567:print(10, 16, "&", keyblack)
    	key4567:print(4, 10, "*", keyblack)
    
    	key89:print(4, 10, "(", keyblack)
    	key89:print(16, 10, ")", keyblack)
    
    	keyabcd:print(10, 4, "A", keyblack)
    	keyabcd:print(16, 10, "B", keyblack)
    	keyabcd:print(10, 16, "C", keyblack)
    	keyabcd:print(4, 10, "D", keyblack)
    
    	keyefgh:print(10, 4, "E", keyblack)
    	keyefgh:print(16, 10, "F", keyblack)
    	keyefgh:print(10, 16, "G", keyblack)
    	keyefgh:print(4, 10, "H", keyblack)
    
    	keyijkl:print(10, 4, "I", keyblack)
    	keyijkl:print(16, 10, "J", keyblack)
    	keyijkl:print(10, 16, "K", keyblack)
    	keyijkl:print(4, 10, "L", keyblack)
    
    	keymnop:print(10, 4, "M", keyblack)
    	keymnop:print(16, 10, "N", keyblack)
    	keymnop:print(10, 16, "O", keyblack)
    	keymnop:print(4, 10, "P", keyblack)
    
    	keyqrst:print(10, 4, "Q", keyblack)
    	keyqrst:print(16, 10, "R", keyblack)
    	keyqrst:print(10, 16, "S", keyblack)
    	keyqrst:print(4, 10, "T", keyblack)
    
    	keyuvwx:print(10, 4, "U", keyblack)
    	keyuvwx:print(16, 10, "V", keyblack)
    	keyuvwx:print(10, 16, "W", keyblack)
    	keyuvwx:print(4, 10, "X", keyblack)
    	
    	keyyz:print(10, 4, "Y", keyblack)
    -- Line 200
    	keyyz:print(16, 10, "Z", keyblack)
    	
    	keysymb:print(10, 4, "~", keyblack)
    	keysymb:print(16, 10, "_", keyblack)
    	keysymb:print(10, 16, "?", keyblack)
    	keysymb:print(4, 10, "/", keyblack)
    	
    	keysymb2:print(10, 4, "{", keyblack)
    	keysymb2:print(16, 10, "]", keyblack)
    	keysymb2:print(10, 16, "}", keyblack)
    	keysymb2:print(4, 10, "[", keyblack)
    
    	keybrd:clear(keywhite)
    	keybrd:blit(1, 1, key0123)
    	keybrd:blit(27, 1, key4567)
    	keybrd:blit(53, 1, key89)
    	keybrd:blit(1, 27, keyabcd)
    	keybrd:blit(27, 27, keyefgh)
    	keybrd:blit(53, 27, keyijkl)
    	keybrd:blit(1, 53, keymnop)
    	keybrd:blit(27, 53, keyqrst)
    	keybrd:blit(53, 53, keyuvwx)
    	keybrd:blit(1, 79, keyyz)
    	keybrd:blit(27, 79, keysymb)
    	keybrd:blit(53, 79, keysymb2)
    	keyscreen:blit(40, 91, keybrd)
    	keyscreen:blit(41, 92, keybrdsel)
    	screen:blit(0, 0, keyscreen)
    
    	screen:flip()
    end
    
    function prints()
    	if case=="lower" then
    		if pad:triangle() then
    			if keyposy==1 then
    				if keyposx==1 then
    					text = text .. "0"
    				elseif keyposx==2 then
    					text = text .. "4"
    				elseif keyposx==3 then
    					text = text .. "8"
    				end
    			elseif keyposy==2 then
    				if keyposx==1 then
    					text = text .. "a"
    				elseif keyposx==2 then
    					text = text .. "e"
    				elseif keyposx==3 then
    					text = text .. "i"
    				end
    			elseif keyposy==3 then
    				if keyposx==1 then
    					text = text .. "m"
    				elseif keyposx==2 then
    					text = text .. "q"
    				elseif keyposx==3 then
    					text = text .. "u"
    				end
    			elseif keyposy==4 then
    				if keyposx==1 then
    					text = text .. "y"
    				elseif keyposx==2 then
    					text = text .. ":"
    				elseif keyposx==3 then
    					text = text .. ","
    				end
    			end
    		elseif pad:circle() then
    			if keyposy==1 then
    				if keyposx==1 then
    					text = text .. "1"
    				elseif keyposx==2 then
    					text = text .. "5"
    				elseif keyposx==3 then
    					text = text .. "9"
    				end
    			elseif keyposy==2 then
    				if keyposx==1 then
    					text = text .. "b"
    				elseif keyposx==2 then
    					text = text .. "f"
    				elseif keyposx==3 then
    					text = text .. "j"
    				end
    			elseif keyposy==3 then
    				if keyposx==1 then
    					text = text .. "n"
    				elseif keyposx==2 then
    					text = text .. "r"
    				elseif keyposx==3 then
    					text = text .. "v"
    				end
    			elseif keyposy==4 then
    				if keyposx==1 then
    					text = text .. "z"
    				elseif keyposx==2 then
    					text = text .. ";"
    				elseif keyposx==3 then
    					text = text .. "<"
    				end
    			end
    		elseif pad:cross() then
    			if keyposy==1 then
    				if keyposx==1 then
    					text = text .. "2"
    				elseif keyposx==2 then
    					text = text .. "6"
    				elseif keyposx==3 then
    					text = text .. ""
    				end
    			elseif keyposy==2 then
    				if keyposx==1 then
    					text = text .. "c"
    				elseif keyposx==2 then
    					text = text .. "g"
    				elseif keyposx==3 then
    					text = text .. "k"
    				end
    			elseif keyposy==3 then
    				if keyposx==1 then
    					text = text .. "o"
    				elseif keyposx==2 then
    					text = text .. "s"
    				elseif keyposx==3 then
    					text = text .. "w"
    				end
    			elseif keyposy==4 then
    				if keyposx==1 then
    					text = text .. ""
    				elseif keyposx==2 then
    					text = text .. "-"
    				elseif keyposx==3 then
    					text = text .. "."
    				end
    			end
    		elseif pad:square() then
    			if keyposy==1 then
    				if keyposx==1 then
    					text = text .. "3"
    				elseif keyposx==2 then
    					text = text .. "7"
    				elseif keyposx==3 then
    					text = text .. " "
    				end
    			elseif keyposy==2 then
    				if keyposx==1 then
    					text = text .. "d"
    				elseif keyposx==2 then
    					text = text .. "h"
    				elseif keyposx==3 then
    					text = text .. "l"
    				end
    			elseif keyposy==3 then
    				if keyposx==1 then
    					text = text .. "p"
    				elseif keyposx==2 then
    					text = text .. "t"
    				elseif keyposx==3 then
    					text = text .. "x"
    				end
    			elseif keyposy==4 then
    				if keyposx==1 then
    					text = text .. ""
    				elseif keyposx==2 then
    					text = text .. "+"
    				elseif keyposx==3 then
    					text = text .. ">"
    				end
    			end
    		elseif pad:l() then
    			text = string.sub(text, 1, string.len(text)-1)
    		elseif pad:r() then
    			text = text .. " "
    		end
    	elseif case=="upper" then
    		if pad:triangle() then
    			if keyposy==1 then
    				if keyposx==1 then
    					text = text .. "!"
    				elseif keyposx==2 then
    					text = text .. "%"
    				elseif keyposx==3 then
    					text = text .. ""
    				end
    			elseif keyposy==2 then
    				if keyposx==1 then
    					text = text .. "A"
    				elseif keyposx==2 then
    					text = text .. "E"
    				elseif keyposx==3 then
    					text = text .. "I"
    				end
    			elseif keyposy==3 then
    				if keyposx==1 then
    					text = text .. "M"
    				elseif keyposx==2 then
    					text = text .. "Q"
    				elseif keyposx==3 then
    					text = text .. "U"
    				end
    			elseif keyposy==4 then
    				if keyposx==1 then
    					text = text .. "Y"
    				elseif keyposx==2 then
    					text = text .. "~"
    				elseif keyposx==3 then
    					text = text .. "{"
    				end
    			end
    		elseif pad:circle() then
    			if keyposy==1 then
    				if keyposx==1 then
    					text = text .. "@"
    				elseif keyposx==2 then
    					text = text .. "^"
    				elseif keyposx==3 then
    					text = text .. ")"
    				end
    			elseif keyposy==2 then
    				if keyposx==1 then
    					text = text .. "B"
    				elseif keyposx==2 then
    					text = text .. "F"
    				elseif keyposx==3 then
    					text = text .. "J"
    				end
    			elseif keyposy==3 then
    				if keyposx==1 then
    					text = text .. "N"
    				elseif keyposx==2 then
    					text = text .. "R"
    				elseif keyposx==3 then
    					text = text .. "V"
    				end
    			elseif keyposy==4 then
    				if keyposx==1 then
    					text = text .. "Z"
    				elseif keyposx==2 then
    					text = text .. "_"
    				elseif keyposx==3 then
    					text = text .. "]"
    				end
    			end
    		elseif pad:cross() then
    			if keyposy==1 then
    				if keyposx==1 then
    					text = text .. "#"
    				elseif keyposx==2 then
    					text = text .. "&"
    				elseif keyposx==3 then
    					text = text .. ""
    				end
    			elseif keyposy==2 then
    				if keyposx==1 then
    					text = text .. "C"
    				elseif keyposx==2 then
    					text = text .. "G"
    				elseif keyposx==3 then
    					text = text .. "K"
    				end
    			elseif keyposy==3 then
    				if keyposx==1 then
    					text = text .. "O"
    				elseif keyposx==2 then
    					text = text .. "S"
    				elseif keyposx==3 then
    					text = text .. "W"
    				end
    			elseif keyposy==4 then
    				if keyposx==1 then
    					text = text .. ""
    				elseif keyposx==2 then
    					text = text .. "?"
    				elseif keyposx==3 then
    					text = text .. "}"
    				end
    			end
    		elseif pad:square() then
    			if keyposy==1 then
    				if keyposx==1 then
    					text = text .. "$"
    				elseif keyposx==2 then
    					text = text .. "*"
    				elseif keyposx==3 then
    					text = text .. "("
    				end
    			elseif keyposy==2 then
    				if keyposx==1 then
    					text = text .. "D"
    				elseif keyposx==2 then
    					text = text .. "H"
    				elseif keyposx==3 then
    					text = text .. "L"
    				end
    			elseif keyposy==3 then
    				if keyposx==1 then
    					text = text .. "P"
    				elseif keyposx==2 then
    					text = text .. "T"
    				elseif keyposx==3 then
    					text = text .. "X"
    				end
    			elseif keyposy==4 then
    				if keyposx==1 then
    					text = text .. ""
    				elseif keyposx==2 then
    					text = text .. "/"
    				elseif keyposx==3 then
    					text = text .. "["
    				end
    			end
    		elseif pad:l() then
    			text = string.sub(text, 1, string.len(text)-1)
    		elseif pad:r() then
    			text = text .. " "
    		end
    	end
    	maxline = math.ceil(string.len(text)/37)
    	printline = 1
    	textdisp:clear(keywhite)
    	while printline<=maxline do
    		if printline==maxline then
    			textend = string.len(text)
    		else
    			textend = printline*37
    		end
    		textdisp:print(3, 3+((printline-1)*8), string.sub(text, (printline-1)*37+1, textend), keyblack)
    		printline = printline+1
    		if textend==string.len(text) then
    			break
    		end
    	end
    	if string.len(text)<=37 then
    		curstextx = (3+(string.len(string.sub(text, (maxline-1)*37, string.len(text)))*8))
    	elseif string.len(text)>37 then
    		curstextx = (3+(string.len(string.sub(text, (maxline-1)*37, string.len(text)-1))*8))
    	end
    	textdisp:print(curstextx, 3+((maxline-1)*8), "|", keygreen)
    	keyscreen:blit(150, 50, textdisp)
    	screen:blit(0, 0, keyscreen)
    	
    	screen:flip()
    end
    
    		
    
    function keyboard()
    	text = ""
    	keyposx = 1
    	keyposy = 2
    	keyscreen:clear(keyyellow)
    	drawRect(keyscreen, 149, 49, 301, 173, keygray)
    	drawRect(keyscreen, 39, 90, 81, 107, keygray)
    	keyscreen:print(0, 17, " " .. string.rep("=", 22) .. "Text Entering" .. string.rep("=", 23), keyorange)
    	keyscreen:print(8, 208, " Select = Shift", keyblue)
    	keyscreen:print(8, 216, " Start = Enter", keyblue)
    	keyscreen:print(8, 224, " D-pad = Select Key", keyblue)
    	keyscreen:print(8, 233, " Control Pad = Print Character", keyblue)
    	keyscreen:print(8, 240, " L = Backspace", keyblue)
    	keyscreen:print(8, 248, " R = Space", keyblue)
    	keyscreen:blit(150, 50, textdisp)
    	keyscreen:blit(40, 91, keybrd)
    	keyscreen:blit(41, 92, keybrdsel)
    	lowercase()
    
    	while true do
    		screen.waitVblankStart(8)
    
    		pad = Controls.read()
    
    		if pad:up() then
    			if keyposy==1 then
    				keyposy = 4
    			else
    				keyposy = keyposy-1
    			end
    			keysel()
    		elseif pad:down() then
    			if keyposy==4 then
    				keyposy = 1
    			else
    				keyposy = keyposy+1
    			end
    			keysel()
    		elseif pad:right() then
    			if keyposx==3 then
    				keyposx = 1
    			else
    				keyposx = keyposx+1
    			end
    			keysel()
    		elseif pad:left() then
    			if keyposx==1 then
    				keyposx = 3
    			else
    				keyposx = keyposx-1
    			end
    			keysel()
    		elseif pad:l() then
    			prints()
    		elseif pad:r() then
    			prints()
    		elseif pad:triangle() then
    			prints()
    		elseif pad:circle() then
    			prints()
    		elseif pad:cross() then
    			prints()
    		elseif pad:square() then
    			prints()
    		elseif pad:select() then
    			if case=="lower" then
    				uppercase()
    			elseif case=="upper" then
    				lowercase()
    			end
    		elseif pad:start() then
    			save.text()
    		elseif pad:note() then
    			break
    		end
    	end
    	keyscreen:clear()
    	screen:flip()
    	return text
    end
    2nd:

    how do i give SELECT button 2 functions?
    like:

    Code:
    if pad:select() then 
    System.usbDiskModeActivate()
    end
    and now when i press SELECT again i want to usbDikModeDeactivate..

    pls help

  4. #3514
    QJ Gamer Blue
    Points: 5.768, Level: 49
    Level completed: 9%, Points required for next Level: 182
    Overall activity: 0%

    Registriert seit
    May 2006
    Beiträge
    457
    Points
    5.768
    Level
    49
    Downloads
    0
    Uploads
    0

    Standard

    i can answer the 2 qestion :

    select = 1

    if pad:select() then
    if select == 1 then
    select = 2
    System.usbDiskModeActivat e()
    end
    end

    if pad:select() then
    if select == 2 then
    select = 1
    System.usbDiskModeDeactiv ate()
    end
    end

  5. #3515
    QJ Gamer Green
    Points: 11.800, Level: 71
    Level completed: 38%, Points required for next Level: 250
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Ort
    Middle Europe
    Beiträge
    1.281
    Points
    11.800
    Level
    71
    Downloads
    0
    Uploads
    0

    Standard

    it doesnt work :/ it doesnt even activate USB but still thx for caring

  6. #3516
    QJ Gamer Bronze
    Points: 5.924, Level: 49
    Level completed: 87%, Points required for next Level: 26
    Overall activity: 0%

    Registriert seit
    Feb 2006
    Ort
    Earth, UK
    Beiträge
    457
    Points
    5.924
    Level
    49
    Downloads
    0
    Uploads
    0

    Standard

    Question 2

    Code:
    UsbOn = 0
    
    if pad:select()  and oldpad:select()~=pad:select() and UsbOn == 0 then 
    select = 1
    end
    
    if pad:select()  and oldpad:select()~=pad:select() and UsbOn == 1 then 
    select = 0
    end
    
    if UsbOn == 0 then
    System.usbDiskModeActivate()
    end
    if UsbOn == 1 then
    System.usbDiskModeDeactivate()
    end
    <<Put A message Here>>
    <<Just made another rubbish website visit it here.>>

  7. #3517
    QJ Gamer Green
    Points: 11.800, Level: 71
    Level completed: 38%, Points required for next Level: 250
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Ort
    Middle Europe
    Beiträge
    1.281
    Points
    11.800
    Level
    71
    Downloads
    0
    Uploads
    0

    Standard

    thx i will try it!

    edit. hmm now it activates USB right after i acces the app, then when i press SELECT i just get Error "oldpad" something...

    Heres my full code:

    Code:
    -- Moj prvy LUA program
    -- Author: myschoo
    
    -- ******* Variables ********
    
    green = Color.new(0,255,0)
    zelena = Color.new(34,70,77)
    oranzova = Color.new(214,128,11)
    modra = Color.new(0,24,240)
    bordova = Color.new(138,0,11)
    myschoo = Color.new(236,225,28)
    biela = Color.new(255,255,255)
    
    upPressed = 'Drzis sipku nahor'
    downPressed = 'Drzis sipku nadol'
    leftPressed = 'Drzis sipku dolava'
    rightPressed = 'Drzis sipku doprava'
    LPressed = 'Drzis "L" tlacitko'
    
    -- *****Main Loop******
    
    while true do
    
    dofile("key.lua")
    
    back = Image.load("blue.jpg")
    boltsnd = Sound.load("sound.wav")
    
    screen:blit(0, 0, back) 
    
    screen:print(145, 5, 'Podrz START pre vypnutie', biela)
    screen:print(155, 15, "Podrz SELECT pre USB", biela)
    screen:print(155, 25, "Podrz krizik pre zvuk", biela)
    screen:print(145, 35, 'Podrz R+stvorec pre info', biela)
    screen:print(145, 45, 'Podrz R+L pre klavesnicu', biela)
    
    pad = Controls.read()
    
    if pad:up() then
    screen:print(185,125,upPressed,green)
    end
    if pad:down() then
    screen:print(185,125,downPressed,zelena)
    end
    if pad:left() then
    screen:print(185,125,leftPressed,oranzova)
    end
    if pad:right() then
    screen:print(185,125,rightPressed,modra)
    end
    if pad:l() then
    screen:print(185,125,LPressed,bordova)
    end
    if pad:r() then
    screen:print(185,125,'Drzis "R" tlacitko',green)
    end
    if pad:triangle() then
    screen:print(185,125,'Drzis trojuholnik',zelena)
    end
    if pad:circle() then
    screen:print(185,125,'Drzis kruzok',oranzova)
    end
    if pad:cross() then
    boltsnd:play()
    screen.flip()
    Music.volume(128)
    end
    if pad:square() then
    screen:print(185,125,'Drzis stvorec',bordova)
    end
    UsbOn = 0
    
    if pad:select()  and oldpad:select()~=pad:select() and UsbOn == 0 then 
    select = 1
    end
    
    if pad:select()  and oldpad:select()~=pad:select() and UsbOn == 1 then 
    select = 0
    end
    
    if UsbOn == 0 then
    System.usbDiskModeActivate()
    end
    if UsbOn == 1 then
    System.usbDiskModeDeactivate()
    end
    if pad:start() then
    break
    end
    if pad:square() and pad:r() then
    screen:print(175, 255, 'Autor: myschoo', myschoo)
    end
    if pad:r() and pad:l() then
    -- Examples
    print(keyboard())
    thetext = keyboard()
    end
    
    screen.waitVblankStart()
    screen.flip()
    end
    and yeh i just started yesterday

  8. #3518
    QJ Gamer Green
    Points: 13.310, Level: 75
    Level completed: 15%, Points required for next Level: 340
    Overall activity: 0%

    Registriert seit
    Dec 2005
    Ort
    Here
    Beiträge
    2.715
    Points
    13.310
    Level
    75
    Downloads
    0
    Uploads
    0

    Standard

    Code:
    select_does_this = 1
    
    if pad:select() and select_does_this == 1 then
    select_does_this = 2
    elseif select_does_this == 2 then
    select_does_this = 1
    end
    
    if select_does_this == 1 then
    System.usbDiskModeDeactivate()
    elseif select_does_this == 2 then
    System.usbDiskModeActivate()
    end
    THAT should work. i never got the "oldpad" way myself...lol
    [CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]

  9. #3519
    QJ Gamer Green
    Points: 11.800, Level: 71
    Level completed: 38%, Points required for next Level: 250
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Ort
    Middle Europe
    Beiträge
    1.281
    Points
    11.800
    Level
    71
    Downloads
    0
    Uploads
    0

    Standard

    yeh this is quiet better...but there is still problem... well..i press SELECT and my PSP USB activates..thats ok :) but then when i stop holding button USB Deactivates, so basicly i have to hold button to be connected now

    Code:
    -- Moj prvy LUA program
    -- Author: myschoo
    
    -- ******* Variables ********
    
    green = Color.new(0,255,0)
    zelena = Color.new(34,70,77)
    oranzova = Color.new(214,128,11)
    modra = Color.new(0,24,240)
    bordova = Color.new(138,0,11)
    myschoo = Color.new(236,225,28)
    biela = Color.new(255,255,255)
    
    upPressed = 'Drzis sipku nahor'
    downPressed = 'Drzis sipku nadol'
    leftPressed = 'Drzis sipku dolava'
    rightPressed = 'Drzis sipku doprava'
    LPressed = 'Drzis "L" tlacitko'
    
    -- *****Main Loop******
    
    while true do
    
    dofile("key.lua")
    
    back = Image.load("blue.jpg")
    boltsnd = Sound.load("sound.wav")
    
    screen:blit(0, 0, back) 
    
    screen:print(145, 5, 'Podrz START pre vypnutie', biela)
    screen:print(155, 15, "Podrz SELECT pre USB", biela)
    screen:print(155, 25, "Podrz krizik pre zvuk", biela)
    screen:print(145, 35, 'Podrz R+stvorec pre info', biela)
    screen:print(145, 45, 'Podrz R+L pre klavesnicu', biela)
    
    pad = Controls.read()
    
    if pad:up() then
    screen:print(185,125,upPressed,green)
    end
    if pad:down() then
    screen:print(185,125,downPressed,zelena)
    end
    if pad:left() then
    screen:print(185,125,leftPressed,oranzova)
    end
    if pad:right() then
    screen:print(185,125,rightPressed,modra)
    end
    if pad:l() then
    screen:print(185,125,LPressed,bordova)
    end
    if pad:r() then
    screen:print(185,125,'Drzis "R" tlacitko',green)
    end
    if pad:triangle() then
    screen:print(185,125,'Drzis trojuholnik',zelena)
    end
    if pad:circle() then
    screen:print(185,125,'Drzis kruzok',oranzova)
    end
    if pad:cross() then
    boltsnd:play()
    screen.flip()
    Music.volume(128)
    end
    if pad:square() then
    screen:print(185,125,'Drzis stvorec',bordova)
    end
    select_does_this = 1
    
    if pad:select() and select_does_this == 1 then
    select_does_this = 2
    elseif select_does_this == 2 then
    select_does_this = 1
    end
    
    if select_does_this == 1 then
    System.usbDiskModeDeactivate()
    elseif select_does_this == 2 then
    System.usbDiskModeActivate()
    end
    if pad:start() then
    break
    end
    if pad:square() and pad:r() then
    screen:print(175, 255, 'Autor: myschoo', myschoo)
    end
    if pad:r() and pad:l() then
    -- Examples
    print(keyboard())
    thetext = keyboard()
    end
    
    screen.waitVblankStart()
    screen.flip()
    end
    thx for help guys i appreciate it! ;)

  10. #3520
    Developer
    Points: 4.318, Level: 41
    Level completed: 84%, Points required for next Level: 32
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Beiträge
    205
    Points
    4.318
    Level
    41
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von EminentJonFrost
    Code:
    select_does_this = 1
    
    if pad:select() and select_does_this == 1 then
    select_does_this = 2
    elseif select_does_this == 2 then
    select_does_this = 1
    end
    
    if select_does_this == 1 then
    System.usbDiskModeDeactivate()
    elseif select_does_this == 2 then
    System.usbDiskModeActivate()
    end
    THAT should work. i never got the "oldpad" way myself...lol
    It doesn't work right because you don't check for pad:select when select_does_this==2. Also, you'll have to be very quick or just lucky if you don't use the "oldpad" way, because the code might loop more than once while you are pressing the button, so it would change back and forth.


    One of many solutions:

    At the top of your code with the rest of the constant definitions, put this:
    Code:
    oldpad=Controls.read()
    usbmode=false
    When you want to change the USB mode (inside your loop):
    Code:
    if pad:select() and oldpad:select()~=pad:select() then
       if usbmode then
          System.usbDiskModeDeactivate()
       else
          System.usbDiskModeActivate()
       end
    end
    At the bottom of your loop (still inside):
    Code:
    oldpad=pad
    Note that the "oldpad" way is just comparing your button presses in the current loop to your button presses in the last loop. If you only want your "if" statement to execute once, then you have to make sure that your button presses in the current loop isn't equal to the ones in your previous loop. This is because code runs so fast that even though you think you are just pressing a button once, the code may loop several times.

  11. #3521
    QJ Gamer Green
    Points: 11.800, Level: 71
    Level completed: 38%, Points required for next Level: 250
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Ort
    Middle Europe
    Beiträge
    1.281
    Points
    11.800
    Level
    71
    Downloads
    0
    Uploads
    0

    Standard

    ok i added ur suggestions and codes and its still SAME... i press button USB activated i realease button USB deactivated... but i want it to stay activated after i stop holding that button

    Code:
    -- Moj prvy LUA program
    -- Author: myschoo
    
    -- ******* Variables ********
    
    green = Color.new(0,255,0)
    zelena = Color.new(34,70,77)
    oranzova = Color.new(214,128,11)
    modra = Color.new(0,24,240)
    bordova = Color.new(138,0,11)
    myschoo = Color.new(236,225,28)
    biela = Color.new(255,255,255)
    
    upPressed = 'Drzis sipku nahor'
    downPressed = 'Drzis sipku nadol'
    leftPressed = 'Drzis sipku dolava'
    rightPressed = 'Drzis sipku doprava'
    LPressed = 'Drzis "L" tlacitko'
    
    -- *****Main Loop******
    
    while true do
    
    dofile("key.lua")
    
    back = Image.load("blue.jpg")
    boltsnd = Sound.load("sound.wav")
    
    screen:blit(0, 0, back) 
    
    screen:print(145, 5, 'Podrz START pre vypnutie', biela)
    screen:print(155, 15, "Podrz SELECT pre USB", biela)
    screen:print(155, 25, "Podrz krizik pre zvuk", biela)
    screen:print(145, 35, 'Podrz R+stvorec pre info', biela)
    screen:print(145, 45, 'Podrz R+L pre klavesnicu', biela)
    
    pad = Controls.read()
    
    if pad:up() then
    screen:print(185,125,upPressed,green)
    end
    if pad:down() then
    screen:print(185,125,downPressed,zelena)
    end
    if pad:left() then
    screen:print(185,125,leftPressed,oranzova)
    end
    if pad:right() then
    screen:print(185,125,rightPressed,modra)
    end
    if pad:l() then
    screen:print(185,125,LPressed,bordova)
    end
    if pad:r() then
    screen:print(185,125,'Drzis "R" tlacitko',green)
    end
    if pad:triangle() then
    screen:print(185,125,'Drzis trojuholnik',zelena)
    end
    if pad:circle() then
    screen:print(185,125,'Drzis kruzok',oranzova)
    end
    if pad:cross() then
    boltsnd:play()
    screen.flip()
    Music.volume(128)
    end
    if pad:square() then
    screen:print(185,125,'Drzis stvorec',bordova)
    end
    
    oldpad=Controls.read()
    usbmode=false
    select_does_this = 1
    
    if pad:select() and select_does_this == 1 then
    select_does_this = 2
    elseif select_does_this == 2 then
    select_does_this = 1
    end
    
    if pad:select() and oldpad:select()~=pad:select() then
    if usbmode then
    System.usbDiskModeDeactivate()
    else
    System.usbDiskModeActivate()
    end
    end
    
    if select_does_this == 1 then
    System.usbDiskModeDeactivate()
    elseif select_does_this == 2 then
    System.usbDiskModeActivate()
    
    oldpad=pad
    end
    if pad:start() then
    break
    end
    if pad:square() and pad:r() then
    screen:print(175, 255, 'Autor: myschoo', myschoo)
    end
    if pad:r() and pad:l() then
    -- Examples
    print(keyboard())
    thetext = keyboard()
    end
    
    screen.waitVblankStart()
    screen.flip()
    end

  12. #3522
    QJ Gamer Green
    Points: 7.598, Level: 58
    Level completed: 24%, Points required for next Level: 152
    Overall activity: 0%

    Registriert seit
    Nov 2005
    Ort
    NoWhere . . . .
    Beiträge
    1.266
    Points
    7.598
    Level
    58
    Downloads
    0
    Uploads
    0

    Standard

    i keep getting expected then near = at line 50 with this code
    Code:
    if menustatus => 4 then
    menustatus = 1
    end
    but this code works
    Code:
    if menustatus <= 0 then
    menustatus = 3
    end

  13. #3523
    QJ Gamer Blue
    Points: 5.768, Level: 49
    Level completed: 9%, Points required for next Level: 182
    Overall activity: 0%

    Registriert seit
    May 2006
    Beiträge
    457
    Points
    5.768
    Level
    49
    Downloads
    0
    Uploads
    0

    Standard

    i think it is meant to be like this :
    if menustatus >= 4 then
    menustatus = 1
    end

  14. #3524
    sceKernelExitGame();
    Points: 19.955, Level: 89
    Level completed: 21%, Points required for next Level: 395
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Ort
    New York
    Beiträge
    3.126
    Points
    19.955
    Level
    89
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von PSP-Maniac
    i think it is meant to be like this :
    if menustatus >= 4 then
    menustatus = 1
    end
    Yeah, it is

  15. #3525
    QJ Gamer Green
    Points: 7.598, Level: 58
    Level completed: 24%, Points required for next Level: 152
    Overall activity: 0%

    Registriert seit
    Nov 2005
    Ort
    NoWhere . . . .
    Beiträge
    1.266
    Points
    7.598
    Level
    58
    Downloads
    0
    Uploads
    0

    Standard

    ya it works great i took that part from the lua sniplets thread at the top and didnt think that idbe wrong so i didnt check.

  16. #3526
    QJ Gamer Green
    Points: 11.800, Level: 71
    Level completed: 38%, Points required for next Level: 250
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Ort
    Middle Europe
    Beiträge
    1.281
    Points
    11.800
    Level
    71
    Downloads
    0
    Uploads
    0

    Standard

    can anyone help me? ??????????????? pls!!

  17. #3527
    Developer
    Points: 4.318, Level: 41
    Level completed: 84%, Points required for next Level: 32
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Beiträge
    205
    Points
    4.318
    Level
    41
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von myschoo
    ok i added ur suggestions and codes and its still SAME... i press button USB activated i realease button USB deactivated... but i want it to stay activated after i stop holding that button
    You almost did.

    The "oldpad = Controls.read()" and "usbmode=false" lines are supposed to be before the while loop, in your ***Variables*** section.

    EDIT: Also, you need to get rid of these parts:

    Code:
    if pad:select() and select_does_this == 1 then
    select_does_this = 2
    elseif select_does_this == 2 then
    select_does_this = 1
    end
    and

    Code:
    if select_does_this == 1 then
    System.usbDiskModeDeactivate()
    elseif select_does_this == 2 then
    System.usbDiskModeActivate()
    
    oldpad=pad
    end
    And put the "oldpad = pad" line at the end of the while loop.

  18. #3528
    QJ Gamer Green
    Points: 11.800, Level: 71
    Level completed: 38%, Points required for next Level: 250
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Ort
    Middle Europe
    Beiträge
    1.281
    Points
    11.800
    Level
    71
    Downloads
    0
    Uploads
    0

    Standard

    thx i will try it asap!!

    Code:
    -- Moj prvy LUA program
    -- Author: myschoo
    
    -- ******* Variables ********
    
    green = Color.new(0,255,0)
    zelena = Color.new(34,70,77)
    oranzova = Color.new(214,128,11)
    modra = Color.new(0,24,240)
    bordova = Color.new(138,0,11)
    myschoo = Color.new(236,225,28)
    biela = Color.new(255,255,255)
    
    upPressed = 'Drzis sipku nahor'
    downPressed = 'Drzis sipku nadol'
    leftPressed = 'Drzis sipku dolava'
    rightPressed = 'Drzis sipku doprava'
    LPressed = 'Drzis "L" tlacitko'
    
    oldpad=Controls.read()
    usbmode=false
    
    -- *****Main Loop******
    
    while true do
    
    dofile("key.lua")
    
    back = Image.load("blue.jpg")
    boltsnd = Sound.load("sound.wav")
    
    screen:blit(0, 0, back) 
    
    screen:print(145, 5, 'Podrz START pre vypnutie', biela)
    screen:print(155, 15, "Podrz SELECT pre USB", biela)
    screen:print(155, 25, "Podrz krizik pre zvuk", biela)
    screen:print(145, 35, 'Podrz R+stvorec pre info', biela)
    screen:print(145, 45, 'Podrz R+L pre klavesnicu', biela)
    
    pad = Controls.read()
    
    if pad:up() then
    screen:print(185,125,upPressed,green)
    end
    if pad:down() then
    screen:print(185,125,downPressed,zelena)
    end
    if pad:left() then
    screen:print(185,125,leftPressed,oranzova)
    end
    if pad:right() then
    screen:print(185,125,rightPressed,modra)
    end
    if pad:l() then
    screen:print(185,125,LPressed,bordova)
    end
    if pad:r() then
    screen:print(185,125,'Drzis "R" tlacitko',green)
    end
    if pad:triangle() then
    screen:print(185,125,'Drzis trojuholnik',zelena)
    end
    if pad:circle() then
    screen:print(185,125,'Drzis kruzok',oranzova)
    end
    if pad:cross() then
    boltsnd:play()
    screen.flip()
    Music.volume(128)
    end
    if pad:square() then
    screen:print(185,125,'Drzis stvorec',bordova)
    end
    
    if pad:select() and oldpad:select()~=pad:select() then
    if usbmode then
    System.usbDiskModeDeactivate()
    else
    System.usbDiskModeActivate()
    end
    end
    
    if pad:start() then
    break
    end
    if pad:square() and pad:r() then
    screen:print(175, 255, 'Autor: myschoo', myschoo)
    end
    if pad:r() and pad:l() then
    -- Examples
    print(keyboard())
    thetext = keyboard()
    end
    
    screen.waitVblankStart()
    screen.flip()
    oldpad = pad
    end
    now when i press SELECT it activates USB but wneh i press SELECT again nothing happens (:Cry:
    Geändert von myschoo (09-24-2006 um 12:17 PM Uhr)

  19. #3529
    Your Fate is Grim...
    Points: 11.640, Level: 70
    Level completed: 98%, Points required for next Level: 10
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Beiträge
    2.269
    Points
    11.640
    Level
    70
    Downloads
    0
    Uploads
    0

    Post

    Zitat Zitat von myschoo
    thx i will try it asap!!

    Code:
    -- Moj prvy LUA program
    -- Author: myschoo
    
    -- ******* Variables ********
    
    green = Color.new(0,255,0)
    zelena = Color.new(34,70,77)
    oranzova = Color.new(214,128,11)
    modra = Color.new(0,24,240)
    bordova = Color.new(138,0,11)
    myschoo = Color.new(236,225,28)
    biela = Color.new(255,255,255)
    
    upPressed = 'Drzis sipku nahor'
    downPressed = 'Drzis sipku nadol'
    leftPressed = 'Drzis sipku dolava'
    rightPressed = 'Drzis sipku doprava'
    LPressed = 'Drzis "L" tlacitko'
    
    oldpad=Controls.read()
    usbmode=false
    
    -- *****Main Loop******
    
    while true do
    
    dofile("key.lua")
    
    back = Image.load("blue.jpg")
    boltsnd = Sound.load("sound.wav")
    
    screen:blit(0, 0, back) 
    
    screen:print(145, 5, 'Podrz START pre vypnutie', biela)
    screen:print(155, 15, "Podrz SELECT pre USB", biela)
    screen:print(155, 25, "Podrz krizik pre zvuk", biela)
    screen:print(145, 35, 'Podrz R+stvorec pre info', biela)
    screen:print(145, 45, 'Podrz R+L pre klavesnicu', biela)
    
    pad = Controls.read()
    
    if pad:up() then
    screen:print(185,125,upPressed,green)
    end
    if pad:down() then
    screen:print(185,125,downPressed,zelena)
    end
    if pad:left() then
    screen:print(185,125,leftPressed,oranzova)
    end
    if pad:right() then
    screen:print(185,125,rightPressed,modra)
    end
    if pad:l() then
    screen:print(185,125,LPressed,bordova)
    end
    if pad:r() then
    screen:print(185,125,'Drzis "R" tlacitko',green)
    end
    if pad:triangle() then
    screen:print(185,125,'Drzis trojuholnik',zelena)
    end
    if pad:circle() then
    screen:print(185,125,'Drzis kruzok',oranzova)
    end
    if pad:cross() then
    boltsnd:play()
    screen.flip()
    Music.volume(128)
    end
    if pad:square() then
    screen:print(185,125,'Drzis stvorec',bordova)
    end
    
    if pad:select() and oldpad:select()~=pad:select() then
    if usbmode then
    System.usbDiskModeDeactivate()
    else
    System.usbDiskModeActivate()
    end
    end
    
    if pad:start() then
    break
    end
    if pad:square() and pad:r() then
    screen:print(175, 255, 'Autor: myschoo', myschoo)
    end
    if pad:r() and pad:l() then
    -- Examples
    print(keyboard())
    thetext = keyboard()
    end
    
    screen.waitVblankStart()
    screen.flip()
    oldpad = pad
    end
    now when i press SELECT it activates USB but wneh i press SELECT again nothing happens (:Cry:

    try this:

    Code:
    --put thsi outside your main loop--
    
    selectPressed = false
    usbInit = false
    
    --put this in youre main loop--
    
    if pad:select() then
         if not selectPressed then
             if usbInit == false then
                usbInit = true
             end
         selectPressed = true
    else
    selectPressed = false
    end
    
    if usbInit == true
    --usb acivate code, im too lazy to find it--
    else
    --usb UNactivate--
    end

    with the above code, you dont need oldpad, it works 100% of them time.
    --------------------------------------------------------------------------------------

  20. #3530
    I'm Baaaack!
    Points: 17.067, Level: 83
    Level completed: 44%, Points required for next Level: 283
    Overall activity: 52,0%

    Registriert seit
    May 2006
    Ort
    Nowhere
    Beiträge
    2.186
    Points
    17.067
    Level
    83
    Downloads
    0
    Uploads
    0

    Standard

    Try this:

    Code:
    usbmode = "false"
    if pad:select() and oldpad:select() ~= pad:select() and usbmode == "false" then
    System.usbDiskModeActivate()
    end
    if pad:select() and oldpad:select() ~= pad:select() and usbmode == "true" then
    System.usbDiskModeDeactivate()
    end

  21. #3531
    Developer
    Points: 4.318, Level: 41
    Level completed: 84%, Points required for next Level: 32
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Beiträge
    205
    Points
    4.318
    Level
    41
    Downloads
    0
    Uploads
    0

    Standard

    You guys are hilarious...he won't learn if you just give him code to "try" without telling him what's wrong.

    On my suggestion, I forgot to make it switch the state of "usbmode," so it always tries to activate it. All you have to do is change it back and forth when select is pressed:

    Code:
    if pad:select() and oldpad:select()~=pad:select() then
    if usbmode then
    System.usbDiskModeDeactivate()
    usbmode=false
    else
    System.usbDiskModeActivate()
    usbmode=true
    end
    end
    Just go with what makes sense to you. I tried to explain "oldpad" in my last post, but as mentioned it is not the only way.

  22. #3532
    QJ Gamer Green
    Points: 11.800, Level: 71
    Level completed: 38%, Points required for next Level: 250
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Ort
    Middle Europe
    Beiträge
    1.281
    Points
    11.800
    Level
    71
    Downloads
    0
    Uploads
    0

    Standard

    Ok so here we go:

    LMelior: if i try ur method,t activates USB and thena after 1 sec deactivates without moving my finger from button :/

    ARza: ur method activates usb without toching anything

    Grimfate: Error: A.LUA:90: "then" expected near "System"


  23. #3533
    Developer
    Points: 4.318, Level: 41
    Level completed: 84%, Points required for next Level: 32
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Beiträge
    205
    Points
    4.318
    Level
    41
    Downloads
    0
    Uploads
    0

    Standard

    This works perfectly fine for me:
    Code:
    -- ******* Variables ********
    
    green = Color.new(0,255,0)
    
    oldpad=Controls.read()
    usbmode=false
    
    -- *****Main Loop******
    
    while true do
    screen:clear()
    pad=Controls.read()
    
    if pad:cross() and oldpad:cross()~=pad:cross() then
    if usbmode then
    System.usbDiskModeDeactivate()
    usbmode=false
    else
    System.usbDiskModeActivate()
    usbmode=true
    end
    end
    
    if usbmode then
    screen:print(200,100,'USB Activated',green)
    else
    screen:print(200,100,'USB Deactivated',green)
    end
    
    
    screen.waitVblankStart()
    screen.flip()
    oldpad = pad
    end
    I just printed out a message so I could test on Luaplayer for Windows. I also changed the button because I'm too lazy to look up what key "select" is, but I know which key "cross" is.

    As for the others:
    ARza forgot the same thing I did, to switch the state of usbmode after the button is pressed.
    Read the error that you posted for Grimfate's. Isn't the fix obvious?

  24. #3534
    QJ Gamer Green
    Points: 11.800, Level: 71
    Level completed: 38%, Points required for next Level: 250
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Ort
    Middle Europe
    Beiträge
    1.281
    Points
    11.800
    Level
    71
    Downloads
    0
    Uploads
    0

    Standard

    THX LMelior!!! it works!!! thx!!!!
    -= Double Post =-
    OK i have new question
    i used this code:

    Code:
    print(tostring(System.powerGetBatteryLifePercent()) .. "%")
    screen:flip()
    to view battery...but when i try it in my PC LUA player i can see it in CMD

    Geändert von myschoo (09-26-2006 um 10:55 AM Uhr) Grund: Automerged Doublepost

  25. #3535
    QJ Gamer Blue
    Points: 5.768, Level: 49
    Level completed: 9%, Points required for next Level: 182
    Overall activity: 0%

    Registriert seit
    May 2006
    Beiträge
    457
    Points
    5.768
    Level
    49
    Downloads
    0
    Uploads
    0

    Standard

    what was the question?

  26. #3536
    QJ Gamer Green
    Points: 11.800, Level: 71
    Level completed: 38%, Points required for next Level: 250
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Ort
    Middle Europe
    Beiträge
    1.281
    Points
    11.800
    Level
    71
    Downloads
    0
    Uploads
    0

    Standard

    which question do u mean??? its in my post

  27. #3537
    QJ Gamer Silver
    Points: 10.263, Level: 67
    Level completed: 54%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    2.326
    Points
    10.263
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    You are using the print function which prints to the console rather then the screen. Use screen:print instead.

  28. #3538
    QJ Gamer Green
    Points: 11.800, Level: 71
    Level completed: 38%, Points required for next Level: 250
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Ort
    Middle Europe
    Beiträge
    1.281
    Points
    11.800
    Level
    71
    Downloads
    0
    Uploads
    0

    Standard

    it says some error when i use screenrint

  29. #3539
    QJ Gamer Silver
    Points: 10.263, Level: 67
    Level completed: 54%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    2.326
    Points
    10.263
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    Considering you used it twice already in your own code, you should really be able to fix the error yourself.

  30. #3540
    QJ Gamer Green
    Points: 11.800, Level: 71
    Level completed: 38%, Points required for next Level: 250
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Ort
    Middle Europe
    Beiträge
    1.281
    Points
    11.800
    Level
    71
    Downloads
    0
    Uploads
    0

    Standard

    that was usefull :/


 

Tags for this Thread

Forumregeln

  • Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
  • Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
  • Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
  • Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.
  •  





Alle Zeitangaben in WEZ -8. Es ist jetzt 07:53 AM Uhr.

Use of this Web site constitutes acceptance of the TERMS & CONDITIONS and PRIVACY POLICY
Copyright © , Caputo Media, LLC. All Rights Reserved. Cluster .