View Full Version : Lua Help
vision
December 30th, 2006, 05:10
Hey there can you tell me whats wrong with this script
-- My First Lua Program
--
--
-- ******* Variables ********
green = Color.new(0,255,0)
red = Color.new(255,0,0)
blue = Color.new(0,0,255)
--
--
--***Button Inputs
upPressed = 'Up'
downPressed = 'Down'
leftPressed = 'Left'
rightPressed = 'Right'
LPressed = 'L'
--
--
--*****Main Loop******
while true do
pad = Controls.read()
screen:clear()
screen.waitVblankStart()
screen.flip()
end
--
--
--*****Button Print******
if pad:up() then
screen:print(100,100,upPressed,green)
end
if pad:down() then
screen:print(100,100,downPressed,green)
end
if pad:left() then
screen:print(100,100,leftPressed,green)
end
if pad:right() then
screen:print(100,100,rightPressed,green)
end
if pad:l() then
screen:print(100,100,LPressed,green)
end
if pad:r() then
screen:print(100,100,'R',red)
end
if pad:triangle() then
screen:print(100,100,'TRIANGLE',red)
end
if pad:circle() then
screen:print(100,100,'CIRCLE',red)
end
if pad:cross() then
screen:print(100,100,'X',red)
end
if pad:square() then
screen:print(100,100,'SQUARE',red)
end
lol :p is : p but not spaced lol
It is suppose to write stuff when you press up,down,right etc.. on ur psp but it doesnt work i just get a black screen anyone help?
Gizmo356
December 30th, 2006, 05:36
you did the code rite but in the wrong place it should be like this
-- ******* Variables ********
green = Color.new(0,255,0)
red = Color.new(255,0,0)
blue = Color.new(0,0,255)
--
--
--***Button Inputs
upPressed = 'Up'
downPressed = 'Down'
leftPressed = 'Left'
rightPressed = 'Right'
LPressed = 'L'
--
--
--*****Main Loop******
while true do
pad = Controls.read()
screen:clear()
--
--
--*****Button Print******
if pad:up() then
screenrint(100,100,upPressed,green)
end
if pad:down() then
screenrint(100,100,downPressed,green)
end
if pad:left() then
screenrint(100,100,leftPressed,green)
end
if pad:right() then
screenrint(100,100,rightPressed,green)
end
if pad:l() then
screenrint(100,100,LPressed,green)
end
if pad:r() then
screenrint(100,100,'R',red)
end
if pad:triangle() then
screenrint(100,100,'TRIANGLE',red)
end
if pad:circle() then
screenrint(100,100,'CIRCLE',red)
end
if pad:cross() then
screenrint(100,100,'X',red)
end
if pad:square() then
screenrint(100,100,'SQUARE',red)
end
screen.waitVblankStart()
screen.flip()
end
vision
December 30th, 2006, 19:44
It worked thanks man, but my i ask why it has to be in that order and what does screen.waitVblankStart()
do?
splodger15
December 30th, 2006, 19:53
You can have it in a loop so
while true do
screen.waitVblankStart()
end
Also you can have screen.waitVblankStart() as
This is taken from my PSP Turismo
----------detect other cars collision--------------
function detectCollision(player, opponent)
if (player.x + character:width() > opponent.x) and (player.x < opponent.x + opponent.pic:width()) and (player.y + character:height() > opponent.y) and (player.y < opponent.y + opponent.pic:height()) then
screen.waitVblankStart(60)
end
end
the screen.waitVblankStart(60) is when the car hit another car it is a 60 second wait to move on
Someone else may be able to explain better
vision
December 30th, 2006, 19:56
Hmm i see, but when i had it in a loop
--*****Main Loop******
while true do
pad = Controls.read()
screen:clear()
screen.waitVblankStart()
screen.flip()
end
it would not work
If that what you mean
splodger15
December 30th, 2006, 20:12
This should be Ok
-- ******* Variables ********
green = Color.new(0,255,0)
red = Color.new(255,0,0)
-- ******* Button Inputs ********
upPressed = 'Up'
downPressed = 'Down'
leftPressed = 'Left'
rightPressed = 'Right'
LPressed = 'L'
-- *****Main Loop******
while true do
screen:clear()
pad = Controls.read()
if pad:up() then
screen:print(100,100,upPressed,green)
end
if pad:down() then
screen:print(100,100,downPressed,green)
end
if pad:left() then
screen:print(100,100,leftPressed,green)
end
if pad:right() then
screen:print(100,100,rightPressed,green)
end
if pad:l() then
screen:print(100,100,LPressed,green)
end
if pad:r() then
screen:print(100,100,'You are pressing the "R" button',red)
end
if pad:triangle() then
screen:print(100,100,'You are pressing the "TRIANGLE" button',red)
end
if pad:circle() then
screen:print(100,100,'You are pressing the "CIRCLE" button',red)
end
if pad:cross() then
screen:print(100,100,'You are pressing the "X" button',red)
end
if pad:square() then
screen:print(100,100,'You are pressing the "SQUARE" button',red)
end
screen.waitVblankStart()
screen.flip()
end
You do not need a blue variable if you are not using it
vision
December 30th, 2006, 20:17
Yeah i know i was just practicing to get the color variable thingy stuck in my head lol anyways thanks
also i pmed you
Gizmo356
December 30th, 2006, 20:53
If you need help aim me.
vision
December 30th, 2006, 22:48
Oh you use aim me too thanks ill keep in mind
Gizmo356
December 30th, 2006, 22:50
Yeah I have msn too so if you need help HIT ME UP!
Lol!
splodger15
December 30th, 2006, 22:53
I have MSN and Aim to
vision
December 30th, 2006, 22:55
i added you on aim too
splodger15
December 30th, 2006, 22:58
Thanks
Powered by vBulletin® Version 4.2.3 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.