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; Zitat von Twenty 2 Ok i fixed the == part and I forgot to put a % in front of ...
-
10-08-2005, 03:03 PM #151NDS Mod
- Registriert seit
- Jul 2005
- Ort
- w00+land
- Beiträge
- 645
- Points
- 18.386
- Level
- 86
- Downloads
- 0
- Uploads
- 0
That's because it's going to fast.
Zitat von Twenty 2
Code:while true do screen.waitVblankStart(5) -- add this
"15% percent of programing is creating a program, 85% percent is getting it to work like it should." - Me
[URL=http://www.mozilla.org/products/firefox/][IMG]http://img439.imageshack.us/img439/5667/getfirefox0sr.png[/IMG][/URL]
-
10-08-2005, 03:05 PM #152Developer

- Registriert seit
- Jun 2005
- Ort
- At my house...
- Beiträge
- 886
- Points
- 8.360
- Level
- 61
- Downloads
- 0
- Uploads
- 0
It still has the same problem and it shouldnt stop at 2.
F.A.L.O?
-
10-08-2005, 03:10 PM #153NDS Mod
- Registriert seit
- Jul 2005
- Ort
- w00+land
- Beiträge
- 645
- Points
- 18.386
- Level
- 86
- Downloads
- 0
- Uploads
- 0
Oh, I see, m stays as one, you never redefined it. It shoul be this:
Zitat von Twenty 2
Code:m = 1 ran = math.random(100) blue = Color.new(0, 0, 225) while true do pad = Controls.read() if pad:up() then m = m+1 screen:clear() screen:print(230, 136, string.format("%d", m), blue) screen:flip() end if pad:down() then 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 if pad:start() then break end end"15% percent of programing is creating a program, 85% percent is getting it to work like it should." - Me
[URL=http://www.mozilla.org/products/firefox/][IMG]http://img439.imageshack.us/img439/5667/getfirefox0sr.png[/IMG][/URL]
-
10-08-2005, 03:17 PM #154Developer

- Registriert seit
- Jun 2005
- Ort
- At my house...
- Beiträge
- 886
- Points
- 8.360
- Level
- 61
- Downloads
- 0
- Uploads
- 0
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?
F.A.L.O?
-
10-08-2005, 03:27 PM #155NDS Mod
- Registriert seit
- Jul 2005
- Ort
- w00+land
- Beiträge
- 645
- Points
- 18.386
- Level
- 86
- Downloads
- 0
- Uploads
- 0
the screen.waitVblanKStark() makes it wait a certain amount of time before reading the next line of code.
Zitat von Twenty 2
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."15% percent of programing is creating a program, 85% percent is getting it to work like it should." - Me
[URL=http://www.mozilla.org/products/firefox/][IMG]http://img439.imageshack.us/img439/5667/getfirefox0sr.png[/IMG][/URL]
-
10-08-2005, 03:41 PM #156QJ Gamer Green
- Registriert seit
- Jun 2005
- Beiträge
- 130
- Points
- 5.597
- Level
- 48
- Downloads
- 0
- Uploads
- 0
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
-
10-08-2005, 03:42 PM #157NDS Mod
- Registriert seit
- Jul 2005
- Ort
- w00+land
- Beiträge
- 645
- Points
- 18.386
- Level
- 86
- Downloads
- 0
- Uploads
- 0
As the error suggest, you left out an
somewhere in that code.Code:end
"15% percent of programing is creating a program, 85% percent is getting it to work like it should." - Me
[URL=http://www.mozilla.org/products/firefox/][IMG]http://img439.imageshack.us/img439/5667/getfirefox0sr.png[/IMG][/URL]
-
10-08-2005, 03:51 PM #158QJ Gamer Green
- Registriert seit
- Jun 2005
- Beiträge
- 130
- Points
- 5.597
- Level
- 48
- Downloads
- 0
- Uploads
- 0
in line 65?
Zitat von MagicianFB
because its
thereCode:while true do
-
10-08-2005, 03:57 PM #159NDS Mod
- Registriert seit
- Jul 2005
- Ort
- w00+land
- Beiträge
- 645
- Points
- 18.386
- Level
- 86
- Downloads
- 0
- Uploads
- 0
So that means you never closed that loop with an end statement.
Zitat von tupac12
"15% percent of programing is creating a program, 85% percent is getting it to work like it should." - Me
[URL=http://www.mozilla.org/products/firefox/][IMG]http://img439.imageshack.us/img439/5667/getfirefox0sr.png[/IMG][/URL]
-
10-08-2005, 06:51 PM #160QJ Gamer Blue
- Registriert seit
- Aug 2005
- Ort
- USA
- Beiträge
- 214
- Points
- 5.594
- Level
- 48
- Downloads
- 0
- Uploads
- 0
just a quick question, what does the "==" do
-
10-08-2005, 07:00 PM #161NDS Mod
- Registriert seit
- Jul 2005
- Ort
- w00+land
- Beiträge
- 645
- Points
- 18.386
- Level
- 86
- Downloads
- 0
- Uploads
- 0
It ask if the two values are equal
Zitat von sofa king dumb
"15% percent of programing is creating a program, 85% percent is getting it to work like it should." - Me
[URL=http://www.mozilla.org/products/firefox/][IMG]http://img439.imageshack.us/img439/5667/getfirefox0sr.png[/IMG][/URL]
-
10-09-2005, 04:22 AM #162
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.
It just flips around, maybe too many screen.flip()?Code:--Ett tidtagningsprogram --Definiera färger svart = Color.new(0, 0, 0) vit = Color.new(255, 255, 255) Timer = Timer.new(0) --Definiera bilder lua = Image.load("lua.png") luasplash = Image.load("luasplash.png") klocka = Image.load("klocka.png") function menu() 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 pad = Controls.read() if pad:cross() then 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 if pad:triangle() then menu() screen.waitVblankStart() screen.flip() end if pad:circle() then menua() end end end function menua() 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 pad = Controls.read() 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() if pad:r() then Timer:start() Timer:reset(0) end if pad:l() then Timer:stop() break end if pad:triangle() then menu() end end end screen:blit(0, 0, luasplash, false) screen.waitVblankStart() screen.flip() screen.waitVblankStart(180) menu()
I think I'm gonna start making my programs in english from now on =)Geändert von lingon (10-09-2005 um 08:40 AM Uhr)
-
10-09-2005, 05:45 AM #163Developer

- Registriert seit
- Sep 2005
- Ort
- Sweden
- Beiträge
- 941
- Points
- 10.075
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Too bad there aren't so many swedish programers here to enjoy your app. :)
Lol ja heter också Karl...
-
10-09-2005, 06:00 AM #164
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?
-
10-09-2005, 12:26 PM #165
come on guys...hlp plz
-
10-09-2005, 01:32 PM #166i <3 fluffy rainbows
- Registriert seit
- Jul 2005
- Ort
- United Kingdom
- Beiträge
- 862
- Points
- 12.514
- Level
- 73
- Downloads
- 0
- Uploads
- 0
Scrolling...
Hey!
Does anybody know how to make text scroll upwards, say like film credits?
Thanks in advance...
--pspmachine :icon_smil
-
10-09-2005, 02:28 PM #167Developer

- Registriert seit
- Jun 2005
- Ort
- At my house...
- Beiträge
- 886
- Points
- 8.360
- Level
- 61
- Downloads
- 0
- Uploads
- 0
I dont have time to look at whats wrong but here is an example of MagicianFB's timer
Zitat von lingon
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) pad = Controls.read() if pad:l() then Timer:reset() Timer:start() while true do pad = Controls.read() 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() if pad:r() then Timer:stop() break end end elseif pad:start() then break elseif pad:select() then screen:save("screenshot.png") end end
F.A.L.O?
-
10-09-2005, 02:34 PM #168i <3 fluffy rainbows
- Registriert seit
- Jul 2005
- Ort
- United Kingdom
- Beiträge
- 862
- Points
- 12.514
- Level
- 73
- Downloads
- 0
- Uploads
- 0
And my question?
--pspmachine
-
10-09-2005, 03:02 PM #169Developer

- Registriert seit
- Jun 2005
- Ort
- At my house...
- Beiträge
- 886
- Points
- 8.360
- Level
- 61
- Downloads
- 0
- Uploads
- 0
Theres a credit scroller at http://lumo.at.tt/ but it goes from right to left.
F.A.L.O?
-
10-09-2005, 05:13 PM #170QJ Gamer Blue
- Registriert seit
- Aug 2005
- Ort
- USA
- Beiträge
- 214
- Points
- 5.594
- Level
- 48
- Downloads
- 0
- Uploads
- 0
how would i make it display for example a score, would this be right?
screen
rint(55, 55, "your score is"x, black) --with x being the score
screen.flip()
-
10-09-2005, 05:16 PM #171NDS Mod
- Registriert seit
- Jul 2005
- Ort
- w00+land
- Beiträge
- 645
- Points
- 18.386
- Level
- 86
- Downloads
- 0
- Uploads
- 0
"your score is" .. x
Zitat von sofa king dumb
This is how you put things together:
Code:..
"15% percent of programing is creating a program, 85% percent is getting it to work like it should." - Me
[URL=http://www.mozilla.org/products/firefox/][IMG]http://img439.imageshack.us/img439/5667/getfirefox0sr.png[/IMG][/URL]
-
10-09-2005, 05:23 PM #172
- Registriert seit
- Oct 2005
- Beiträge
- 3
- Points
- 4.399
- Level
- 42
- Downloads
- 0
- Uploads
- 0
edit: *already covered*
-
10-09-2005, 10:53 PM #173i <3 fluffy rainbows
- Registriert seit
- Jul 2005
- Ort
- United Kingdom
- Beiträge
- 862
- Points
- 12.514
- Level
- 73
- Downloads
- 0
- Uploads
- 0
Thanks alot buddy! :)
Zitat von Twenty 2
--pspmachine :ROFL:
-
10-10-2005, 08:49 AM #174
Thx, twenty 2. I'll see what I can make out of it =)
-
10-10-2005, 11:46 AM #175QJ Gamer Blue
- Registriert seit
- Aug 2005
- Ort
- USA
- Beiträge
- 214
- Points
- 5.594
- Level
- 48
- Downloads
- 0
- Uploads
- 0
how do you do colissions in lua?
-
10-10-2005, 02:07 PM #176Developer

- Registriert seit
- Jun 2005
- Ort
- At my house...
- Beiträge
- 886
- Points
- 8.360
- Level
- 61
- Downloads
- 0
- Uploads
- 0
How do you make a sprite repeat when i button is pressed?
F.A.L.O?
-
10-10-2005, 03:58 PM #177
- Registriert seit
- Oct 2005
- Beiträge
- 6
- Points
- 4.421
- Level
- 42
- Downloads
- 0
- Uploads
- 0
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
-
10-10-2005, 04:06 PM #178Developer

- Registriert seit
- Jun 2005
- Ort
- At my house...
- Beiträge
- 886
- Points
- 8.360
- Level
- 61
- Downloads
- 0
- Uploads
- 0
It doesnt have an eboot, you download Luaplayer 11 which does. It just uses script.lua which is put in the aplications.
F.A.L.O?
-
10-10-2005, 10:29 PM #179
- Registriert seit
- Oct 2005
- Beiträge
- 6
- Points
- 4.421
- Level
- 42
- Downloads
- 0
- Uploads
- 0
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
-
10-11-2005, 02:36 PM #180
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.
Zitat von sofa king dumb
Just in case you don't understand the variables: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
sq = square
1/2 = box 1 or 2
x/y = x or y axis
pos = position
size = size


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