QJ.NET | Videos | Forums | iPhone | MMORPG | Nintendo DS | Wii | PlayStation 3 | PSP | Xbox 360 | PC | Downloads | Contact Us
Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact

QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides

Go Back   QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides > Developers Corner > PSP Development, Hacks, and Homebrew > PSP Development Forum
The above video goes away if you are a member and logged in, so log in now!

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) ...

Reply
 
LinkBack Thread Tools
Old 08-17-2006, 12:19 PM   #1
 
Join Date: Aug 2006
Posts: 19
Trader Feedback: 0
Default lua help

i made this game using progam lua but i dont no wuts wrong with it. please help.

green = Color.new(0,255,0)
math.randomseed(os.time() )
LotteryNumbers = {2,12,16,19,32,48}
winningNumber = 1
oldpad = Controls.read()
while true do
screen:clear()
pad = Controls.read()
if pad:cross() and oldpad:cross() ~= pad:cross() then
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,winnin gNumber,green)
screen.waitVblankstart()
screen.flip()
oldpad = pad
end
mditalia13 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-18-2006, 10:08 AM   #2
Red Underwear
 
aznballa1992's Avatar
 
Join Date: Feb 2006
Location: Rockville, MD
Posts: 1,914
Trader Feedback: 0
Default

whats up with the smileys?
__________________
360 GT: aznWUsta
aznballa1992 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-18-2006, 06:33 PM   #3
 
Join Date: Aug 2006
Posts: 19
Trader Feedback: 0
Default

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

Last edited by mditalia13; 08-18-2006 at 06:33 PM.. Reason: Automerged Doublepost
mditalia13 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-18-2006, 08:30 PM   #4

sceKernelExitGame();
 
Bronx's Avatar
 
Join Date: Jan 2006
Location: New York
Posts: 3,125
Trader Feedback: 0
Default

First off, wrong section...
Second, try using elseif statements, and setting Winningnumber to nil, like so
Code:
Winningnumber = nil
Bronx is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-18-2006, 08:46 PM   #5

6201ymereJ
 
Join Date: Jul 2005
Location: Baltimore
Posts: 588
Trader Feedback: 0
Default

your missing commas in your "screenrints"...

Code:
screen:print(100,100,"YOU WIN!",green)
Jeremy1026 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-19-2006, 06:08 AM   #6
 
Join Date: Aug 2006
Posts: 19
Trader Feedback: 0
Default

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

Last edited by mditalia13; 08-19-2006 at 06:27 AM..
mditalia13 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-19-2006, 06:41 AM   #7
 
 
My Mood: Bored
Join Date: Apr 2006
Location: England ~¦¦¦|+|¦¦¦~
Posts: 1,112
Trader Feedback: 0
Default

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.
__________________
...Just Returned To The Scene...
JaSo PsP is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-19-2006, 06:48 AM   #8

Developer
 
yaustar's Avatar
 
Join Date: Jun 2006
Location: UK
Posts: 2,317
Trader Feedback: 0
Default

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)
yaustar is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-19-2006, 06:51 AM   #9
 
Join Date: Aug 2006
Posts: 19
Trader Feedback: 0
Default

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?
mditalia13 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-19-2006, 06:55 AM   #10

Developer
 
yaustar's Avatar
 
Join Date: Jun 2006
Location: UK
Posts: 2,317
Trader Feedback: 0
Default

Capital 's' for Start:
screen.waitVblankStart()
yaustar is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-19-2006, 07:01 AM   #11
 
Join Date: Aug 2006
Posts: 19
Trader Feedback: 0
Default

it works thanks guys for all your help. now i would like to add a image in the backround. how do i do it?
mditalia13 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-19-2006, 07:10 AM   #12

Developer
 
yaustar's Avatar
 
Join Date: Jun 2006
Location: UK
Posts: 2,317
Trader Feedback: 0
Default

http://wiki.ps2dev.org/psp:lua_player:tutorial#images
yaustar is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-19-2006, 07:13 AM   #13
 
Join Date: Aug 2006
Posts: 19
Trader Feedback: 0
Default

is there a spicific place where i put the image code inside my lottery game code or can i put it whereever i want
mditalia13 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-19-2006, 07:23 AM   #14
 
rikardo_92's Avatar
 
Join Date: Apr 2006
Location: Portugal
Posts: 63
Trader Feedback: 0
Default

(your image name) = Image.load("image.png or jpg")

screen:blit(0, 0, (your image name before assigned))
rikardo_92 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-19-2006, 07:28 AM   #15
 
Join Date: Aug 2006
Posts: 19
Trader Feedback: 0
Default

where do i add these 2 sentences in my code?
mditalia13 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-19-2006, 07:33 AM   #16

Your Fate is Grim...
 
Grimfate126's Avatar
 
Join Date: Oct 2005
Posts: 2,269
Trader Feedback: 0
Default

Quote:
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.
__________________
--------------------------------------------------------------------------------------
Grimfate126 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-19-2006, 07:50 AM   #17
 
NinjaGuerra's Avatar
 
Join Date: Jul 2006
Location: Couch
Posts: 97
Trader Feedback: 0
Default

:p doesnt disableing smilies work?
NinjaGuerra is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-19-2006, 07:51 AM   #18
 
Join Date: Aug 2006
Posts: 19
Trader Feedback: 0
Default

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
oldpad = Controls.read()
fetch[3] = Image.load("image.png")
while true do
screen:blit(0, 0, (fetch[3]))
screen:clear()
pad = Controls.read()
if pad:cross() and oldpad:cross() ~= pad:cross() then
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,winnin gNumber,green)
screen.waitVblankStart()
screen.flip()
oldpad = pad
end
mditalia13 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-19-2006, 07:59 AM   #19
 
 
My Mood: Bored
Join Date: Apr 2006
Location: England ~¦¦¦|+|¦¦¦~
Posts: 1,112
Trader Feedback: 0
Default

Quote:
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
oldpad = Controls.read()
fetch3 = Image.load("image.png")

while true do
screen:blit(0, 0, fetch3)
screen:clear()
pad = Controls.read()

if pad:cross() and oldpad:cross() ~= pad:cross() then
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,winnin gNumber,green)
screen.waitVblankStart()
screen.flip()
oldpad = pad
end
i've made some changes^
__________________
...Just Returned To The Scene...
JaSo PsP is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-19-2006, 08:05 AM   #20
 
Join Date: Aug 2006
Posts: 19
Trader Feedback: 0
Default

it said error loading images. i must of downloaded images wrong.
mditalia13 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-19-2006, 08:23 AM   #21

Developer
 
yaustar's Avatar
 
Join Date: Jun 2006
Location: UK
Posts: 2,317
Trader Feedback: 0
Default

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
oldpad = Controls.read()
-- Between the quotation marks, put the file path to the image you want to load.
fetch3 = Image.load("image.png")

while true do
screen:clear()
-- Blit the image AFTER you clear the screen
screen:blit(0, 0, fetch3)
pad = Controls.read()

if pad:cross() and oldpad:cross() ~= pad:cross() then
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()
oldpad = pad
end
yaustar is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-19-2006, 08:45 AM   #22
 
Join Date: Aug 2006
Posts: 19
Trader Feedback: 0
Default

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.
mditalia13 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-19-2006, 09:46 AM   #23
 
 
My Mood: Bored
Join Date: Apr 2006
Location: England ~¦¦¦|+|¦¦¦~
Posts: 1,112
Trader Feedback: 0
Default

Quote:
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.
__________________
...Just Returned To The Scene...
JaSo PsP is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-19-2006, 10:08 AM   #24
 
Join Date: Aug 2006
Posts: 19
Trader Feedback: 0
Default

its called fetch[3] and its a png file. and it is in the directory in lua where my lottery game is
mditalia13 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-19-2006, 12:29 PM   #25
 
 
My Mood: Bored
Join Date: Apr 2006
Location: England ~¦¦¦|+|¦¦¦~
Posts: 1,112
Trader Feedback: 0
Default

Quote:
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
__________________
...Just Returned To The Scene...
JaSo PsP is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Tags
lua

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -8. The time now is 07:54 PM.



Use of this Web site constitutes acceptance of the TERMS & CONDITIONS and PRIVACY POLICY
Copyright © 2009, QJ.NET. All Rights Reserved.
Contact Us