Seite 56 von 342 ErsteErste ... 6 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 106 156 ... LetzteLetzte
Zeige Ergebnis 1.651 bis 1.680 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; on lua for windows, it doesnt report an error, but nothing pops up on the screen. Code: background = Image.load("Cursor/background.png") ...

  
  1. #1651
    QJ Gamer Silver
    Points: 9.678, Level: 66
    Level completed: 7%, Points required for next Level: 372
    Overall activity: 0%

    Registriert seit
    Jun 2005
    Ort
    The Migrant Fleet
    Beiträge
    908
    Points
    9.678
    Level
    66
    Downloads
    0
    Uploads
    0

    Unhappy

    on lua for windows, it doesnt report an error, but nothing pops up on the screen.

    Code:
    background = Image.load("Cursor/background.png")
    mouse = Image.load("Cursor/mouse1.png")
    blood = Image.load("Cursor/blood.png")
    enemy = Image.load("Cursor/enemy1.png")
    
    mousex = 100
    mousey = 172
    
    while true do
    screen:clear()
    end
    
    
    pad = Controls.read()
    
    screen:blit(0, 0, background, false)
    screen:blit(mousex, mousey, mouse)
    
    if pad:up() then
    mousey = mousey - 5
    end
    
    if pad:down() then
    mousey = mousey + 5
    end
    
    if pad:left() then
    mousex = mousex - 5
    end
    
    if pad:right() then
    mousex = mousex + 5
    end
    
    if pad:r() then
    if mousex == 135 and mousey == 151 then
    screen:blit(135, 151, blood)
    end
    
    screen.waitVblankStart()
    screen.flip()
    end



  2. #1652
    Your Fate is Grim...
    Points: 11.640, Level: 70
    Level completed: 98%, Points required for next Level: 10
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Beiträge
    2.269
    Points
    11.640
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    montrob: try this:
    Code:
    background = Image.load("Cursor/background.png")
    mouse = Image.load("Cursor/mouse1.png")
    blood = Image.load("Cursor/blood.png")
    enemy = Image.load("Cursor/enemy1.png")
    
    mousex = 100
    mousey = 172
    
    
    while true do
    
    screen:clear()
    
    pad = Controls.read()
    
    screen:blit(0, 0, background, false)
    screen:blit(mousex, mousey, mouse)
    
    if pad:up() then
    mousey = mousey - 5
    end
    
    if pad:down() then
    mousey = mousey + 5
    end
    
    if pad:left() then
    mousex = mousex - 5
    end
    
    if pad:right() then
    mousex = mousex + 5
    end
    
    if pad:r() and mousex > 130 and mousex < 140 then
    if mousey > 146 and mousey < 156 then
    screen:blit(135, 151, blood)
    end
    end
    
    screen.waitVblankStart()
    screen.flip()
    end
    --------------------------------------------------------------------------------------

  3. #1653
    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

    (at the very end of the code)

    --XBL Gamertag: PhenoM904--

  4. #1654
    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

    or just take out screen:clear() it just is constantly clearing the screen
    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

  5. #1655
    QJ Gamer Silver
    Points: 9.678, Level: 66
    Level completed: 7%, Points required for next Level: 372
    Overall activity: 0%

    Registriert seit
    Jun 2005
    Ort
    The Migrant Fleet
    Beiträge
    908
    Points
    9.678
    Level
    66
    Downloads
    0
    Uploads
    0

    Standard

    For my new game, WildSniper , i am going to have bullets shooting from the enemies guns. I need to know how to detect a collision when they moving bullet hits my aimer that is moving.

  6. #1656
    Your Fate is Grim...
    Points: 11.640, Level: 70
    Level completed: 98%, Points required for next Level: 10
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Beiträge
    2.269
    Points
    11.640
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von montrob
    For my new game, WildSniper , i am going to have bullets shooting from the enemies guns. I need to know how to detect a collision when they moving bullet hits my aimer that is moving.

    well if you have ur aimer x and y like theis:
    Code:
    aimerx = 100
    amiery=  130
    and u have the bullets x and y like this:
    Code:
    enemyBulletx = 30
    enemyBullety = 50
    this u just do this:

    Code:
    if enemyBulletx > aimerrx - 5 and enemyBulletx < aimerx + 5 then
    if enemyBullety > aimerry - 5 and enemyBullety < aimery + 5 then 
    -- the rest of ur code
    this means that if the bullet comes within 5 pixels of the aimer, then it will do what u want it to do.

    hope i helped!! good luck!

    EDIT- 600th post!! w00t!!!!!!!
    --------------------------------------------------------------------------------------

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

    Does anyone know how to check what the last number is in a table? For example, if I have LUA automatically make a table like this:
    Code:
    folders=System.listDirectory()
    is there a way LUA can find the number of the last entry in that table, for example, folders[4] ? Thanks to anyone who can answer my question.
    Zitat Zitat von Noriko
    I would call you gay but I love you.


    Wait ...huh.



  8. #1658
    Mushroom Man
    Points: 7.283, Level: 56
    Level completed: 67%, Points required for next Level: 67
    Overall activity: 0%

    Registriert seit
    Sep 2005
    Ort
    UK
    Beiträge
    318
    Points
    7.283
    Level
    56
    Downloads
    0
    Uploads
    0

    Standard

    Had a look on google, and I found this :)
    Code:
    We can find the size of a table using the standard
    table library function table.getn() (i.e. get
    number of elements)
    
    table.getn(t)
    So you would want folders.getn(t), and then I presume t will hold the number of entries.

    Source: http://lua-users.org/wiki/TablesTutorial
    Geändert von Psilocybeing (04-17-2006 um 02:28 PM Uhr)

  9. #1659
    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 Psilocybeing
    Had a look on google, and I found this :)
    Code:
    We can find the size of a table using the standard
    table library function table.getn() (i.e. get
    number of elements)
    
    table.getn(t)
    So you would want folders.getn(t), and then I presume t will hold the number of entrys.

    Source: http://lua-users.org/wiki/TablesTutorial
    Thank you very much! I checked the wiki and but never saw that part of it. Thanks again, Psilocybeing, now custom characters will be easy to implement in my game by just placing in the folder. :icon_smil
    Zitat Zitat von Noriko
    I would call you gay but I love you.


    Wait ...huh.



  10. #1660
    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 other question. Is there a way that I can quote a variable? Like say I wanted to concatenate a variable, but it needed quotes around it to work. For example:
    Code:
    folders=System.listDirectory()
    
    screen:blit(0,0,"images/"..folders[1].name.."/pic.png")
    doesn't work because the folder names don't have quotes around them.

    Because the table is created by LUA, I can't manually add quotes around each entry, so is there a way I could do this when blitting to the screen? Thanks again.
    Zitat Zitat von Noriko
    I would call you gay but I love you.


    Wait ...huh.



  11. #1661
    Mushroom Man
    Points: 7.283, Level: 56
    Level completed: 67%, Points required for next Level: 67
    Overall activity: 0%

    Registriert seit
    Sep 2005
    Ort
    UK
    Beiträge
    318
    Points
    7.283
    Level
    56
    Downloads
    0
    Uploads
    0

    Standard

    It looks like in LUA the function lua_pushfstring works the same way that sprintf does in C, so you can construct your path variable before passing it to blit. I.e.

    otherString = "and so is this"
    lua_pushfstring(newString , "This is my string: %s", otherString)
    newString = "This is my string: and so is this"

    This is just pseudo code, as I've not used LUA before, just trying to be helpfull :)

  12. #1662
    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 Psilocybeing
    It looks like in LUA the function lua_pushfstring works the same way that sprintf does in C, so you can construct your path variable before passing it to blit. I.e.

    otherString = "and so is this"
    lua_pushfstring(newString , "This is my string: %s", otherString)
    newString = "This is my string: and so is this"

    This is just pseudo code, as I've not used LUA before, just trying to be helpfull :)
    Hmmm...I actually understand that lol. I'll try something like that right now and see if it works, thanks a lot.
    Zitat Zitat von Noriko
    I would call you gay but I love you.


    Wait ...huh.



  13. #1663
    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

    No go. It's telling me that lua_pushfstring is a nil value.
    Zitat Zitat von Noriko
    I would call you gay but I love you.


    Wait ...huh.



  14. #1664
    Developer
    Points: 6.074, Level: 50
    Level completed: 62%, Points required for next Level: 76
    Overall activity: 0%

    Registriert seit
    Sep 2005
    Beiträge
    270
    Points
    6.074
    Level
    50
    Downloads
    0
    Uploads
    0

    Standard

    how do you get windows lua to report errors? whenever i have an error, the screen just pops up and closes real quick.

  15. #1665
    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 other question. Is there a way that I can quote a variable? Like say I wanted to concatenate a variable, but it needed quotes around it to work. For example:
    Code:
    folders=System.listDirectory()
    
    screen:blit(0,0,"images/"..folders[1].name.."/pic.png")
    doesn't work because the folder names don't have quotes around them.

    Because the table is created by LUA, I can't manually add quotes around each entry, so is there a way I could do this when blitting to the screen? Thanks again.
    Zitat Zitat von Noriko
    I would call you gay but I love you.


    Wait ...huh.



  16. #1666
    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

    hello ever1 well if havent seen i've been working on a game: pspaintball and recently released v 0.1 so i want to implement wifi within the next few versions and i remeber a while back seeing sometin about lua wifi libary's now then heres my question:

    A: fanjita got wifi for lua to work in 2.1+ correctly?
    B:are there any tut's yet made for how to implement wifi into lua
    C: if so where
    D:anyway to check if it works or not as of i don't have a wifi connection spot
    E: thats about it=-)
    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. #1667
    Points: 4.107, Level: 40
    Level completed: 79%, Points required for next Level: 43
    Overall activity: 0%

    Registriert seit
    Apr 2006
    Beiträge
    17
    Points
    4.107
    Level
    40
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von ro0kie42
    how do you get windows lua to report errors? whenever i have an error, the screen just pops up and closes real quick.
    Send (open) "test.cmd" in a text editor. Add a 2nd line with the text "pause". Save file. It will look like this:

    luaplayer index.lua
    pause
    Geändert von dragaron (04-17-2006 um 05:24 PM Uhr)

  18. #1668
    Points: 24.247, Level: 94
    Level completed: 90%, Points required for next Level: 103
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    texas
    Beiträge
    2.803
    Points
    24.247
    Level
    94
    Downloads
    0
    Uploads
    0

    Standard

    PSPhax09, that code *should* work, but maybe the first index value of the directory isnt what you think it is. I remember when I was making LUA OS and my card became corrupted. After that, the files in the directory were literally in a random order each time. Because of this, i almost gave up because my code didnt work for it anymore. But, yeah, I got it fixed.

    Anyhoo, the first 2 index values are:
    .
    ..

    The . means current directory, the .. means back 1 directory. Also, check what folder you are trying to open. (maybe print(folders[3])).
    Either that, or add a space like: .. folders[3] ..
    牧来栠摩琠敨映汩獥
    PSN: youresam
    From Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
    --Mike Hollingsworth

  19. #1669
    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

    how do you randomize something?
    Games I Made:
    Stick Dance
    Stick Dance V2
    50% Done "Smile Quartet"


    MY XBOX.COM GAMER SPOTLIGHT!

  20. #1670
    QJ Gamer Silver
    Points: 9.678, Level: 66
    Level completed: 7%, Points required for next Level: 372
    Overall activity: 0%

    Registriert seit
    Jun 2005
    Ort
    The Migrant Fleet
    Beiträge
    908
    Points
    9.678
    Level
    66
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Greenskull
    how do you randomize something?
    Code:
    number = math.random(1,4) -- ""number is the variable you want to randomize, 1 and 4 are the numbers you want the random number to be between""
    if number >= 2 then....
    -more code here-

  21. #1671
    Developer
    Points: 6.074, Level: 50
    Level completed: 62%, Points required for next Level: 76
    Overall activity: 0%

    Registriert seit
    Sep 2005
    Beiträge
    270
    Points
    6.074
    Level
    50
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von dragaron
    Send (open) "test.cmd" in a text editor. Add a 2nd line with the text "pause". Save file. It will look like this:

    luaplayer index.lua
    pause
    thanks d00d

  22. #1672
    &lt;img src=&quot;images/smilies/psp.gif&quot; border=&quot;0&quot; alt=&quot;&quot; title=&quot;&quot; cl***=&quot;inlineimg&quot; /&gt; &lt;img src=&quot;images/smilies/Punk.gif&quot; border=&quot;0&quot; alt=&quot;&quot; title=&quot;&quot; cl***=&
    Points: 11.105, Level: 69
    Level completed: 64%, Points required for next Level: 145
    Overall activity: 0%

    Registriert seit
    Jun 2005
    Ort
    Canada
    Beiträge
    1.944
    Points
    11.105
    Level
    69
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von montrob
    Code:
    number = math.random(1,4) -- ""number is the variable you want to randomize, 1 and 4 are the numbers you want the random number to be between""
    if number >= 2 then....
    -more code here-
    and you have to add
    math.randomseed(os.time() )

    at the beginning, outside the loop

  23. #1673
    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

    have you guys just gone right pass my question??
    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

  24. #1674
    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

    ok how do i start the randomization?
    Games I Made:
    Stick Dance
    Stick Dance V2
    50% Done "Smile Quartet"


    MY XBOX.COM GAMER SPOTLIGHT!

  25. #1675
    Points: 24.247, Level: 94
    Level completed: 90%, Points required for next Level: 103
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    texas
    Beiträge
    2.803
    Points
    24.247
    Level
    94
    Downloads
    0
    Uploads
    0

    Standard

    math.randomseed(os.time() ) makes it so the numbers are TRULY random based on the time. If you didnt do this, every time you started luaplayer, the 'random' numbers generated would be the same. You call this at the begining of your program.

    math.random(low,high) returns an integer between low and high. It's that simple.
    牧来栠摩琠敨映汩獥
    PSN: youresam
    From Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
    --Mike Hollingsworth

  26. #1676
    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

    or you can just define the high one and lua well auto set low to 1
    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

  27. #1677
    Your Fate is Grim...
    Points: 11.640, Level: 70
    Level completed: 98%, Points required for next Level: 10
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Beiträge
    2.269
    Points
    11.640
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    my code:

    Code:
    pad = Controls.read()
    dx = pad:analogX()
    dy = pad:analogY()
    
            if math.abs(dx) > 32 then
    		cursorx = cursorx + dx / 64
                              height = height +1
    	end
    	if math.abs(dy) > 32 then
    		cursory = cursory + dy / 64
            end

    how can i make it so that if the analog stik goes down, height decreases by 1?right now, if you go up or down, the height increases.
    --------------------------------------------------------------------------------------

  28. #1678
    Points: 4.172, Level: 41
    Level completed: 11%, Points required for next Level: 178
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Beiträge
    7
    Points
    4.172
    Level
    41
    Downloads
    0
    Uploads
    0

    Standard

    Ok, here goes...

    I've been coding Lua for over three months now, and somewhere I got stuck. I'm trying to move multiple objects around my screen, using the same function. Something like a rack of balls on a pool table. Here it is:

    function moving()
    a = speed / 500
    if a >= 0 then
    if ball.x <= 6 or ball.x >= 460 then
    angle = pi - angle
    end
    if ball.y <= 5 or ball.y >= 252 then
    angle = angle * (-1)
    end
    ball.x = ball.x + math.cos(angle) * a
    ball.y = ball.y + math.sin(angle) * a
    speed = speed - 10
    end
    screen:blit(ball.x,ball.y ,BallNumber,true)
    end
    This function moves the object in a given "angle" for "a" pixels, untill "speed / a" reaches zero.
    I would like to enter some variables when running the function, like so:

    function moving(speed, angle, ball.x, ball.y, BallNumber)
    Now comes my problem: if call this function inside my mainloop, it gets repeated over and over, ball.x and ball.y would get resetted every time. How could I get this to work?

  29. #1679
    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

    you have to make a table where there are n balls. Then in that function make a for loop so that it happens for all the balls.
    LUA manual:
    [url]http://www.lua.org/manual/5.0/manual.html[/url]

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

  30. #1680
    Points: 4.172, Level: 41
    Level completed: 11%, Points required for next Level: 178
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Beiträge
    7
    Points
    4.172
    Level
    41
    Downloads
    0
    Uploads
    0

    Standard

    Hey Altair,

    could you give me an example of how that table would look like?


 

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

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