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; whats the code?sounds like you have too many or not enough "end" statments also I was messing around with the ...
-
04-21-2006, 11:05 AM #1771QJ Gamer Blue
- Registriert seit
- Jun 2005
- Beiträge
- 375
- Points
- 5.631
- Level
- 48
- Downloads
- 0
- Uploads
- 0
whats the code?sounds like you have too many or not enough "end" statments
also I was messing around with the code for the analog stick so i figured id post it here incase someone learning how to use the analog stick wants to use it
Code:white = Color.new(255, 255, 255) while true do screen:clear() pad = Controls.read() analogX = pad:analogX() analogY = pad:analogY() if pad:start() then break end --Up/Down/Left/Right --Right if analogX > 32 and analogY > -40 and analogY < 40 then screen:print(200, 100, "Right", white) end --Left if analogX < -32 and analogY > -40 and analogY < 40 then screen:print(200, 100, "Left", white) end --Down if analogY > 32 and analogX < 40 and analogX > -40 then screen:print(200, 100, "Down", white) end --Up if analogY < -32 and analogX < 40 and analogX >-40 then screen:print(200, 100, "Up", white) end --Center if analogY > -32 and analogY <32 and analogX < 32 and analogX > -32 then screen:print(200, 100, "Center", white) end --Diagnals --Up/Right if analogY < -32 and analogX > 40 then screen:print(200, 100, "Up and Right", white) end --Up/Left if analogY < -32 and analogX < -40 then screen:print(200, 100, "Up and Left", white) end --Down/Right if analogY > 32 and analogX > 40 then screen:print(200, 100, "Down and Right", white) end --Down/Left if analogY > 32 and analogX < -40 then screen:print(200, 100, "Down and Left", white) end screen.flip() end
-
04-21-2006, 11:06 AM #1772Rock Star

- Registriert seit
- Aug 2005
- Ort
- CT| FW: 4.01 M33-2
- Beiträge
- 11.844
- Points
- 70.899
- Level
- 100
- Downloads
- 0
- Uploads
- 0
I fixed it for him, when he PMed me about it ;)

-
04-21-2006, 11:07 AM #1773sceKernelExitGame();
- Registriert seit
- Jan 2006
- Ort
- New York
- Beiträge
- 3.126
- Points
- 19.955
- Level
- 89
- Downloads
- 0
- Uploads
- 0
yeah thanks! i appreciate it!
Zitat von TeamOverload
-
04-21-2006, 12:18 PM #1774
Dont make your games online. Period. Right now, LUA only supports TCP. TCP is slow, all/most online games use UDP because its much faster. I got a TCP server on my computer to talk to my PSP as a test for netlib. It was wasy too slow (although much faster than the current netlib.)
If I can ever get UDP with netlib, making an online game is a good idea.
However, if I continue to devolop netlib with TCP, it would be useful for things like online scores and stuff that you send once. Right now, netlib has to connect every time you want to send data, and failing to connect and getting stuck in luaplayer is common.
(And to the person who said you need netlib to make an online game, you dont. You use the Wlan. functions)牧来栠摩琠敨映汩獥
PSN: youresamFrom Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
--Mike Hollingsworth
-
04-21-2006, 03:08 PM #1775sceKernelExitGame();
- Registriert seit
- Jan 2006
- Ort
- New York
- Beiträge
- 3.126
- Points
- 19.955
- Level
- 89
- Downloads
- 0
- Uploads
- 0
could some1 tell me wat is wrong with my end statements? thanks!
BTW- if u find anything else wrong feel free to say! lolCode:green = Color.new(0, 255, 0) black = Color.new(0, 0, 0) red = Color.new(255, 0, 0) blue = Color.new(0, 0, 255) white = Color.new(0, 0, 0) -- ********Variables****** downPressed = answerOne upPressed = answerFour rightPressed = answerTwo leftPressed = answerThree -- Questions 1 questionOne = "Who hit the most homeruns ever?" --answers 1 answerOne = "down = Babe Ruth" answerTwo = "right = Hank Aaron" AnswerThree = "left = Barry Bond" AnswerFour = "up = Sammy Sosa" --****Main Loop**** while true do screen:clear() pad = Controls.read() screen:print(100, 100, questionOne, blue) screen.flip() end screen:print(150, 250, answerOne, white) screen.flip() end screen:print(150, 255, answerTwo, white) screen.flip() end screen:print(150, 260, answerThree, white) screen.flip() end screen:print(150, 265, answerFour, white) screen.flip() end if pad:down() then screen:print(150, 300, 'sorry, incorrect.', left) screen.flip() end if pad:right() then screen:print(150, 300, 'Your Correct!', green) screen.flip() end if pad:left() then screen:print(150, 300, 'sorry, incorrect.', left) screen.flip() end if pad:up() then screen:print(150, 300, 'sorry, incorrect.', left) screen.filp() end while true do screen.flip() screen.waitVblankStart() end
-
04-21-2006, 03:14 PM #1776<img src="images/smilies/psp.gif" border="0" alt="" title="" cl***="inlineimg" /> <img src="images/smilies/Punk.gif" border="0" alt="" title="" cl***=&

- Registriert seit
- Jun 2005
- Ort
- Canada
- Beiträge
- 1.944
- Points
- 11.105
- Level
- 69
- Downloads
- 0
- Uploads
- 0
you have too many of them,,
you dont need an end after screenflip, or print
EDIT, you also have an extra while true do statement that you dont need,,
To check if your ends are correct download NotePad++
itll connect everything, and colour the reserved words,it perfectGeändert von Sousanator (04-21-2006 um 03:18 PM Uhr)
-
04-21-2006, 03:21 PM #1777sceKernelExitGame();
- Registriert seit
- Jan 2006
- Ort
- New York
- Beiträge
- 3.126
- Points
- 19.955
- Level
- 89
- Downloads
- 0
- Uploads
- 0
thanks! but now i cant get the answers to appear!
Zitat von Sousanator
-
04-21-2006, 03:23 PM #1778<img src="images/smilies/psp.gif" border="0" alt="" title="" cl***="inlineimg" /> <img src="images/smilies/Punk.gif" border="0" alt="" title="" cl***=&

- Registriert seit
- Jun 2005
- Ort
- Canada
- Beiträge
- 1.944
- Points
- 11.105
- Level
- 69
- Downloads
- 0
- Uploads
- 0
try taking away all the screenflips, except the one at the very end
ohh, and you spelled screenflip wrong on your second last statement
(you put screenfilp)
-
04-21-2006, 03:27 PM #1779sceKernelExitGame();
- Registriert seit
- Jan 2006
- Ort
- New York
- Beiträge
- 3.126
- Points
- 19.955
- Level
- 89
- Downloads
- 0
- Uploads
- 0
which one? and this is the code i have now, it works, kinda... i cant get the answers to show!? any help
Zitat von Sousanator
Code:green = Color.new(0, 255, 0) black = Color.new(0, 0, 0) red = Color.new(255, 0, 0) blue = Color.new(0, 0, 255) white = Color.new(0, 0, 0) -- ********Variables****** downPressed = answerOne upPressed = answerFour rightPressed = answerTwo leftPressed = answerThree -- Questions 1 questionOne = "Who hit the most homeruns ever?" --answers 1 answerOne = "down = Babe Ruth" answerTwo = "right = Hank Aaron" AnswerThree = "left = Barry Bond" AnswerFour = "up = Sammy Sosa" --****Main Loop**** while true do screen:clear() pad = Controls.read() screen:print(100, 100, questionOne, blue) screen.flip() end screen:print(150, 250, answerOne, white) screen.flip() screen:print(150, 255, answerTwo, white) screen.flip() screen:print(150, 260, answerThree, white) screen.flip() screen:print(150, 265, answerFour, white) screen.flip() if pad:down() then screen:print(150, 300, 'sorry, incorrect.', left) screen.flip() end if pad:right() then screen:print(150, 300, 'Your Correct!', green) screen.flip() end if pad:left() then screen:print(150, 300, 'sorry, incorrect.', left) screen.flip() end if pad:up() then screen:print(150, 300, 'sorry, incorrect.', left) screen.flip() end while true do screen.flip() screen.waitVblankStart() end
-
04-21-2006, 03:29 PM #1780sceKernelExitGame();
- Registriert seit
- Jan 2006
- Ort
- New York
- Beiträge
- 3.126
- Points
- 19.955
- Level
- 89
- Downloads
- 0
- Uploads
- 0
let me try...
Zitat von Sousanator
btw- sry for double post...
EDIT- ok i tried this code but no text appears...
Code:green = Color.new(0, 255, 0) black = Color.new(0, 0, 0) red = Color.new(255, 0, 0) blue = Color.new(0, 0, 255) white = Color.new(0, 0, 0) -- ********Variables****** downPressed = answerOne upPressed = answerFour rightPressed = answerTwo leftPressed = answerThree -- Questions 1 questionOne = "Who hit the most homeruns ever?" --answers 1 answerOne = "down = Babe Ruth" answerTwo = "right = Hank Aaron" AnswerThree = "left = Barry Bond" AnswerFour = "up = Sammy Sosa" --****Main Loop**** while true do screen:clear() end pad = Controls.read() screen:print(100, 100, questionOne, blue) screen:print(150, 250, answerOne, white) screen:print(150, 255, answerTwo, white) screen:print(150, 260, answerThree, white) screen:print(150, 265, answerFour, white) if pad:down() then screen:print(150, 300, 'sorry, incorrect.', left) end if pad:right() then screen:print(150, 300, 'Your Correct!', green) end if pad:left() then screen:print(150, 300, 'sorry, incorrect.', left) end if pad:up() then screen:print(150, 300, 'sorry, incorrect.', left) end while true do screen.waitVblankStart() end
Geändert von Bronx (04-21-2006 um 03:34 PM Uhr)
-
04-21-2006, 03:44 PM #1781<img src="images/smilies/psp.gif" border="0" alt="" title="" cl***="inlineimg" /> <img src="images/smilies/Punk.gif" border="0" alt="" title="" cl***=&

- Registriert seit
- Jun 2005
- Ort
- Canada
- Beiträge
- 1.944
- Points
- 11.105
- Level
- 69
- Downloads
- 0
- Uploads
- 0
here i rewrote your code,,
some problems you had were, white was actually black, and you mixed up the up/down, and left/right posistios,,
i didnt fix the positions, so its cluttered a bit,, ill let you fix that
Code:green = Color.new(0, 255, 0) black = Color.new(0, 0, 0) red = Color.new(255, 0, 0) blue = Color.new(0, 0, 255) white = Color.new(255, 255, 255) -- Questions 1 questionOne = "Who hit the most homeruns ever?" --answers 1 answerOne = "down = Babe Ruth" answerTwo = "right = Hank Aaron" answerThree = "left = Barry Bond" answerFour = "up = Sammy Sosa" --****Main Loop**** while true do screen:clear() pad = Controls.read() screen:print(100, 100, questionOne, blue) screen:print(150, 250, answerOne, white) screen:print(150, 255, answerTwo, white) screen:print(150, 260, answerThree, white) screen:print(150, 265, answerFour, white) if pad:down() then screen:print(150, 100, "sorry, incorrect.", red) end if pad:right() then screen:print(150, 100, "Your Correct!", green) end if pad:left() then screen:print(150, 100, "sorry, incorrect.", red) end if pad:up() then screen:print(150, 100, "sorry, incorrect.", red) end screen.flip() screen.waitVblankStart() end
-
04-21-2006, 03:47 PM #1782sceKernelExitGame();
- Registriert seit
- Jan 2006
- Ort
- New York
- Beiträge
- 3.126
- Points
- 19.955
- Level
- 89
- Downloads
- 0
- Uploads
- 0
thanks! i appreciate ur help! and with notepad++ how do u find out wat each color means that it highlights?
-
04-21-2006, 03:52 PM #1783<img src="images/smilies/psp.gif" border="0" alt="" title="" cl***="inlineimg" /> <img src="images/smilies/Punk.gif" border="0" alt="" title="" cl***=&

- Registriert seit
- Jun 2005
- Ort
- Canada
- Beiträge
- 1.944
- Points
- 11.105
- Level
- 69
- Downloads
- 0
- Uploads
- 0
you go to language > style configerator(the last one) > then in language choose lua, and you will see what each colour means
-
04-21-2006, 03:58 PM #1784sceKernelExitGame();
- Registriert seit
- Jan 2006
- Ort
- New York
- Beiträge
- 3.126
- Points
- 19.955
- Level
- 89
- Downloads
- 0
- Uploads
- 0
ok
, i know u have helped me a lot! but do u know how to stop it show u only get one try to answer it then u move on to the next question (once i have a new question, lol)!btw i appreciate all ur help!
-
04-21-2006, 04:57 PM #1785
can someone show me a code to move words pls? like there is a word Hello in the black screen and if i press Circle it will move right
it will really helpBequiet!!!
I'm learning cc©cc
-
04-21-2006, 05:09 PM #1786<img src="images/smilies/psp.gif" border="0" alt="" title="" cl***="inlineimg" /> <img src="images/smilies/Punk.gif" border="0" alt="" title="" cl***=&

- Registriert seit
- Jun 2005
- Ort
- Canada
- Beiträge
- 1.944
- Points
- 11.105
- Level
- 69
- Downloads
- 0
- Uploads
- 0
@bronxbomber92, im not sure how to do that,, at least not easily
@natan333 make some new varibles
letterPos = {}
letterPos.x = (starting point, x posistion)
letterPos.y = (starting point, y position)
then when you screen
rint you do this,,
screen
rint(letterPos.x, letterPos.y, "blaa", white)
then you do this
if pad:circle() then letterPos.x = letterPos.x + 2 end
if you wanted it to move left, change + to -,,
and if you wanted to move it up/down you subtract/add letterPos.y
-
04-21-2006, 07:37 PM #1787sceKernelExitGame();
- Registriert seit
- Jan 2006
- Ort
- New York
- Beiträge
- 3.126
- Points
- 19.955
- Level
- 89
- Downloads
- 0
- Uploads
- 0
d*m*, does any1 else know how to give only one chance to answer a question and either restart the game if they get it wrong or go on to the next question if they get it correct?
-
04-21-2006, 07:52 PM #1788
whats wrong with this code? It dosent give no error but Circle dosent make it move =/Code:while true do blue=Color.new(0,200,350) screen:clear() letterPos = {} letterPosx = 200, 250 letterPosy = 100, 150 screen:print(letterPosx, letterPosy, "HELLO", blue) pad = Controls.read() if pad:circle() then letterPosx = letterPosx + 2 end if pad:select() then break end screen.flip() screen.waitVblankStart() endBequiet!!!
I'm learning cc©cc
-
04-21-2006, 07:54 PM #1789Is in your zone.

- Registriert seit
- Oct 2005
- Ort
- Jacksonville, FL
- Beiträge
- 3.429
- Points
- 24.342
- Level
- 94
- Downloads
- 0
- Uploads
- 0
Get rid of the array and you should be set. and have only 1 value per variable

--XBL Gamertag: PhenoM904--
-
04-21-2006, 08:09 PM #1790
what do u mean by array ? and the 1 per variable you mean letterPosx + 2 to be + 1 or letterPosx = 200, 1 ?
Bequiet!!!
I'm learning cc©cc
-
04-21-2006, 08:15 PM #1791Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von natan333
also, your screen.waitVblankStart() should come BEFORE your screen:flip()--------------------------------------------------------------------------------------
-
04-21-2006, 08:22 PM #1792
is it possible for you to put the code showing the correct way ?
Bequiet!!!
I'm learning cc©cc
-
04-21-2006, 08:52 PM #1793
This is my problem:
a = 2
b = a - 1.
tempa = a
a = b
b = tempa
somehow, they both equal one, instead of a = 1 and b = 2.
-
04-21-2006, 08:54 PM #1794Is in your zone.

- Registriert seit
- Oct 2005
- Ort
- Jacksonville, FL
- Beiträge
- 3.429
- Points
- 24.342
- Level
- 94
- Downloads
- 0
- Uploads
- 0
Try that. and the array was the letterPos={} thing.Code:while true do blue=Color.new(0,200,350) screen:clear() letterPosx = 200 letterPosy = 100 screen:print(letterPosx, letterPosy, "HELLO", blue) pad = Controls.read() if pad:circle() then letterPosx = letterPosx + 5 end if pad:select() then break end screen.flip() screen.waitVblankStart() end

--XBL Gamertag: PhenoM904--
-
04-21-2006, 08:55 PM #1795
Ok I got it working, Moving =P but if i release the button , it comes back =/
what do i do to make it stay ?Code:while true do blue=Color.new(0,200,350) screen:clear() letterPosx = 200, 200 letterPosy = 150, 150 pad = Controls.read() if pad:cross() then letterPosx = letterPosx + 10 end screen:print(letterPosx, letterPosy, "HELLO", blue) if pad:select() then break end screen.waitVblankStart() screen.flip() end
Bequiet!!!
I'm learning cc©cc
-
04-21-2006, 09:03 PM #1796Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
try this:
Zitat von natan333
it should workCode:blue = Color.new(0,200,350) letterPosx = 200 letterPosy = 150 while true do pad = Controls.read() screen:print(letterPosx, letterPosy, "HELLO", blue) if pad:cross() then screen:clear() letterPosx = letterPosx + 10 end if pad:select() then break end screen.waitVblankStart() screen.flip() end
--------------------------------------------------------------------------------------
-
04-21-2006, 09:10 PM #1797
yeah i learned now =PPPPPP Thanks Guys
now i have to learn how to make it attomatic
i saw source of an example of moving Hello Word, and it has Time in there, but have no idea how to change the pad to move attomatic =P
Geändert von natan333 (04-21-2006 um 09:12 PM Uhr)
Bequiet!!!
I'm learning cc©cc
-
04-21-2006, 09:24 PM #1798
someone please answer my question (see above)
-
04-21-2006, 09:40 PM #1799
to overwrite the pad to be attomatic i have to overwrite this
?Code:time = 0 pi = math.atan(1) * 4 while true do screen:clear() x = math.sin(pi * 2 / 360 * time) * 150 + 192.5 screen:print(x, 100, "HELLO", blue) time = time + 1 if time >= 360 then time = 0 end
or i can keep the "letterPosx = 200
letterPosy = 150"?Bequiet!!!
I'm learning cc©cc
-
04-22-2006, 08:07 AM #1800
guys what do i replace if pad:circle() to make it attomatic so it moves by it self with out pressing a button ?
Bequiet!!!
I'm learning cc©cc


LinkBack URL
About LinkBacks
Mit Zitat antworten


Hello everyone I am new here and I am glad to be part of this amazing community and I think there...
New to forum