Seite 6 von 342 ErsteErste 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 56 106 ... LetzteLetzte
Zeige Ergebnis 151 bis 180 von 10238

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

  
  1. #151
    NDS Mod
    Points: 18.386, Level: 86
    Level completed: 8%, Points required for next Level: 464
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    w00+land
    Beiträge
    645
    Points
    18.386
    Level
    86
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von 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
    
    pad = Controls.read()
    
    if pad:up() then
    screen:clear()
    screen:print(230, 136, string.format("%d", m + 1), blue)
    screen:flip() end
    
    if pad:down() then
    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
    
    if pad:start() then
    break end
    
    end
    That's because it's going to fast.

    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]

  2. #152
    Developer
    Points: 8.360, Level: 61
    Level completed: 70%, Points required for next Level: 90
    Overall activity: 16,0%

    Registriert seit
    Jun 2005
    Ort
    At my house...
    Beiträge
    886
    Points
    8.360
    Level
    61
    Downloads
    0
    Uploads
    0

    Standard

    It still has the same problem and it shouldnt stop at 2.
    F.A.L.O?

  3. #153
    NDS Mod
    Points: 18.386, Level: 86
    Level completed: 8%, Points required for next Level: 464
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    w00+land
    Beiträge
    645
    Points
    18.386
    Level
    86
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von 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
    
    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]

  4. #154
    Developer
    Points: 8.360, Level: 61
    Level completed: 70%, Points required for next Level: 90
    Overall activity: 16,0%

    Registriert seit
    Jun 2005
    Ort
    At my house...
    Beiträge
    886
    Points
    8.360
    Level
    61
    Downloads
    0
    Uploads
    0

    Standard

    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?

  5. #155
    NDS Mod
    Points: 18.386, Level: 86
    Level completed: 8%, Points required for next Level: 464
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    w00+land
    Beiträge
    645
    Points
    18.386
    Level
    86
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von 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.
    "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]

  6. #156
    QJ Gamer Green
    Points: 5.597, Level: 48
    Level completed: 24%, Points required for next Level: 153
    Overall activity: 0%

    Registriert seit
    Jun 2005
    Beiträge
    130
    Points
    5.597
    Level
    48
    Downloads
    0
    Uploads
    0

    Standard

    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. #157
    NDS Mod
    Points: 18.386, Level: 86
    Level completed: 8%, Points required for next Level: 464
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    w00+land
    Beiträge
    645
    Points
    18.386
    Level
    86
    Downloads
    0
    Uploads
    0

    Standard

    As the error suggest, you left out an
    Code:
    end
    somewhere in that 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]

  8. #158
    QJ Gamer Green
    Points: 5.597, Level: 48
    Level completed: 24%, Points required for next Level: 153
    Overall activity: 0%

    Registriert seit
    Jun 2005
    Beiträge
    130
    Points
    5.597
    Level
    48
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von 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. #159
    NDS Mod
    Points: 18.386, Level: 86
    Level completed: 8%, Points required for next Level: 464
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    w00+land
    Beiträge
    645
    Points
    18.386
    Level
    86
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von tupac12
    in line 65?

    because its

    Code:
    while true do
    there
    So that means you never closed that loop with an end statement.
    "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. #160
    QJ Gamer Blue
    Points: 5.594, Level: 48
    Level completed: 22%, Points required for next Level: 156
    Overall activity: 0%

    Registriert seit
    Aug 2005
    Ort
    USA
    Beiträge
    214
    Points
    5.594
    Level
    48
    Downloads
    0
    Uploads
    0

    Standard

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

  11. #161
    NDS Mod
    Points: 18.386, Level: 86
    Level completed: 8%, Points required for next Level: 464
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    w00+land
    Beiträge
    645
    Points
    18.386
    Level
    86
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von sofa king dumb
    just a quick question, what does the "==" do
    It ask if the two values are equal
    "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]

  12. #162
    QJ Gamer Blue
    Points: 4.995, Level: 45
    Level completed: 23%, Points required for next Level: 155
    Overall activity: 0%

    Registriert seit
    Sep 2005
    Beiträge
    122
    Points
    4.995
    Level
    45
    Downloads
    0
    Uploads
    0

    Standard

    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 
    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()
    It just flips around, maybe too many screen.flip()?
    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)

  13. #163
    Developer
    Points: 10.075, Level: 67
    Level completed: 7%, Points required for next Level: 375
    Overall activity: 0%

    Registriert seit
    Sep 2005
    Ort
    Sweden
    Beiträge
    941
    Points
    10.075
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

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

    Lol ja heter också Karl...

  14. #164
    QJ Gamer Blue
    Points: 4.995, Level: 45
    Level completed: 23%, Points required for next Level: 155
    Overall activity: 0%

    Registriert seit
    Sep 2005
    Beiträge
    122
    Points
    4.995
    Level
    45
    Downloads
    0
    Uploads
    0

    Standard

    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. #165
    QJ Gamer Blue
    Points: 4.995, Level: 45
    Level completed: 23%, Points required for next Level: 155
    Overall activity: 0%

    Registriert seit
    Sep 2005
    Beiträge
    122
    Points
    4.995
    Level
    45
    Downloads
    0
    Uploads
    0

    Standard

    come on guys...hlp plz

  16. #166
    i <3 fluffy rainbows
    Points: 12.514, Level: 73
    Level completed: 16%, Points required for next Level: 336
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    United Kingdom
    Beiträge
    862
    Points
    12.514
    Level
    73
    Downloads
    0
    Uploads
    0

    Question Scrolling...

    Hey!

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

    Thanks in advance...


    --pspmachine :icon_smil

  17. #167
    Developer
    Points: 8.360, Level: 61
    Level completed: 70%, Points required for next Level: 90
    Overall activity: 16,0%

    Registriert seit
    Jun 2005
    Ort
    At my house...
    Beiträge
    886
    Points
    8.360
    Level
    61
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von 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)
    	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?

  18. #168
    i <3 fluffy rainbows
    Points: 12.514, Level: 73
    Level completed: 16%, Points required for next Level: 336
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    United Kingdom
    Beiträge
    862
    Points
    12.514
    Level
    73
    Downloads
    0
    Uploads
    0

    Standard

    And my question?

    --pspmachine

  19. #169
    Developer
    Points: 8.360, Level: 61
    Level completed: 70%, Points required for next Level: 90
    Overall activity: 16,0%

    Registriert seit
    Jun 2005
    Ort
    At my house...
    Beiträge
    886
    Points
    8.360
    Level
    61
    Downloads
    0
    Uploads
    0

    Standard

    Theres a credit scroller at http://lumo.at.tt/ but it goes from right to left.
    F.A.L.O?

  20. #170
    QJ Gamer Blue
    Points: 5.594, Level: 48
    Level completed: 22%, Points required for next Level: 156
    Overall activity: 0%

    Registriert seit
    Aug 2005
    Ort
    USA
    Beiträge
    214
    Points
    5.594
    Level
    48
    Downloads
    0
    Uploads
    0

    Standard

    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. #171
    NDS Mod
    Points: 18.386, Level: 86
    Level completed: 8%, Points required for next Level: 464
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    w00+land
    Beiträge
    645
    Points
    18.386
    Level
    86
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von 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()
    "your score is" .. x
    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]

  22. #172
    Points: 4.399, Level: 42
    Level completed: 25%, Points required for next Level: 151
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Beiträge
    3
    Points
    4.399
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    edit: *already covered*

  23. #173
    i <3 fluffy rainbows
    Points: 12.514, Level: 73
    Level completed: 16%, Points required for next Level: 336
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    United Kingdom
    Beiträge
    862
    Points
    12.514
    Level
    73
    Downloads
    0
    Uploads
    0

    Standard

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

    --pspmachine :ROFL:

  24. #174
    QJ Gamer Blue
    Points: 4.995, Level: 45
    Level completed: 23%, Points required for next Level: 155
    Overall activity: 0%

    Registriert seit
    Sep 2005
    Beiträge
    122
    Points
    4.995
    Level
    45
    Downloads
    0
    Uploads
    0

    Standard

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

  25. #175
    QJ Gamer Blue
    Points: 5.594, Level: 48
    Level completed: 22%, Points required for next Level: 156
    Overall activity: 0%

    Registriert seit
    Aug 2005
    Ort
    USA
    Beiträge
    214
    Points
    5.594
    Level
    48
    Downloads
    0
    Uploads
    0

    Standard

    how do you do colissions in lua?

  26. #176
    Developer
    Points: 8.360, Level: 61
    Level completed: 70%, Points required for next Level: 90
    Overall activity: 16,0%

    Registriert seit
    Jun 2005
    Ort
    At my house...
    Beiträge
    886
    Points
    8.360
    Level
    61
    Downloads
    0
    Uploads
    0

    Standard

    How do you make a sprite repeat when i button is pressed?
    F.A.L.O?

  27. #177
    Points: 4.421, Level: 42
    Level completed: 36%, Points required for next Level: 129
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Beiträge
    6
    Points
    4.421
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    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. #178
    Developer
    Points: 8.360, Level: 61
    Level completed: 70%, Points required for next Level: 90
    Overall activity: 16,0%

    Registriert seit
    Jun 2005
    Ort
    At my house...
    Beiträge
    886
    Points
    8.360
    Level
    61
    Downloads
    0
    Uploads
    0

    Standard

    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?

  29. #179
    Points: 4.421, Level: 42
    Level completed: 36%, Points required for next Level: 129
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Beiträge
    6
    Points
    4.421
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    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. #180
    Premium Member
    Points: 8.817, Level: 63
    Level completed: 23%, Points required for next Level: 233
    Overall activity: 0%

    Registriert seit
    Sep 2005
    Beiträge
    44
    Points
    8.817
    Level
    63
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von 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


 
Seite 6 von 342 ErsteErste 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 56 106 ... LetzteLetzte

Tags for this Thread

Forumregeln

  • Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
  • Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
  • Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
  • Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.
  •  





Alle Zeitangaben in WEZ -8. Es ist jetzt 09:00 PM Uhr.

Use of this Web site constitutes acceptance of the TERMS & CONDITIONS and PRIVACY POLICY
Copyright © , Caputo Media, LLC. All Rights Reserved. Cluster .