The above video goes away if you are a member and logged in, so log in now!

 Would you like to get all the newest Gaming News fromQJ.NET in your email each day? Want to learn more about the team who brings you the QJ news?

## lua help

This is a discussion on lua help within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; i made this game using progam lua but i dont no wuts wrong with it. please help. green = Color.new(0,255,0) ...

 Tweet
1. ## lua help

green = Color.new(0,255,0)
math.randomseed(os.time() )
LotteryNumbers = {2,12,16,19,32,48}
winningNumber = 1
while true do
screen:clear()
winningNumber = math.random(1,65)
end
if winningNumber == Lotterynumbers[1]then
screenrint(100,100"YOU WIN!",green)
end
if winningNumber == Lotterynumbers[2]then
screenrint(100,100"YOU WIN!",green)
end
if winningNumber == Lotterynumbers[3]then
screenrint(100,100"YOU WIN!",green)
end
if winningNumber == Lotterynumbers[5]then
screenrint(100,100"YOU WIN!",green)
end
if winningNumber == Lotterynumbers[6]then
screenrint(100,100"YOU WIN!",green)
end
screenrint(10,10,winningNumber, green)
screen.waitVblankstart()
screen.flip()
end

2. whats up with the smileys?

3. because when u type in : p next to eachother it makes a smiley.
can anyone fix my code?
-= Double Post =-
sorry for double post but can someone tell me wut i did wrong

4. First off, wrong section...
Second, try using elseif statements, and setting Winningnumber to nil, like so
Code:
`Winningnumber = nil`

Code:
`screen:print(100,100,"YOU WIN!",green)`

6. it says error expects ) near you win. wut do i do now

7. u forgot to put the comma in here:
Code:
```Before:
if winningNumber == Lotterynumbers[1]then
screen:print(100,100"YOU WIN!",green)
end

After:
if winningNumber == Lotterynumbers[1]then
screen:print(100,100,"YOU WIN!",green)```
See the difference? make this change for each one.

8. You would also need a space before the keyword 'then'
Code:
`if winningNumber == Lotterynumbers[1]then`
to
Code:
`if winningNumber == Lotterynumbers[1] then`
Also:
Code:
`screen:print(10,10,winnin gNumber,green)`
to
Code:
`screen:print(10,10,winningNumber,green)`

9. ok i fixed that now on the bottom of the code it says 'waitVblankstart'
(a nil value) how do i fix this and then i should be done?

10. Capital 's' for Start:
screen.waitVblankStart()

11. it works thanks guys for all your help. now i would like to add a image in the backround. how do i do it?

12. is there a spicific place where i put the image code inside my lottery game code or can i put it whereever i want

screen:blit(0, 0, (your image name before assigned))

14. where do i add these 2 sentences in my code?

15. Originally Posted by mditalia13
where do i add these 2 sentences in my code?
the load part: but it before ur while true do loop.

blit the image either in a function of ur while true do loop.

16. :p doesnt disableing smilies work?

17. is this right? i dont think it is.

green = Color.new(0,255,0)
math.randomseed(os.time() )
LotteryNumbers = {2,12,16,19,32,48}
winningNumber = 1
while true do
screen:blit(0, 0, (fetch[3]))
screen:clear()
winningNumber = math.random(1,65)
end
if winningNumber == LotteryNumbers[1] then
screenrint(100,100,"YOU WIN!",green)
end
if winningNumber == LotteryNumbers[2] then
screenrint(100,100,"YOU WIN!",green)
end
if winningNumber == LotteryNumbers[3] then
screenrint(100,100,"YOU WIN!",green)
end
if winningNumber == LotteryNumbers[5] then
screenrint(100,100,"YOU WIN!",green)
end
if winningNumber == LotteryNumbers[6] then
screenrint(100,100,"YOU WIN!",green)
end
screenrint(10,10,winningNumber, green)
screen.waitVblankStart()
screen.flip()
end

18. Originally Posted by mditalia13
is this right? i dont think it is.

green = Color.new(0,255,0)
math.randomseed(os.time() )
LotteryNumbers = {2,12,16,19,32,48}
winningNumber = 1

while true do
screen:blit(0, 0, fetch3)
screen:clear()

winningNumber = math.random(1,65)
end

if winningNumber == LotteryNumbers[1] then
screenrint(100,100,"YOU WIN!",green)
end

if winningNumber == LotteryNumbers[2] then
screenrint(100,100,"YOU WIN!",green)
end

if winningNumber == LotteryNumbers[3] then
screenrint(100,100,"YOU WIN!",green)
end

if winningNumber == LotteryNumbers[5] then
screenrint(100,100,"YOU WIN!",green)
end

if winningNumber == LotteryNumbers[6] then
screenrint(100,100,"YOU WIN!",green)
end

screenrint(10,10,winningNumber, green)
screen.waitVblankStart()
screen.flip()
end

20. Fixed JaSo PsP's code
Code:
```green = Color.new(0,255,0)
math.randomseed(os.time() )
LotteryNumbers = {2,12,16,19,32,48}
winningNumber = 1
-- Between the quotation marks, put the file path to the image you want to load.

while true do
screen:clear()
-- Blit the image AFTER you clear the screen
screen:blit(0, 0, fetch3)

winningNumber = math.random(1,65)
end

if winningNumber == LotteryNumbers[1] then
screenrint(100,100,"YOU WIN!",green)
end

if winningNumber == LotteryNumbers[2] then
screenrint(100,100,"YOU WIN!",green)
end

if winningNumber == LotteryNumbers[3] then
screenrint(100,100,"YOU WIN!",green)
end

if winningNumber == LotteryNumbers[5] then
screenrint(100,100,"YOU WIN!",green)
end

if winningNumber == LotteryNumbers[6] then
screenrint(100,100,"YOU WIN!",green)
end

screenrint(10,10,winningNumber,green)
screen.waitVblankStart()
screen.flip()
end```

21. darn it didnt work. my backround file isnt working. does any one know how to get like a lottery backround. if i get this it should work perfectly. thanks for all of your help.

22. Originally Posted by mditalia13
darn it didnt work. my backround file isnt working. does any one know how to get like a lottery backround. if i get this it should work perfectly. thanks for all of your help.
is the image in the same directory as index.lua? is the image called image.png? is it a png image? check through these and see if it works.

23. its called fetch[3] and its a png file. and it is in the directory in lua where my lottery game is

24. Originally Posted by mditalia13
its called fetch[3] and its a png file. and it is in the directory in lua where my lottery game is
take out the square brackets and change the file name in the code or change the file name to image.png

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

All times are GMT -8. The time now is 08:43 AM.

Use of this Web site constitutes acceptance of the TERMS & CONDITIONS and PRIVACY POLICY