Seite 235 von 342 ErsteErste ... 135 185 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 285 335 ... LetzteLetzte
Zeige Ergebnis 7.021 bis 7.050 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; To those who are just starting out and wnat to integrate pressurized movement of your sprite or object or player ...

  
  1. #7021
    words are stones in my <3
    Points: 35.274, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Spokane
    Beiträge
    5.008
    Points
    35.274
    Level
    100
    My Mood
    Lonely
    Downloads
    1
    Uploads
    0

    Standard

    To those who are just starting out and wnat to integrate pressurized movement of your sprite or object or player or w/e, heres a simple way:
    Code:
    -- before your main loop, where you define variables
    sensitivity = 50 -- how far away from the center of hte analog stick should the sprite/w/e start moving
    maxspeed = 5 -- when the analog stick is fully extended in one direction, this is the speed the sprite/w/e will be moving
    
    -- in your main loop for where player movement is polled from the psp pad
    pad = Controls.read()
    
    if pad:analogX() < -sensitivity or pad:analogX() > sensitivity then
         sprite.x += analogX()/(128/maxspeed)
    end
    if pad:analogY() < -sensitivity or pad:analogY() > sensitivity then
         sprite.y += analogY()/(128/maxspeed)
    end



    ...at what speed must I live.. to be able to see you again?...

    Projects

    You can support my Open World 3D RPG for PSP by voting for it here


  2. #7022
    QJ Gamer Blue
    Points: 4.561, Level: 43
    Level completed: 6%, Points required for next Level: 189
    Overall activity: 0%

    Registriert seit
    May 2006
    Beiträge
    224
    Points
    4.561
    Level
    43
    Downloads
    0
    Uploads
    0

    Standard

    good snippet there sg. Edit: there is no += in lua. For people looking at the snippet it should be sprite.x = sprite.x + analogX()/(128/maxspeed)
    -- same with the y also.


    I have a question. If i have a function that i only use like once (a main menu funtion) can during I make this function nil (clear it from memory) to make play in my game faster? Because i was thinking that if a function was big, having it stored in memory and not being used would slow the game. Does anyone know if this would speed it up? If so how?

    would it just be like:
    Code:
    function something()
    --blah
    end
    something() = nil
    ?

  3. #7023
    QJ Gamer Blue
    Points: 3.768, Level: 38
    Level completed: 79%, Points required for next Level: 32
    Overall activity: 0%

    Registriert seit
    Apr 2007
    Beiträge
    70
    Points
    3.768
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    well i prefer to do it as oop cos that is the correct way to do a game. else..you must haave alot of thigs and functions to manage your things in the game.. soo .. as in the starfield example up ther. i asing each objet star. to an array and acces to each object property soo simple..."think in the stars as enemys on a space shoter"... but wy the second one is given me an error,, i wont move a simple sprite,
    i will move an object, in the analog angle direction..(that i have solved.) can some one say wy that nil thing.
    by the way tnks KleptoOne of taking care of my code. and.. yeaa that code line is somthing to link the classes. iwas reading a oop lua tutorial and that is the way they do, im used to oop in c++,blitzmax, stuff, but ther is a learning point in the life of a programer when must learn more languages and each one have his way.
    sorry of my englis. im not uk not nortamerica :P

  4. #7024
    QJ Gamer Gold
    Points: 11.942, Level: 71
    Level completed: 73%, Points required for next Level: 108
    Overall activity: 0%

    Registriert seit
    Nov 2006
    Ort
    ...
    Beiträge
    2.080
    Points
    11.942
    Level
    71
    Downloads
    0
    Uploads
    0

    Standard

    ok this is bothering me again, in my collision i have it where when two objects collide then it restarts the game using dofile("br.lua"). How do i have it where when the to same objects collide but the player image is different it would cancel the dofile("br.lua")?

  5. #7025
    QJ Gamer Blue
    Points: 3.768, Level: 38
    Level completed: 79%, Points required for next Level: 32
    Overall activity: 0%

    Registriert seit
    Apr 2007
    Beiträge
    70
    Points
    3.768
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    haaaa forget about that oop, i "figure out" jaja .. all i did is copy the estructore of the starts i did, and now is woeking... i start to think lua has his spirits :P...

  6. #7026
    QJ Gamer Blue
    Points: 5.344, Level: 46
    Level completed: 97%, Points required for next Level: 6
    Overall activity: 0%

    Registriert seit
    May 2006
    Beiträge
    347
    Points
    5.344
    Level
    46
    Downloads
    0
    Uploads
    0

    Standard

    Hey sg i tryed to use your example you gave and then changed what the other guy said to but it still doesn't work i get Error: main.lua:28: attempt to call global 'anaogY' (a nil val

    i am not sure what to do. What ever i try i get this error.

  7. #7027
    QJ Gamer Green
    Points: 43.021, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Jun 2005
    Ort
    Fascination Street
    Beiträge
    7.215
    Points
    43.021
    Level
    100
    Downloads
    0
    Uploads
    0

    Standard

    For Bob: youresam: put "pad:" before analogY()
    [SIZE=2][FONT=Verdana][SIZE=3][U][B]3 YEAR VETERAN[/B][/U][/SIZE][SIZE=3][FONT=Arial Black]
    [/FONT][/SIZE][/FONT][/SIZE]Thanks to the following whose ever made me a sig/av.
    [U][I][FONT=Impact]
    [/FONT][/I][/U]

  8. #7028
    QJ Gamer Blue
    Points: 4.412, Level: 42
    Level completed: 31%, Points required for next Level: 138
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    Tokoroa, New Zealand
    Beiträge
    103
    Points
    4.412
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    And spell analogY correctly. Lol.

  9. #7029
    QJ Gamer Blue
    Points: 5.344, Level: 46
    Level completed: 97%, Points required for next Level: 6
    Overall activity: 0%

    Registriert seit
    May 2006
    Beiträge
    347
    Points
    5.344
    Level
    46
    Downloads
    0
    Uploads
    0

    Standard

    oh sorry it is spelled right on my psp i get that error on analogX also though.

  10. #7030
    words are stones in my <3
    Points: 35.274, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Spokane
    Beiträge
    5.008
    Points
    35.274
    Level
    100
    My Mood
    Lonely
    Downloads
    1
    Uploads
    0

    Standard

    Ok, use this as a base (this has the fixed += thing, also, make sure you replace 'pad' with whatever your feeding the current control states into (in this case, 'pad')
    Code:
    -- before your main loop, where you define variables
    sensitivity = 50 -- how far away from the center of hte analog stick should the sprite/w/e start moving
    maxspeed = 5 -- when the analog stick is fully extended in one direction, this is the speed the sprite/w/e will be moving
    
    -- in your main loop for where player movement is polled from the psp pad
    pad = Controls.read()
    
    if pad:analogX() < -sensitivity or pad:analogX() > sensitivity then
         sprite.x = sprite.x + analogX()/(128/maxspeed)
    end
    if pad:analogY() < -sensitivity or pad:analogY() > sensitivity then
         sprite.y = sprite.y + analogY()/(128/maxspeed)
    end
    That works dandy... If all else fails, copy some of your code here.

    ...at what speed must I live.. to be able to see you again?...

    Projects

    You can support my Open World 3D RPG for PSP by voting for it here


  11. #7031
    QJ Gamer Blue
    Points: 4.561, Level: 43
    Level completed: 6%, Points required for next Level: 189
    Overall activity: 0%

    Registriert seit
    May 2006
    Beiträge
    224
    Points
    4.561
    Level
    43
    Downloads
    0
    Uploads
    0

    Standard

    (cleared my post because i found something out myself) :)

  12. #7032
    QJ Gamer Green
    Points: 6.721, Level: 53
    Level completed: 86%, Points required for next Level: 29
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Beiträge
    543
    Points
    6.721
    Level
    53
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von SG57
    Ok, use this as a base (this has the fixed += thing, also, make sure you replace 'pad' with whatever your feeding the current control states into (in this case, 'pad')
    Code:
    -- before your main loop, where you define variables
    sensitivity = 50 -- how far away from the center of hte analog stick should the sprite/w/e start moving
    maxspeed = 5 -- when the analog stick is fully extended in one direction, this is the speed the sprite/w/e will be moving
    
    -- in your main loop for where player movement is polled from the psp pad
    pad = Controls.read()
    
    if pad:analogX() < -sensitivity or pad:analogX() > sensitivity then
         sprite.x = sprite.x + analogX()/(128/maxspeed)
    end
    if pad:analogY() < -sensitivity or pad:analogY() > sensitivity then
         sprite.y = sprite.y + analogY()/(128/maxspeed)
    end
    That works dandy... If all else fails, copy some of your code here.
    youresam: SG57 you nub, test out your code before you tell another nub that it works. Had you actually read the message I relayed earlier, you would notice that you forgot to put pad: before analogX()and analogY()
    HELP ME HAIRY LEG!!!!

    I have a 1.5 (downgraded) US PSP
    [code]
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \
    ( P | S | P | - | P | r | o | g | r | a | m | m | i | n | g )
    \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/
    _ _ _ _ _
    / \ / \ / \ / \ / \
    ( A | d | m | i | n )
    \_/ \_/ \_/ \_/ \_/ [/code]

  13. #7033
    QJ Gamer Blue
    Points: 4.561, Level: 43
    Level completed: 6%, Points required for next Level: 189
    Overall activity: 0%

    Registriert seit
    May 2006
    Beiträge
    224
    Points
    4.561
    Level
    43
    Downloads
    0
    Uploads
    0

    Standard

    ??? wtf he did put pad: in front!

  14. #7034
    QJ Gamer Green
    Points: 6.721, Level: 53
    Level completed: 86%, Points required for next Level: 29
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Beiträge
    543
    Points
    6.721
    Level
    53
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von emericaska8r
    ??? wtf he did put pad: in front!
    youresam: look after the if statements
    HELP ME HAIRY LEG!!!!

    I have a 1.5 (downgraded) US PSP
    [code]
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \
    ( P | S | P | - | P | r | o | g | r | a | m | m | i | n | g )
    \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/
    _ _ _ _ _
    / \ / \ / \ / \ / \
    ( A | d | m | i | n )
    \_/ \_/ \_/ \_/ \_/ [/code]

  15. #7035
    words are stones in my <3
    Points: 35.274, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Spokane
    Beiträge
    5.008
    Points
    35.274
    Level
    100
    My Mood
    Lonely
    Downloads
    1
    Uploads
    0

    Standard

    To youresam - You and your ****y attitude... Im almost positive its what got you banned (before you created the dupe account mocking Fanjita... you should be ashamed...). Ive been working with OSlib for the past week, and to poll for analogvalue, :
    Code:
    osl_pad->analogX(); osl_pad->analogY();
    True, i forgot the pad: before each analogX/Y, so thanks for clearing that up :P (i didnt test the snippet, as Lua is no longer useful to me... , also - the person using the snippet shouldve seen the line number pointing to the line missing the pad: ;))

    New, tested version ;) lol
    Code:
    -- before your main loop, where you define variables
    sensitivity = 50 -- how far away from the center of hte analog stick should the sprite/w/e start moving
    maxspeed = 5 -- when the analog stick is fully extended in one direction, this is the speed the sprite/w/e will be moving
    
    -- in your main loop for where player movement is polled from the psp pad
    pad = Controls.read()
    
    if pad:analogX() < -sensitivity or pad:analogX() > sensitivity then
         sprite.x = sprite.x + pad:analogX()/(128/maxspeed)
    end
    if pad:analogY() < -sensitivity or pad:analogY() > sensitivity then
         sprite.y = sprite.y + pad:analogY()/(128/maxspeed)
    end

    ...at what speed must I live.. to be able to see you again?...

    Projects

    You can support my Open World 3D RPG for PSP by voting for it here


  16. #7036
    QJ Gamer Blue
    Points: 5.344, Level: 46
    Level completed: 97%, Points required for next Level: 6
    Overall activity: 0%

    Registriert seit
    May 2006
    Beiträge
    347
    Points
    5.344
    Level
    46
    Downloads
    0
    Uploads
    0

    Standard

    I got the analog working guys thanks for the help. It took a few trys. I had to adopt it to work with my code a little bit.

    Thanks Bob Hoil

  17. #7037
    QJ Gamer Blue
    Points: 4.412, Level: 42
    Level completed: 31%, Points required for next Level: 138
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    Tokoroa, New Zealand
    Beiträge
    103
    Points
    4.412
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    What does the table.concat function do?

    EDIT: Forgot to say "Please".

  18. #7038
    lol
    Points: 20.859, Level: 91
    Level completed: 2%, Points required for next Level: 491
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    Whittier, CA
    Beiträge
    5.791
    Points
    20.859
    Level
    91
    Downloads
    0
    Uploads
    0

    Standard

    It concatenates all strings of a list.

  19. #7039
    QJ Gamer Blue
    Points: 4.412, Level: 42
    Level completed: 31%, Points required for next Level: 138
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    Tokoroa, New Zealand
    Beiträge
    103
    Points
    4.412
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    Ok sweet thanks. Firefox 2 is giving me a lot of trouble and it sometimes stops pages from loading. At the moment Evilmana and lua.org are both stopped.

  20. #7040
    lol
    Points: 20.859, Level: 91
    Level completed: 2%, Points required for next Level: 491
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    Whittier, CA
    Beiträge
    5.791
    Points
    20.859
    Level
    91
    Downloads
    0
    Uploads
    0

    Standard

    lua.org is where you can find your answer also.
    http://www.lua.org/pil/11.6.html

  21. #7041
    QJ Gamer Blue
    Points: 4.412, Level: 42
    Level completed: 31%, Points required for next Level: 138
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    Tokoroa, New Zealand
    Beiträge
    103
    Points
    4.412
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    lua.org isn't loading at the moment. Damn Firefox 2.

  22. #7042
    words are stones in my <3
    Points: 35.274, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Spokane
    Beiträge
    5.008
    Points
    35.274
    Level
    100
    My Mood
    Lonely
    Downloads
    1
    Uploads
    0

    Standard

    First thing that pops up on google:

    http://www.lua.org/pil/11.6.html

    Firefox 2? im on firefox, works fine

    ...at what speed must I live.. to be able to see you again?...

    Projects

    You can support my Open World 3D RPG for PSP by voting for it here


  23. #7043
    QJ Gamer Blue
    Points: 4.412, Level: 42
    Level completed: 31%, Points required for next Level: 138
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    Tokoroa, New Zealand
    Beiträge
    103
    Points
    4.412
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    Server not found

    Firefox can't find the server at www.lua.org.

    * Check the address for typing errors such as
    ww.example.com instead of
    www.example.com

    * If you are unable to load any pages, check your computer's network
    connection.

    * If your computer or network is protected by a firewall or proxy, make sure
    that Firefox is permitted to access the Web.


    Thats what comes up every time when it decides to stop me from connecting to a site. It may be because I'm on Vista.
    It's weird. About one in five pages won't load and it is always the server not found error.

  24. #7044
    QJ 300th Hot Club Member
    Points: 14.700, Level: 78
    Level completed: 63%, Points required for next Level: 150
    Overall activity: 15,0%

    Registriert seit
    Mar 2006
    Ort
    Im not to sure.... Psp Firmware: 3.10 OE-A
    Beiträge
    1.670
    Points
    14.700
    Level
    78
    Downloads
    0
    Uploads
    0

    Standard

    youresam says: right click your network connection and hit repair, my guess is you cannot connect to your DNS server properly

  25. #7045
    QJ Gamer Blue
    Points: 4.412, Level: 42
    Level completed: 31%, Points required for next Level: 138
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    Tokoroa, New Zealand
    Beiträge
    103
    Points
    4.412
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    Windows has confirmed that this computer is currently experiencing a network connectivity problem

    Windows found a problem that cannot be repaired automatically
    Contact your Internet service provider or network administrator for help or click here for information about things you can try to help resolve this problem.


    Hmmm seems you were right but I tried to correct the problem and none of the options applied to the problem I have.
    Oh well I can put up with it I suppose.

    PS: This was my 100th post

  26. #7046
    QJ Gamer Blue
    Points: 3.679, Level: 38
    Level completed: 20%, Points required for next Level: 121
    Overall activity: 0%

    Registriert seit
    Apr 2007
    Ort
    Relative
    Beiträge
    135
    Points
    3.679
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    OK this is probably something stupid but it is really annoying me. :Argh:

    I'm trying to get the color of a pixel in a empty created image(I will put stuff on it later), and that works fine until I put it in a for loop and use the iterator as an argument in pixel()
    Code:
    image = Image.createEmpty(50,50)
    
    for i = 0, 50 do
    	color = image:pixel(0, i)
    	Colors = color:colors()
    	if Colors.r ~= nil or Colors.r ~= 0 then
    		screen:print(10,10*i,Colors.r,Color.new(255,255,255))
    	end
    end
    
    screen:flip()
    screen.waitVblankStart(1000)
    If I try to run the above code I get: "error: script.lua:5: An argument was incorrect"

    I tried using the same code only using Image.load() instead of Image.createEmpty() and it works fine, I even cleared the image with color and drew on it, just to make sure it isn't giving me problems because it's empty, but still I get the same error.

    I know this is probably some tiny mistake so just rid me of my misery. TIA :Jump:

  27. #7047
    QJ Gamer Blue
    Points: 4.369, Level: 42
    Level completed: 10%, Points required for next Level: 181
    Overall activity: 0%

    Registriert seit
    Feb 2007
    Beiträge
    246
    Points
    4.369
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    the image is 50x50 pixels, however because the coord system starts at 0, the for loop should only go to 49

  28. #7048
    QJ Gamer Gold
    Points: 11.942, Level: 71
    Level completed: 73%, Points required for next Level: 108
    Overall activity: 0%

    Registriert seit
    Nov 2006
    Ort
    ...
    Beiträge
    2.080
    Points
    11.942
    Level
    71
    Downloads
    0
    Uploads
    0

    Standard

    ok this is bothering me again, in my collision i have it where when two objects collide then it restarts the game using dofile("br.lua"). How do i have it where when the to same objects collide but the player image is different it would cancel the dofile("br.lua")?

  29. #7049
    words are stones in my <3
    Points: 35.274, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Spokane
    Beiträge
    5.008
    Points
    35.274
    Level
    100
    My Mood
    Lonely
    Downloads
    1
    Uploads
    0

    Standard

    Urameshi - You arent getting an answer, as your very specific. If you designed your code structure correctly, an if statemetn checking for collision between the two objects restarts the script, then another for when a different two objects collide does soemthing else. Honestly, i havent a clue what to tell you

    ...at what speed must I live.. to be able to see you again?...

    Projects

    You can support my Open World 3D RPG for PSP by voting for it here


  30. #7050
    QJ Gamer Gold
    Points: 11.942, Level: 71
    Level completed: 73%, Points required for next Level: 108
    Overall activity: 0%

    Registriert seit
    Nov 2006
    Ort
    ...
    Beiträge
    2.080
    Points
    11.942
    Level
    71
    Downloads
    0
    Uploads
    0

    Standard

    well.... thanks anyways


 

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 07:54 AM Uhr.

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