![]() |
| Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact |
| ||||||
This is a discussion on Need Some LUA help PLEASE within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; Ive created a simple program that enables USB and it works. USB gets activated when you press X. My only ...
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 |
![]() |
Ive created a simple program that enables USB and it works. USB gets activated when you press X. My only problem is, the text that says USB mode is active (screen
rint(240,136,"US B mode is active",red)) It will only display when i am holding it down. How to i get it to stay there?
__________________
...Just Returned To The Scene... |
|
|
|
|
|
#2 |
![]() |
Set up a int, call it, usba.
Make a while loop in your program, that has the button input code. But if X is pressed set the usba to 1. Then set up an if loop that runs the screen printf if usba is 1. This is it in C. Code:
int main(){
SceCtrlData pad;
int usba = 0;
while(1){
sceCtrlReadBufferPositive(&pad, 1);
if (pad.Buttons & PSP_CTRL_CROSS){
usba = 1 }
if (usba == 1) {
printf("USB mode is active");
}
}
}
Sorry my lua isnt great, otherwise i would have written the lua code out.
__________________
[b][center] [URL="http://forums.qj.net/showthread.php?t=65032"][SIZE="3"][COLOR="Blue"]Omicron[/COLOR] - [COLOR="DeepSkyBlue"]A hacking simulation game for the PSP[/COLOR][/SIZE][/URL] [url=http://profile.mygamercard.net/dr+nutterbutter][img]http://card.mygamercard.net/gbar/live/dr+nutterbutter.gif[/img][/url][/b][/center] |
|
|
|
|
|
#3 | |
![]() |
Quote:
__________________
...Just Returned To The Scene... |
|
|
|
|
|
|
#5 |
![]() |
Try this.
Code:
usba = 1
while true do
pad = Controls.read()
if pad:start() then
// USB activate code goes here
usba = 1
end
if usba = 1 then
(screenrint(240,136,"USB mode is active",red))
end
end
__________________
[b][center] [URL="http://forums.qj.net/showthread.php?t=65032"][SIZE="3"][COLOR="Blue"]Omicron[/COLOR] - [COLOR="DeepSkyBlue"]A hacking simulation game for the PSP[/COLOR][/SIZE][/URL] [url=http://profile.mygamercard.net/dr+nutterbutter][img]http://card.mygamercard.net/gbar/live/dr+nutterbutter.gif[/img][/url][/b][/center] Last edited by Nutterbutter; 08-16-2006 at 10:41 AM.. Reason: Automerged Doublepost |
|
|
|
|
|
#6 | |
![]() ![]() Your Fate is Grim...
|
Quote:
try: Code:
usbEnabled = false oldpad = Controls.read() while true do screen:clear() pad = Controls.read() if pad:cross() and oldpad:cross() ~= pad:cross() and usbEnabled == false then usbEnabled = true else usbEnabled = false end if usbEnabled == true then --activate usb -- print whatever end screen.waitVblankStart() screen:flip() oldpad = pad end
__________________
-------------------------------------------------------------------------------------- ![]() |
|
|
|
|
|
|
#8 |
![]() |
The main loop should look like this, kinda
Code:
while true do pad=Controls.read screen:clear() if pad:cross()then usba="yes" end if usba=="yes" then System.usbDiskModeActivate() screen:print(240,136,"USB mode is active",red) end screen.waitVblankStart() screen.flip() end
__________________
<<Put A message Here>> <<Just made another rubbish website visit it [URL="http://www.joedastudd.co.uk/"]here[/URL].>> |
|
|
|
|
|
#9 | |
![]() |
Quote:
__________________
[b][center] [URL="http://forums.qj.net/showthread.php?t=65032"][SIZE="3"][COLOR="Blue"]Omicron[/COLOR] - [COLOR="DeepSkyBlue"]A hacking simulation game for the PSP[/COLOR][/SIZE][/URL] [url=http://profile.mygamercard.net/dr+nutterbutter][img]http://card.mygamercard.net/gbar/live/dr+nutterbutter.gif[/img][/url][/b][/center] |
|
|
|
|
|
|
#11 | |
![]() |
this is wot i got at the moment:
Code:
red = Color.new(255,0,0) screen:print(240,136,"Press X to enter USB mode", red) while true do pad = Controls.read() if pad:cross() then screen:clear() System.usbDiskModeActivate() screen:print(240,136,"USB mode active", red) end if pad:start() then return end screen.flip() end Quote:
__________________
...Just Returned To The Scene... Last edited by JaSo PsP; 08-16-2006 at 10:47 AM.. Reason: Automerged Doublepost |
|
|
|
|
|
|
#12 | |
![]() |
Quote:
screen.waitVblankStart() screen.flip() end Also, have you ever heard of this thread? |
|
|
|
|
|
|
#13 | |
![]() |
Quote:
-= Double Post =- ok, it still flashes like this... Code:
screen:clear() red = Color.new(255,0,0) screen:print(240,136,"Press X to enter USB mode", red) while true do pad = Controls.read() if pad:cross() then screen:clear() System.usbDiskModeActivate() screen:print(240,136,"USB mode active", red) end if pad:start() then return end screen.waitVblankStart() screen.flip() end
__________________
...Just Returned To The Scene... Last edited by JaSo PsP; 08-16-2006 at 10:55 AM.. Reason: Automerged Doublepost |
|
|
|
|
|
|
#14 |
![]() |
try
Code:
red = Color.new(255,0,0) usba="no" while true do pad = Controls.read() screen:clear() if usba=="no" then screen:print(240,136,"Press X to enter USB mode", red) else screen:print(240,136,"USB mode active", red) end if pad:cross() then System.usbDiskModeActivate() usba="yes" end if pad:start() then break end screen.waitVblankStart() screen.flip() end
__________________
<<Put A message Here>> <<Just made another rubbish website visit it [URL="http://www.joedastudd.co.uk/"]here[/URL].>> |
|
|
|
|
|
#15 |
![]() ![]() I'm Baaaack!
|
Do this:
Code:
function Activate() while true do screen:clear() pad = Contols.read() screen: print(240,136,"USB mode active", red) System.usbDiskModeActivate() if pad:start() then return end screen.waitVblankStart() screen.flip() end end red = Color.new(255,0,0) while true do screen:clear() pad = Controls.read() screen: print(240,136,"Pre ss X to enter USB mode", red) if pad:cross() then Activate() end screen.waitVblankStart() screen.flip() end
__________________
|
|
|
|
|
|
#16 | |
![]() |
Quote:
__________________
...Just Returned To The Scene... |
|
|
|
|
|
|
#17 | |
![]() ![]() sceKernelExitGame();
|
Quote:
, ur combining c and lua lol
__________________
|
|
|
|
|
|
|
#18 | |
![]() |
Quote:
__________________
[b][center] [URL="http://forums.qj.net/showthread.php?t=65032"][SIZE="3"][COLOR="Blue"]Omicron[/COLOR] - [COLOR="DeepSkyBlue"]A hacking simulation game for the PSP[/COLOR][/SIZE][/URL] [url=http://profile.mygamercard.net/dr+nutterbutter][img]http://card.mygamercard.net/gbar/live/dr+nutterbutter.gif[/img][/url][/b][/center] |
|
|
|
|
|
|
#19 |
![]() ![]() ...in a dream...
|
No need for a completely seperate thread for something as simple as a bool to tell whether or not the usb is active or not...
Code:
usb = false
white = Color.new(255,255,255)
while true do
pad = Controls.read()
if usb==true then screen:print(0,0,"SG57: USB On", white)
else screen:print(0,0,"SG57: Usb Off",white) end
if pad:cross() then usb = ~usb end
end
__________________
...you'll never know what it's like... spending your whole life in a dream...
Launch a Kitten out of a Cannon and win real cash! Checkout my newly updated site for all my projects (Kitten Cannon, BOXHEAD, Light Cycle 3D) |
|
|
|
|
|
#20 |
![]() ![]() Developer
|
I would change it this so that it can tell the difference from a singular key press and release:
Code:
usb = false
WasCrossPressed = false;
white = Color.new(255,255,255)
while true do
pad = Controls.read()
if usb==true then screen:print(0,0,"SG57: USB On", white)
else screen:print(0,0,"SG57: Usb Off",white) end
if pad:cross() then
if not WasCrossPressed then
usb = ~usb
end
WasCrossPressed = true
else
WasCrossPressed = false
end
end
|
|
|
|
![]() |
| Tags |
| lua |
| Thread Tools | |
|
|