Seite 23 von 342 ErsteErste ... 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 73 123 ... LetzteLetzte
Zeige Ergebnis 661 bis 690 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; lui you are the best that helped me so much=-)(cmd thing) new question is there a duplication feature like laser:duplicate(laser+i) ...

  
  1. #661
    QJ Gamer Gold
    Points: 17.453, Level: 84
    Level completed: 21%, Points required for next Level: 397
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    everywhere
    Beiträge
    3.526
    Points
    17.453
    Level
    84
    Downloads
    1
    Uploads
    0

    Standard

    lui you are the best that helped me so much=-)(cmd thing)

    new question is there a duplication feature like laser:duplicate(laser+i)
    i'll do a little searching


    Geändert von slicer4ever (03-11-2006 um 07:54 PM Uhr)
    1. Failed....again...
    2. http://slicer.gibbocool.com/ stay updated on all my projects
    3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been

  2. #662
    Is in your zone.
    Points: 24.342, Level: 94
    Level completed: 99%, Points required for next Level: 8
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Ort
    Jacksonville, FL
    Beiträge
    3.429
    Points
    24.342
    Level
    94
    Downloads
    0
    Uploads
    0

    Standard

    What code would I use to make something fall down the screen?

    @slicer4ever. You could make a function with x and y variables and call the function with the coordinates you want, maybe something like...
    Code:
    function duplicate()
    screen:blit(x, y, image)
    screen.flip()
    end
    Where "image" is the image you want to duplicate
    Geändert von Mast3r_Shak3 (03-11-2006 um 08:01 PM Uhr)

    --XBL Gamertag: PhenoM904--

  3. #663
    QJ Gamer Gold
    Points: 17.453, Level: 84
    Level completed: 21%, Points required for next Level: 397
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    everywhere
    Beiträge
    3.526
    Points
    17.453
    Level
    84
    Downloads
    1
    Uploads
    0

    Standard

    would this reset the thing if used a second time?
    1. Failed....again...
    2. http://slicer.gibbocool.com/ stay updated on all my projects
    3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been

  4. #664
    Is in your zone.
    Points: 24.342, Level: 94
    Level completed: 99%, Points required for next Level: 8
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Ort
    Jacksonville, FL
    Beiträge
    3.429
    Points
    24.342
    Level
    94
    Downloads
    0
    Uploads
    0

    Standard

    No, you can call the function over and over again. The purpose is to call the same things over and over again without having to keep on typing it out. You can write the function in or outside of your main loop

    --XBL Gamertag: PhenoM904--

  5. #665
    QJ Gamer Gold
    Points: 17.453, Level: 84
    Level completed: 21%, Points required for next Level: 397
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    everywhere
    Beiträge
    3.526
    Points
    17.453
    Level
    84
    Downloads
    1
    Uploads
    0

    Standard

    k i'll try it and thanks=-)
    1. Failed....again...
    2. http://slicer.gibbocool.com/ stay updated on all my projects
    3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been

  6. #666
    Is in your zone.
    Points: 24.342, Level: 94
    Level completed: 99%, Points required for next Level: 8
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Ort
    Jacksonville, FL
    Beiträge
    3.429
    Points
    24.342
    Level
    94
    Downloads
    0
    Uploads
    0

    Standard

    Depending on the nature of the duplication you might want to put differnt variables, but thats up to you.

    --XBL Gamertag: PhenoM904--

  7. #667
    QJ Gamer Gold
    Points: 17.453, Level: 84
    Level completed: 21%, Points required for next Level: 397
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    everywhere
    Beiträge
    3.526
    Points
    17.453
    Level
    84
    Downloads
    1
    Uploads
    0

    Standard

    hmm...how do you call the function i tried:

    if pad:cross() then duplicate()
    end

    but it doesn't seem to wanna work

    edit: nvm i forgot: if pad:cross() then duplicate()
    Geändert von slicer4ever (03-11-2006 um 08:35 PM Uhr)
    1. Failed....again...
    2. http://slicer.gibbocool.com/ stay updated on all my projects
    3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been

  8. #668
    Is in your zone.
    Points: 24.342, Level: 94
    Level completed: 99%, Points required for next Level: 8
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Ort
    Jacksonville, FL
    Beiträge
    3.429
    Points
    24.342
    Level
    94
    Downloads
    0
    Uploads
    0

    Standard

    You have to do it like this.
    Code:
    function duplicate()
    if pad:cross() then 
    screen:blit(x,y, image)
    So when you want that to happen just type duplicate() in the code

    Click me for a tut on functions

    --XBL Gamertag: PhenoM904--

  9. #669
    QJ Gamer Gold
    Points: 17.453, Level: 84
    Level completed: 21%, Points required for next Level: 397
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    everywhere
    Beiträge
    3.526
    Points
    17.453
    Level
    84
    Downloads
    1
    Uploads
    0

    Standard

    k thanks=-)
    1. Failed....again...
    2. http://slicer.gibbocool.com/ stay updated on all my projects
    3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been

  10. #670
    QJ Gamer Blue
    Points: 5.036, Level: 45
    Level completed: 44%, Points required for next Level: 114
    Overall activity: 0%

    Registriert seit
    Feb 2006
    Beiträge
    224
    Points
    5.036
    Level
    45
    Downloads
    0
    Uploads
    0

    Standard

    Earlier I asked how I would read from a .txt file in lua and display some of it on screen...
    someone said the function would be io.read or something like that

    could someone explain more how to use this? Like if I wanted to write a score to a text file, would it be io.write?
    and what would I have to put after that for it to write a number to a text file

  11. #671
    QJ Gamer Green
    Points: 5.559, Level: 48
    Level completed: 5%, Points required for next Level: 191
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Beiträge
    506
    Points
    5.559
    Level
    48
    Downloads
    0
    Uploads
    0

    Standard

    That was me. But the thing is it wasn't in the list of all the commands, so im not sure if it will work. The command was: io.input(”file.txt”) where file.txt is your file.
    To write maybe io.output("...") works. You will have to try it out.

    @ PSPHax0r9
    Sure you can send it to me. Ill give it a look.
    LUA manual:
    [url]http://www.lua.org/manual/5.0/manual.html[/url]

    LUA Wiki:
    [url]http://wiki.ps2dev.org/psp:lua_player[/url]

  12. #672
    is not posting very often
    Points: 33.152, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 99,6%

    Registriert seit
    Feb 2006
    Ort
    omnipresent
    Beiträge
    5.162
    Points
    33.152
    Level
    100
    Downloads
    0
    Uploads
    0

    Standard

    @Altair - yes start and select do, why?

  13. #673
    Developer
    Points: 14.378, Level: 77
    Level completed: 82%, Points required for next Level: 72
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Ort
    Boston, MA
    Beiträge
    1.389
    Points
    14.378
    Level
    77
    Downloads
    0
    Uploads
    0

    Standard

    can somebody give me a sample code for a timer?

  14. #674
    Quality Haxing Since 1991
    Points: 29.255, Level: 99
    Level completed: 55%, Points required for next Level: 745
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Ort
    Pennsylvania, USA Fi
    Beiträge
    6.206
    Points
    29.255
    Level
    99
    Downloads
    0
    Uploads
    0

    Standard

    One comes included with luaplayer.

    @Altair - I PM'ed you.
    Zitat Zitat von Noriko
    I would call you gay but I love you.


    Wait ...huh.



  15. #675
    is not posting very often
    Points: 33.152, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 99,6%

    Registriert seit
    Feb 2006
    Ort
    omnipresent
    Beiträge
    5.162
    Points
    33.152
    Level
    100
    Downloads
    0
    Uploads
    0

    Standard

    EDIT: Sorted it out, just need to do click function!
    Geändert von Glynnder (03-12-2006 um 10:51 AM Uhr)

  16. #676
    QJ Gamer Gold
    Points: 17.453, Level: 84
    Level completed: 21%, Points required for next Level: 397
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    everywhere
    Beiträge
    3.526
    Points
    17.453
    Level
    84
    Downloads
    1
    Uploads
    0

    Standard

    hey i have a problem so here it is:

    i am using a function to blit something to the screen when i press x but now it won't stay on the screen heres my function:

    Code:
    function duplicatetoplaser()
    screen:blit(playerx+10,playery-31, playerlasertop)
    screen.flip()
    screen:waitVblankStart()
    end
    thanks in advance
    1. Failed....again...
    2. http://slicer.gibbocool.com/ stay updated on all my projects
    3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been

  17. #677
    QJ Gamer Green
    Points: 5.559, Level: 48
    Level completed: 5%, Points required for next Level: 191
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Beiträge
    506
    Points
    5.559
    Level
    48
    Downloads
    0
    Uploads
    0

    Standard

    thats because you only call the function when you press "X". So what happens is, you press X, then it goes through the function ones and then the next loop it makes its gone again.

    BTW 100th post W000T!!! Im a Journeyman, im a Journeyman!
    LUA manual:
    [url]http://www.lua.org/manual/5.0/manual.html[/url]

    LUA Wiki:
    [url]http://wiki.ps2dev.org/psp:lua_player[/url]

  18. #678
    QJ Gamer Gold
    Points: 17.453, Level: 84
    Level completed: 21%, Points required for next Level: 397
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    everywhere
    Beiträge
    3.526
    Points
    17.453
    Level
    84
    Downloads
    1
    Uploads
    0

    Standard

    so what would i do then to make it stay there permently?
    1. Failed....again...
    2. http://slicer.gibbocool.com/ stay updated on all my projects
    3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been

  19. #679
    Simon Champion!
    Points: 11.489, Level: 70
    Level completed: 60%, Points required for next Level: 161
    Overall activity: 99,0%

    Registriert seit
    Mar 2006
    Ort
    Calgary, Alberta, Ca
    Beiträge
    537
    Points
    11.489
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    Hi everyone! I have an idea for a game but I'm just learning Lua so can someone give me a bit of code to get me started? I want a simple little game that there are 3 constantly bouncing balls that when you press a trigger, you can select one and move it right or left. I need some help. How do you make it so you can switch between them and how can you make them bounce constantly. Those are my main issues. Help would be appreciated. Thank you!
    Geändert von Greenskull (03-12-2006 um 04:13 PM Uhr)

  20. #680
    QJ Gamer Blue
    Points: 5.631, Level: 48
    Level completed: 41%, Points required for next Level: 119
    Overall activity: 0%

    Registriert seit
    Jun 2005
    Beiträge
    375
    Points
    5.631
    Level
    48
    Downloads
    0
    Uploads
    0

    Standard

    im trying to get highscore working in my game but it always gives me an error

    Code:
    attempt to compare nil with a number
    these are my functions

    save function
    Code:
    function saveHighscore()
    	file = io.open(highscoreFile, "w")
    	if file then
    		file:write(high)
    		file:close()
    	end
    end
    load function
    Code:
    function loadHighscore()
    	file = io.open(highscoreFile, "r")
    	if file then
    		high = file:read("*n")
    		file:close()
    	end
    end

    this is how i call the funtion in my game(the write variable is to make sure it only saves once)
    Code:
    	if write==1 then
    		loadHighscore()
    		if high<score then
    			high=score
    			saveHighscore()
    			write=2
    		end
    	end
    i know the save funtion works because if i get rid of the part where i compare the highscore variable to your score(and just save the score) it saves it.

    i know the load funtion is fine because in my menu script i have an option to view highscore.


    Code:
    function loadHighscore()
    	file = io.open(highscoreFile, "r")
    	if file then
    		high = file:read("*n")
    		file:close()
    	end
    end
    then i just have it print the high variable and it works fine. but when i combined the two i get the error and i dont know why.

  21. #681
    Is in your zone.
    Points: 24.342, Level: 94
    Level completed: 99%, Points required for next Level: 8
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Ort
    Jacksonville, FL
    Beiträge
    3.429
    Points
    24.342
    Level
    94
    Downloads
    0
    Uploads
    0

    Standard

    What does the "function argument expected near 'blah blah'" mean? And what code would I use to make 'script.lua' (My loading screen) read 'game.lua'? (The actual game code)

    --XBL Gamertag: PhenoM904--

  22. #682
    Quality Haxing Since 1991
    Points: 29.255, Level: 99
    Level completed: 55%, Points required for next Level: 745
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Ort
    Pennsylvania, USA Fi
    Beiträge
    6.206
    Points
    29.255
    Level
    99
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von MaSt3r_ShAk3
    What does the "function argument expected near 'blah blah'" mean? And what code would I use to make 'script.lua' (My loading screen) read 'game.lua'? (The actual game code)
    Why not just make your entire loading screen file a function? Then you could condense it into one LUA file. If you can't do that for some reason, the comand would be dofile("game.lua")
    Zitat Zitat von Noriko
    I would call you gay but I love you.


    Wait ...huh.



  23. #683
    Is in your zone.
    Points: 24.342, Level: 94
    Level completed: 99%, Points required for next Level: 8
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Ort
    Jacksonville, FL
    Beiträge
    3.429
    Points
    24.342
    Level
    94
    Downloads
    0
    Uploads
    0

    Standard

    Good idea... But I need to know what the error means before I can get anyhere =/

    --XBL Gamertag: PhenoM904--

  24. #684
    Quality Haxing Since 1991
    Points: 29.255, Level: 99
    Level completed: 55%, Points required for next Level: 745
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Ort
    Pennsylvania, USA Fi
    Beiträge
    6.206
    Points
    29.255
    Level
    99
    Downloads
    0
    Uploads
    0

    Standard

    Give the exact error.
    Zitat Zitat von Noriko
    I would call you gay but I love you.


    Wait ...huh.



  25. #685
    Is in your zone.
    Points: 24.342, Level: 94
    Level completed: 99%, Points required for next Level: 8
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Ort
    Jacksonville, FL
    Beiträge
    3.429
    Points
    24.342
    Level
    94
    Downloads
    0
    Uploads
    0

    Standard

    Well im on my PSP but it was
    Code:
    Function argument expected near 'while'

    --XBL Gamertag: PhenoM904--

  26. #686
    QJ Gamer Bronze
    Points: 5.975, Level: 50
    Level completed: 13%, Points required for next Level: 175
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Ort
    Alabama
    Beiträge
    272
    Points
    5.975
    Level
    50
    Downloads
    0
    Uploads
    0

    Standard

    whats your while command look like..an example could be...

    while something == something do
    code here
    end

    make sure you just dont have something like

    while do

    whereas ..

    while true do ... would work
    My lua tutorials for PSP - www.evilmana.com/tutorials
    PSP Lua CodeBase - Add your own code examples to the codebase! - www.evilmana.com/tutorials/codebase/

  27. #687
    QJ Gamer Green
    Points: 5.559, Level: 48
    Level completed: 5%, Points required for next Level: 191
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Beiträge
    506
    Points
    5.559
    Level
    48
    Downloads
    0
    Uploads
    0

    Standard

    Soadnation, what line is the error in?
    Also, do you get the error when you leave in the comparisation of the highscore and your score, or only when you put in the save and load function?
    LUA manual:
    [url]http://www.lua.org/manual/5.0/manual.html[/url]

    LUA Wiki:
    [url]http://wiki.ps2dev.org/psp:lua_player[/url]

  28. #688
    QJ Gamer Blue
    Points: 5.036, Level: 45
    Level completed: 44%, Points required for next Level: 114
    Overall activity: 0%

    Registriert seit
    Feb 2006
    Beiträge
    224
    Points
    5.036
    Level
    45
    Downloads
    0
    Uploads
    0

    Standard

    could someone please explain how io.input and io.output are used?
    I've got io.output("highscore.txt" ) ... what do I need to put to make it write a variable (score) to the text file?
    then what would I have to put after io.input in order to read the score from the text file and display it on screen/

  29. #689
    Simon Champion!
    Points: 11.489, Level: 70
    Level completed: 60%, Points required for next Level: 161
    Overall activity: 99,0%

    Registriert seit
    Mar 2006
    Ort
    Calgary, Alberta, Ca
    Beiträge
    537
    Points
    11.489
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    hey PSPHax0r9, I have an idea for a game but I'm just learning Lua so can you give me a bit of code to get me started? I want a simple little game that there are 3 constantly bouncing balls that when you press a trigger, you can select one and move it right or left. I need some help. How do you make it so you can switch between them and how can you make them bounce constantly. Those are my main issues. Help would be appreciated. Thank you!

  30. #690
    Is in your zone.
    Points: 24.342, Level: 94
    Level completed: 99%, Points required for next Level: 8
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Ort
    Jacksonville, FL
    Beiträge
    3.429
    Points
    24.342
    Level
    94
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von PSPMillionaire
    whats your while command look like..an example could be...

    while something == something do
    code here
    end

    make sure you just dont have something like

    while do

    whereas ..

    while true do ... would work
    Heres my code so far (besides the loading screen, combining scripts later)

    Code:
    black=Color.new(0, 0, 0)
    
    player={}
    player[1]={x=240, y=250}
    
    screenwidth=480 - player:width
    
    while true do
    
    screen:blit(0, 0, background, false)
    screen:blit(player[1].x,player[1].y,player)
    
    for a=0,10 do
    for b=0,0 do
    screen:blit(45*a, 45*b, spike)
    end
    end
    
    pad = Controls.read()
    screen:clear()
    
    if pad:left() then
    player[1].x = player.x - 2
    end
    if pad:right() then
    player[1].x = player.x + 2
    end
    
    screen.waitVblankStart()
    screen.flip()
    end

    --XBL Gamertag: PhenoM904--


 

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:01 PM Uhr.

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