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?

This is a discussion on Lua Programming Help Thread within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; Originally Posted by Twenty 2 Ok i fixed the == part and I forgot to put a % in front ...

 Tweet
1. Originally Posted by Twenty 2
Ok i fixed the == part and I forgot to put a % in front of d. No when I test the program and when i press up it goes straight to 2 and wont go higher. When i press down it goes straight to zero.

Code:
m = 1
ran = math.random(100)
blue = Color.new(0, 0, 225)

while true do

screen:clear()
screen:print(230, 136, string.format("%d", m + 1), blue)
screen:flip() end

screen:clear()
screen:print(230, 136, string.format("%d", m - 1), blue)
screen:flip() end

if pad:cross() and m == ran then
screen:clear()
screen:print(230, 136, string.format("%d", m), blue)
screen:print(230, 136, "You guessed correctly!", blue)
screen:flip() end

break end

end
That's because it's going to fast.

Code:
while true do
screen.waitVblankStart(5) -- add this

2. It still has the same problem and it shouldnt stop at 2.

3. Originally Posted by Twenty 2
It still has the same problem and it shouldnt stop at 2.
Oh, I see, m stays as one, you never redefined it. It shoul be this:
Code:
m = 1
ran = math.random(100)
blue = Color.new(0, 0, 225)

while true do

m = m+1
screen:clear()
screen:print(230, 136, string.format("%d", m), blue)
screen:flip() end

m = m-1
screen:clear()
screen:print(230, 136, string.format("%d", m), blue)
screen:flip() end

if pad:cross() and m == ran then
screen:clear()
screen:print(230, 136, string.format("%d", m), blue)
screen:print(230, 136, "You guessed correctly!", blue)
screen:flip() end

break end

end

4. Ok thnx it works now, but it goes to fast. Is there anyway to slow it down? Also how would you set limits to the number so its 0-100,like "if m<100 then
m=m+1?

5. Originally Posted by Twenty 2
Ok thnx it works now, but it goes to fast. Is there anyway to slow it down? Also how would you set limits to the number so its 0-100,like "if m<100 then
m=m+1?
the screen.waitVblanKStark() makes it wait a certain amount of time before reading the next line of code.
Example: screen.waitVblanKStark(8) make it wait 8/60 of a second.
Use this at the beginning of the while loop to slow it down.

6. hi am on the 2nd Tutorials in Lua and i get

error: script:127: \end/ expected (to close \while/ at line 65) near \<eof>/

here is the code

http://www.filefactory.com/get/f2.ph...3dda454f100e57

7. As the error suggest, you left out an
Code:
end
somewhere in that code.

8. Originally Posted by MagicianFB
As the error suggest, you left out an
Code:
end
somewhere in that code.
in line 65?

because its

Code:
while true do
there

9. Originally Posted by tupac12
in line 65?

because its

Code:
while true do
there
So that means you never closed that loop with an end statement.

10. just a quick question, what does the "==" do

11. Originally Posted by sofa king dumb
just a quick question, what does the "==" do
It ask if the two values are equal

12. This is supposed to be a timer program but I cant really get it to work. I suspect it has something to do with the tostring because I dont know much about these kinda things.

Code:
--Ett tidtagningsprogram

--Definiera färger
svart = Color.new(0, 0, 0)
vit = Color.new(255, 255, 255)

Timer = Timer.new(0)

--Definiera bilder

screen:blit(0, 0, lua, false)
screen:print(220, 170, "Carls tidtagningsprogramm", svart)
screen:print(220, 190, "X:Info", svart)
screen:print(220, 200, "O:Gå vidare till tidtagningen", svart)
screen:print(220, 210, "Select: Avsluta", svart)
screen.flip()

while true do

screen:blit(0, 0,lua, false)
screen:print(50, 200, "Detta program tillåter dig att ta tid.", svart)
screen:print(50, 210, "Det skapades av Carl den 8 Okt 2005", svart)
screen:print(220, 170, "Triangel:Tillbaka", svart)
screen:print(220, 180, "Select: Avsluta", svart)
screen.flip()
end

screen.waitVblankStart()
screen.flip()
end

end
end
end

screen:blit(0, 0, klocka, false)
screen:print(150, 180, "tryck R för att starta, L för att Stoppa och R+L för att återställa", svart)

while true do

screen:print(220, 133, tostring(math.floor(Timer:time()/1000/60) .. ":" .. math.floor((Timer:time()/1000/60-math.floor(Timer:time()/1000/60))*60) .. ":" .. string.sub(tostring(math.floor(Timer:time()/10)), -2)), svart)
screen.flip()

Timer:start()
Timer:reset(0)
end

Timer:stop()
break
end

end
end
end

screen:blit(0, 0, luasplash, false)
screen.waitVblankStart()
screen.flip()
screen.waitVblankStart(180)
menu()
It just flips around, maybe too many screen.flip()?
I think I'm gonna start making my programs in english from now on =)

13. Too bad there aren't so many swedish programers here to enjoy your app. :)

Lol ja heter också Karl...

14. Haha, hur stor är chansen för det? Det är inte så många som heter Carl/Karl nuförtiden.
Hursomhelst, Lua fixar ju inte å, ä, ö men jag funderar på om man skulle ta och göra två versioner utav ens programm, dom som blir bra asså. En svensk och en engelsk, om man orkar. Förresten, hur funkade det där med wait.VblankStart som jag Pm:ade om?

15. come on guys...hlp plz

16. Scrolling...

Hey!

Does anybody know how to make text scroll upwards, say like film credits?

--pspmachine :icon_smil

17. Originally Posted by lingon
come on guys...hlp plz
I dont have time to look at whats wrong but here is an example of MagicianFB's timer
Code:
-- Define Colors
white = Color.new(255, 255, 255)
yellow = Color.new(255, 255, 0)

-- Print Instructions
screen:print(5, 5, "Press L to begin and R to stop.", yellow)
screen:flip()

-- Create Timer
Timer = Timer.new(0)

-- Start Main Program
while true do
screen.waitVblankStart(5)
Timer:reset()
Timer:start()
while true do
screen:clear()
screen:print(5, 5, "Press L to begin and R to stop.", yellow)
screen:print(220, 133, tostring(math.floor(Timer:time()/1000/60) .. ":" .. math.floor((Timer:time()/1000/60-math.floor(Timer:time()/1000/60))*60) .. ":" .. string.sub(tostring(math.floor(Timer:time()/10)), -2)), white)
screen:flip()
Timer:stop()
break
end
end
break
screen:save("screenshot.png")
end
end

18. And my question?

--pspmachine

19. Theres a credit scroller at http://lumo.at.tt/ but it goes from right to left.

20. how would i make it display for example a score, would this be right?
screenrint(55, 55, "your score is"x, black) --with x being the score
screen.flip()

21. Originally Posted by sofa king dumb
how would i make it display for example a score, would this be right?
screenrint(55, 55, "your score is"x, black) --with x being the score
screen.flip()
This is how you put things together:
Code:
 ..

23. Originally Posted by Twenty 2
Theres a credit scroller at http://lumo.at.tt/ but it goes from right to left.
Thanks alot buddy! :)

--pspmachine :ROFL:

24. Thx, twenty 2. I'll see what I can make out of it =)

25. how do you do colissions in lua?

26. How do you make a sprite repeat when i button is pressed?

27. ok, im not sure if im talking rubbish here but how do u create an eboot from a lua script? 0_o ive seen some programs on the files list "created in lua" but how do they become eboots? all so confusing...

Thanks

28. It doesnt have an eboot, you download Luaplayer 11 which does. It just uses script.lua which is put in the aplications.

29. ok, sorry ill re-phrase my queston:

i have seen programs availabe for download in the file section, they say they have been written in lua, but open using an eboot file, is there a way to somehow convert the lua script to be run by an eboot

e.g, run straight from the game menu, and not going through the lua player...

thanks

30. Originally Posted by sofa king dumb
how do you do colissions in lua?
I wrote a function to detect collisions a couple of days ago. I'm not sure what the method is called (bounding box?), but the function returns true if the boxes are colliding.

Code:
function squarecollision(sq1xpos, sq1xsize, sq1ypos, sq1ysize, sq2xpos, sq2xsize, sq2ypos, sq2ysize)
if sq1xpos <= (sq2xpos + sq2xsize) and (sq1xpos + sq1xsize) >= sq2xpos then
if sq1ypos <= (sq2ypos + sq2ysize) and (sq1ypos + sq1ysize) >= sq2ypos then
return true
else
return false
end
end
end
Just in case you don't understand the variables:

sq = square
1/2 = box 1 or 2
x/y = x or y axis
pos = position
size = size

Page 6 of 342 First 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 56 106 ... Last

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:11 PM.

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