Seite 306 von 342 ErsteErste ... 206 256 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 ... LetzteLetzte
Zeige Ergebnis 9.151 bis 9.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; yea i would have done that anyways...

  
  1. #9151
    Points: 2.355, Level: 29
    Level completed: 37%, Points required for next Level: 95
    Overall activity: 0%
    Achievements:
    First 1000 Experience Points

    Registriert seit
    Aug 2008
    Beiträge
    13
    Points
    2.355
    Level
    29
    Downloads
    0
    Uploads
    0

    Standard

    yea i would have done that anyways



  2. #9152
    Lua guy
    Points: 11.690, Level: 71
    Level completed: 10%, Points required for next Level: 360
    Overall activity: 0%

    Registriert seit
    Jan 2008
    Ort
    Wales, cardiff
    Beiträge
    1.442
    Points
    11.690
    Level
    71
    My Mood
    Blah
    Downloads
    0
    Uploads
    0

    Standard

    though u can re-use them thats wat i meant. 4 better Anim use animLib

  3. #9153
    Points: 2.355, Level: 29
    Level completed: 37%, Points required for next Level: 95
    Overall activity: 0%
    Achievements:
    First 1000 Experience Points

    Registriert seit
    Aug 2008
    Beiträge
    13
    Points
    2.355
    Level
    29
    Downloads
    0
    Uploads
    0

    Standard

    just for now im gonna stick with animation without libraries, better for me to learn

  4. #9154
    QJ Gamer Bronze
    Points: 5.381, Level: 47
    Level completed: 16%, Points required for next Level: 169
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Beiträge
    550
    Points
    5.381
    Level
    47
    Downloads
    1
    Uploads
    0

    Standard

    Zitat Zitat von dan369 Beitrag anzeigen
    Code:
    timer = 0
    
    function moveL()
    timer = timer + 1
    
    if timer == 2 then
    change img
    elseif timer == 4 then 
    change img
          end
    end
    That is absolutely horrible code. Do not try help people untill you have a better grasp of the language yourself.
    Ever heard of tables and math?

    Forgot That. Have a drifferent timer 4 each animation, e.g timer2 = 0, timer3 = 0 etc
    Why? You should only need one timer for all animations.

    4 better Anim use animLib
    You should be able to make something as good as animLib yourself. Animation, as well as sprite sheets are not difficult. Pay more attention in Maths, and read up on data structures (Such as Lua's tables.)

  5. #9155
    Points: 2.355, Level: 29
    Level completed: 37%, Points required for next Level: 95
    Overall activity: 0%
    Achievements:
    First 1000 Experience Points

    Registriert seit
    Aug 2008
    Beiträge
    13
    Points
    2.355
    Level
    29
    Downloads
    0
    Uploads
    0

    Standard

    in no way were his intention for me to copy and paste that code or even copy and paste and modify slightly but give me a hint on a way to do sprite animation via a counter

  6. #9156
    QJ Gamer Bronze
    Points: 5.381, Level: 47
    Level completed: 16%, Points required for next Level: 169
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Beiträge
    550
    Points
    5.381
    Level
    47
    Downloads
    1
    Uploads
    0

    Standard

    Zitat Zitat von tre_flip Beitrag anzeigen
    in no way were his intention for me to copy and paste that code or even copy and paste and modify slightly but give me a hint on a way to do sprite animation via a counter
    He has shown you the worst possible way to do it (which happens to be the way he does it in his shoddily coded RPG)
    Geändert von Nielkie (08-06-2008 um 09:39 PM Uhr)

  7. #9157
    Points: 2.355, Level: 29
    Level completed: 37%, Points required for next Level: 95
    Overall activity: 0%
    Achievements:
    First 1000 Experience Points

    Registriert seit
    Aug 2008
    Beiträge
    13
    Points
    2.355
    Level
    29
    Downloads
    0
    Uploads
    0

    Standard

    why so negative? technically the worst is a way not working at all.
    so if your so smart then what is the best/way you recommend

  8. #9158
    QJ Gamer Green
    Points: 3.721, Level: 38
    Level completed: 48%, Points required for next Level: 79
    Overall activity: 0%

    Registriert seit
    Jan 2008
    Beiträge
    612
    Points
    3.721
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    A method similar to what I recommended or one you make on your own, but that would require too much comprehension and understanding on your part and thus is fairly pointless until you actually learn to do things on your own in the world of programming.

  9. #9159
    Lua guy
    Points: 11.690, Level: 71
    Level completed: 10%, Points required for next Level: 360
    Overall activity: 0%

    Registriert seit
    Jan 2008
    Ort
    Wales, cardiff
    Beiträge
    1.442
    Points
    11.690
    Level
    71
    My Mood
    Blah
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Nielkie Beitrag anzeigen
    He has shown you the worst possible way to do it (which happens to be the way he does it in his shoddily coded RPG)
    I know that its the worst, most inefficient way of doing animation.
    It's just a simple, easy way.
    You most probably could make a better animation urself. I was just suggesting POSSIBLE ways of doing it.

  10. #9160
    QJ Gamer Silver
    Points: 10.263, Level: 67
    Level completed: 54%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    2.326
    Points
    10.263
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    Look at the animation snippet I did here: Lua Code Snippets I did a while back...

  11. #9161
    Lua guy
    Points: 11.690, Level: 71
    Level completed: 10%, Points required for next Level: 360
    Overall activity: 0%

    Registriert seit
    Jan 2008
    Ort
    Wales, cardiff
    Beiträge
    1.442
    Points
    11.690
    Level
    71
    My Mood
    Blah
    Downloads
    0
    Uploads
    0

    Wink

    Zitat Zitat von yaustar Beitrag anzeigen
    Look at the animation snippet I did here: Lua Code Snippets I did a while back...
    Yaustar: Nice i'll take a look at those.
    One question: Are u using Spirte sheets for it??? (I'm not near a computer right now so i cant see) i'm on my ps3:Jump:

  12. #9162
    QJ Gamer Silver
    Points: 10.263, Level: 67
    Level completed: 54%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    2.326
    Points
    10.263
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    Yes I am.

  13. #9163
    Lua guy
    Points: 11.690, Level: 71
    Level completed: 10%, Points required for next Level: 360
    Overall activity: 0%

    Registriert seit
    Jan 2008
    Ort
    Wales, cardiff
    Beiträge
    1.442
    Points
    11.690
    Level
    71
    My Mood
    Blah
    Downloads
    0
    Uploads
    0

    Standard

    Hummmhh....... SpirteSheets. After looking through yaustars example. I got confused.
    So could someone explain???

  14. #9164
    Banned for LIFE
    Points: 18.744, Level: 86
    Level completed: 79%, Points required for next Level: 106
    Overall activity: 0%

    Registriert seit
    Oct 2006
    Ort
    East London, England
    Beiträge
    2
    Points
    18.744
    Level
    86
    Downloads
    0
    Uploads
    0

    Standard

    If I remember correctly it is very well commented ...

  15. #9165
    Lua guy
    Points: 11.690, Level: 71
    Level completed: 10%, Points required for next Level: 360
    Overall activity: 0%

    Registriert seit
    Jan 2008
    Ort
    Wales, cardiff
    Beiträge
    1.442
    Points
    11.690
    Level
    71
    My Mood
    Blah
    Downloads
    0
    Uploads
    0

    Standard

    After looking through yaustars example i got pretty confused.
    Not with the animation but with the first function.
    it said sumthing like setmetatable???
    what is that?????

  16. #9166
    Banned for LIFE
    Points: 18.744, Level: 86
    Level completed: 79%, Points required for next Level: 106
    Overall activity: 0%

    Registriert seit
    Oct 2006
    Ort
    East London, England
    Beiträge
    2
    Points
    18.744
    Level
    86
    Downloads
    0
    Uploads
    0

  17. #9167
    Lua guy
    Points: 11.690, Level: 71
    Level completed: 10%, Points required for next Level: 360
    Overall activity: 0%

    Registriert seit
    Jan 2008
    Ort
    Wales, cardiff
    Beiträge
    1.442
    Points
    11.690
    Level
    71
    My Mood
    Blah
    Downloads
    0
    Uploads
    0

    Standard

    Thanks, it was thinking y the 2 __?? but now i know.
    And why there's index, it refers it to a table.
    Thanks

  18. #9168
    QJ Gamer Green
    Points: 3.721, Level: 38
    Level completed: 48%, Points required for next Level: 79
    Overall activity: 0%

    Registriert seit
    Jan 2008
    Beiträge
    612
    Points
    3.721
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    You CANNOT halfass your way around with metatables - you HAVE to learn them. Lua-users.org has some very good articles on how metatables (or even normal ones) can be used to trick your way into OOP in lua, and that's exactly what most people use them for.

  19. #9169
    Lua guy
    Points: 11.690, Level: 71
    Level completed: 10%, Points required for next Level: 360
    Overall activity: 0%

    Registriert seit
    Jan 2008
    Ort
    Wales, cardiff
    Beiträge
    1.442
    Points
    11.690
    Level
    71
    My Mood
    Blah
    Downloads
    0
    Uploads
    0

    Standard

    Ok another question. I have 4 drifferent tiles in one img.
    How would i code it so that it will take each img (32x32) and but it simply into a number on a map so that 1 would represent the first img etc.
    ???

  20. #9170
    Banned for LIFE
    Points: 18.744, Level: 86
    Level completed: 79%, Points required for next Level: 106
    Overall activity: 0%

    Registriert seit
    Oct 2006
    Ort
    East London, England
    Beiträge
    2
    Points
    18.744
    Level
    86
    Downloads
    0
    Uploads
    0

    Standard

    Why dont you make your life easier and just use four seperate images ?

  21. #9171
    QJ Gamer Bronze
    Points: 5.583, Level: 48
    Level completed: 17%, Points required for next Level: 167
    Overall activity: 0%

    Registriert seit
    May 2007
    Beiträge
    127
    Points
    5.583
    Level
    48
    Downloads
    0
    Uploads
    0

    Standard

    you could setup an SDL_Rect for each tile in the image. I dont know what luaplayer functions there are for this sort of thing. just calculate tile_index * width_of_tile to get the start offset for that tile. just remember youd need to blit 32 pixels then add tile_sheet_image_width - 32 to get to the next row in the tile. But if luaplayer gives you access to SDL_Rect's then that woud be a lot easier.
    -- Code Monkey : Sarien, Fishguts, Cracks and Crevices --

    "Did IQ's just drop sharply while I was away?" (Ripley)

  22. #9172
    Lua guy
    Points: 11.690, Level: 71
    Level completed: 10%, Points required for next Level: 360
    Overall activity: 0%

    Registriert seit
    Jan 2008
    Ort
    Wales, cardiff
    Beiträge
    1.442
    Points
    11.690
    Level
    71
    My Mood
    Blah
    Downloads
    0
    Uploads
    0

    Standard

    thanks i understand.
    calculate the img width and height of each tile which is 32x32
    Then put into a seperate array??

  23. #9173
    QJ Gamer Blue
    Points: 4.268, Level: 41
    Level completed: 59%, Points required for next Level: 82
    Overall activity: 0%

    Registriert seit
    Apr 2008
    Beiträge
    497
    Points
    4.268
    Level
    41
    Downloads
    0
    Uploads
    0

    Standard

    ok, I have a question, I'm working on a battle system demo, and I am working on Ai for it, I have a function that takes away 5 health when the AI attacks, but it continues to take 5 health continuosly, how do I make it only take away 5 points per turn (I'm doing turn based battlesystem) I am thinking something like monster.attack and oldmonster.attack, but I'm not sure.

  24. #9174
    QJ Gamer Silver
    Points: 10.263, Level: 67
    Level completed: 54%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    2.326
    Points
    10.263
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von PSProgramer Beitrag anzeigen
    ok, I have a question, I'm working on a battle system demo, and I am working on Ai for it, I have a function that takes away 5 health when the AI attacks, but it continues to take 5 health continuosly, how do I make it only take away 5 points per turn (I'm doing turn based battlesystem) I am thinking something like monster.attack and oldmonster.attack, but I'm not sure.
    If the game is turn based and this is happening, then there is something wrong with the turn based system. I would take a deeper look at the logic.

  25. #9175
    QJ Gamer Bronze
    Points: 5.583, Level: 48
    Level completed: 17%, Points required for next Level: 167
    Overall activity: 0%

    Registriert seit
    May 2007
    Beiträge
    127
    Points
    5.583
    Level
    48
    Downloads
    0
    Uploads
    0

    Standard

    sure, you can precalc your offsets, its really only handy when you have a sprite sheet that is more than 1 line of sprites deep, since if its just 1 row, its just an index * 32 calculation.

    but you could if you wanted to precalc you could do something like

    Code:
    sprites = {}
    
    function CalcSprites(sprite_sheet, sheet_width, sheet_height, sprite_height, sprite_width)
        local row
        local col
        
        for row = 0, sheet_height / sprite_height do
            for col = 0 .. sheet_width / sprite_width do
                sprites[#sprites] = { width = sprite_width, 
                    height = sprite_height,
                    sheet = sprite_sheet,
                    offset = (row * sprite_height) + (col * sprite_width) }
            end
        end
    end
    putting the sprite sheet in there, you can load mutliple sprites into the one table, or extra things like a transparency colour, etc
    -- Code Monkey : Sarien, Fishguts, Cracks and Crevices --

    "Did IQ's just drop sharply while I was away?" (Ripley)

  26. #9176
    QJ Gamer Blue
    Points: 4.268, Level: 41
    Level completed: 59%, Points required for next Level: 82
    Overall activity: 0%

    Registriert seit
    Apr 2008
    Beiträge
    497
    Points
    4.268
    Level
    41
    Downloads
    0
    Uploads
    0

    Standard

    @yuastar: should I have 2 different loops, for each turn?? one for characters, and one for enemies??

  27. #9177
    Lua guy
    Points: 11.690, Level: 71
    Level completed: 10%, Points required for next Level: 360
    Overall activity: 0%

    Registriert seit
    Jan 2008
    Ort
    Wales, cardiff
    Beiträge
    1.442
    Points
    11.690
    Level
    71
    My Mood
    Blah
    Downloads
    0
    Uploads
    0

    Standard

    Sorry, i should of said its 4 a tilemap. I've dun it know. Anyway.
    Code:
    function getTileWidth()
    Width = tiles:Width
    tileWidth = {}
    
    if Width then
       Width = Width / 2
        table.insert(tileWidth, width)
    end
    Then should I do sumthing like this‚
    Code:
     
    tiledata = {
    tileWidth[1],
    tileWidth[2]
    }
    Would That work....?????
    Geändert von dan369 (08-07-2008 um 12:36 PM Uhr)

  28. #9178
    QJ Gamer Blue
    Points: 4.268, Level: 41
    Level completed: 59%, Points required for next Level: 82
    Overall activity: 0%

    Registriert seit
    Apr 2008
    Beiträge
    497
    Points
    4.268
    Level
    41
    Downloads
    0
    Uploads
    0

    Standard

    BTW: @yuastar: I figured it out thank you

  29. #9179
    Points: 1.864, Level: 25
    Level completed: 64%, Points required for next Level: 36
    Overall activity: 0%
    Achievements:
    First 1000 Experience Points

    Registriert seit
    Aug 2008
    Beiträge
    8
    Points
    1.864
    Level
    25
    Downloads
    0
    Uploads
    0

    Standard

    i have a question. how do you make 3d lua applications?

  30. #9180
    QJ Gamer Green
    Points: 3.721, Level: 38
    Level completed: 48%, Points required for next Level: 79
    Overall activity: 0%

    Registriert seit
    Jan 2008
    Beiträge
    612
    Points
    3.721
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    For a very basic screw understanding it but know how to do it kind of tutorial, check here:
    http://tacticalpenguin.com/snippets/3d.txt


 

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 .