Seite 276 von 342 ErsteErste ... 176 226 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 326 ... LetzteLetzte
Zeige Ergebnis 8.251 bis 8.280 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; Just a heads up: JaX3RiR has recompiled Lua Player V0.16 to 3.XX kernel now (The other one you guys linked ...

  
  1. #8251
    QJ Gamer Silver
    Points: 6.948, Level: 54
    Level completed: 99%, Points required for next Level: 2
    Overall activity: 0%

    Registriert seit
    Aug 2007
    Beiträge
    657
    Points
    6.948
    Level
    54
    Downloads
    5
    Uploads
    0

    Standard

    Just a heads up:

    JaX3RiR has recompiled Lua Player V0.16 to 3.XX kernel now
    (The other one you guys linked to above, was V0.20)

    [RELEASE]3.XX Kernel homebrew pack


    PSP: PSP SLIM 2001 TA-088v2
    Custom Firmware: 5.00 M33-6

  2. #8252
    Developer and Tutor.
    Points: 8.736, Level: 62
    Level completed: 96%, Points required for next Level: 14
    Overall activity: 0%

    Registriert seit
    Jul 2007
    Ort
    Widnes, England
    Beiträge
    1.649
    Points
    8.736
    Level
    62
    My Mood
    Happy
    Downloads
    0
    Uploads
    0

    Standard

    doesn't work
    ------ FaT3oYCG -----
    AKA Craig, call me what you want to It's your preference.
    My Website: http://www.modern-gamer.co.uk/

    Currently working on:
    (0) MediaGrab
    (0) PGE Gears Of War - On hold (Very large project).
    (0) PS???? -On Hold A tactical 2d side scrolling game involving AI and online multiplayer features. - Tile engine nearley finished (1 bug to fix).

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

    Zitat Zitat von Mr_Shizzy
    Just a heads up:

    JaX3RiR has recompiled Lua Player V0.16 to 3.XX kernel now
    (The other one you guys linked to above, was V0.20)

    [RELEASE]3.XX Kernel homebrew pack
    Sweet!

  4. #8254
    Points: 2.781, Level: 32
    Level completed: 21%, Points required for next Level: 119
    Overall activity: 0%

    Registriert seit
    Dec 2007
    Beiträge
    4
    Points
    2.781
    Level
    32
    Downloads
    0
    Uploads
    0

    Standard

    Code:
    blue = Color.new(0,0,255)
    white = Color.new(255,255,255)
    red = Color.new(255,0,0)
    green = Color.new(0,255,0)
    
    test = {x = -8, y = 243, speed = 3, img = Image.createEmpty(8, 8)}
    test.img:clear(green)
    
    box1 = Image.createEmpty(480, 80)
    box1:clear(blue)
    
    line = Image.createEmpty(5, 80)
    line:clear(white)
    
    line1 = Image.createEmpty(90, 5)
    line1:clear(white)
    
    line2 = Image.createEmpty(3, 52)
    line2:clear(white)
    
    back = Image.createEmpty(480, 140)
    back:clear(red)
    
    function drawimages()
       screen:blit(0, 141, box1)
       screen:blit(101, 141, line)
       screen:blit(196, 141, line)
       screen:blit(0, 0, back)
       screen:blit(106, 141, line1)
       screen:blit(106, 216, line1)
       screen:blit(239, 221, line2)
       screen:blit(test.x, test.y, test.img)
    end
    
    function drawtext()
       screen:print(116, 151, "Fight", white)
       screen:print(116, 166, "Harmony", white)
       screen:print(116, 181, "Dissonance", white)
       screen:print(116, 196, "Items", white)
    end
    
    function test()
       if test.x < 500 then
          test.x = test.x + test.speed
       end
    end
    
    while true do
       screen:clear()
    
       drawimages()
       drawtext()
       test()
       
       screen.waitVblankStart()
       screen.flip()
    end
    Alright, I've been learning Lua for couple months now, and I'm stumped by this error message:

    34:attempt to index global 'test' (a function value)
    What am I doing wrong?
    Note: The code should cause an 8x8 green block scroll from offscreen on the left side of the screen to offscreen on the right side.

  5. #8255
    QJ Gamer Bronze
    Points: 8.665, Level: 62
    Level completed: 72%, Points required for next Level: 85
    Overall activity: 0%

    Registriert seit
    Mar 2007
    Beiträge
    758
    Points
    8.665
    Level
    62
    Downloads
    0
    Uploads
    0

    Standard

    I'm pretty sure it's because you have a function called test and an array/table called test. Rename one of them. Then I THINK it will work.

  6. #8256
    QJ Gamer Green
    Points: 13.310, Level: 75
    Level completed: 15%, Points required for next Level: 340
    Overall activity: 0%

    Registriert seit
    Dec 2005
    Ort
    Here
    Beiträge
    2.715
    Points
    13.310
    Level
    75
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Foxhull
    Code:
    blue = Color.new(0,0,255)
    white = Color.new(255,255,255)
    red = Color.new(255,0,0)
    green = Color.new(0,255,0)
    
    test = {x = -8, y = 243, speed = 3, img = Image.createEmpty(8, 8)}
    test.img:clear(green)
    
    box1 = Image.createEmpty(480, 80)
    box1:clear(blue)
    
    line = Image.createEmpty(5, 80)
    line:clear(white)
    
    line1 = Image.createEmpty(90, 5)
    line1:clear(white)
    
    line2 = Image.createEmpty(3, 52)
    line2:clear(white)
    
    back = Image.createEmpty(480, 140)
    back:clear(red)
    
    function drawimages()
       screen:blit(0, 141, box1)
       screen:blit(101, 141, line)
       screen:blit(196, 141, line)
       screen:blit(0, 0, back)
       screen:blit(106, 141, line1)
       screen:blit(106, 216, line1)
       screen:blit(239, 221, line2)
       screen:blit(test.x, test.y, test.img)
    end
    
    function drawtext()
       screen:print(116, 151, "Fight", white)
       screen:print(116, 166, "Harmony", white)
       screen:print(116, 181, "Dissonance", white)
       screen:print(116, 196, "Items", white)
    end
    
    function test()
       if test.x < 500 then
          test.x = test.x + test.speed
       end
    end
    
    while true do
       screen:clear()
    
       drawimages()
       drawtext()
       test()
       
       screen.waitVblankStart()
       screen.flip()
    end
    Alright, I've been learning Lua for couple months now, and I'm stumped by this error message:


    What am I doing wrong?
    Note: The code should cause an 8x8 green block scroll from offscreen on the left side of the screen to offscreen on the right side.
    You named "test" a table AND a function.
    Rename one of them.

    Dang it, michaelp beat me to it. lol
    [CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]

  7. #8257
    Points: 2.781, Level: 32
    Level completed: 21%, Points required for next Level: 119
    Overall activity: 0%

    Registriert seit
    Dec 2007
    Beiträge
    4
    Points
    2.781
    Level
    32
    Downloads
    0
    Uploads
    0

    Standard

    thanks, i'll try that

    EDIT: Thanks, works now.

  8. #8258
    QJ Gamer Green
    Points: 13.310, Level: 75
    Level completed: 15%, Points required for next Level: 340
    Overall activity: 0%

    Registriert seit
    Dec 2005
    Ort
    Here
    Beiträge
    2.715
    Points
    13.310
    Level
    75
    Downloads
    0
    Uploads
    0

    Standard

    Come back for any help you need. :)
    [CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]

  9. #8259
    QJ Gamer Blue
    Points: 5.636, Level: 48
    Level completed: 44%, Points required for next Level: 114
    Overall activity: 0%

    Registriert seit
    Sep 2005
    Beiträge
    300
    Points
    5.636
    Level
    48
    Downloads
    0
    Uploads
    0

    Standard

    This is bugging the hell out of me. What EXACTLY is the screen object? I used to think it was an image, but when I tried to use it like one, it told me it was a table (With no elements in it). Can someone please explain it to me? I need to find a way to use it like an image object.

  10. #8260
    Developer and Tutor.
    Points: 8.736, Level: 62
    Level completed: 96%, Points required for next Level: 14
    Overall activity: 0%

    Registriert seit
    Jul 2007
    Ort
    Widnes, England
    Beiträge
    1.649
    Points
    8.736
    Level
    62
    My Mood
    Happy
    Downloads
    0
    Uploads
    0

    Standard

    it is like a container

    - if you blit an image to it it contains that data like a table if you want to use it like an image you cant i like to blit a blank image to it 480 x 272 and use that instead then it will act like a screen and an image

    just remember

    image_screen = image.createEmpty(480, 272)

    then

    image_screen.flip() and so on

    thanks
    ------ FaT3oYCG -----
    AKA Craig, call me what you want to It's your preference.
    My Website: http://www.modern-gamer.co.uk/

    Currently working on:
    (0) MediaGrab
    (0) PGE Gears Of War - On hold (Very large project).
    (0) PS???? -On Hold A tactical 2d side scrolling game involving AI and online multiplayer features. - Tile engine nearley finished (1 bug to fix).

  11. #8261
    QJ Gamer Blue
    Points: 5.636, Level: 48
    Level completed: 44%, Points required for next Level: 114
    Overall activity: 0%

    Registriert seit
    Sep 2005
    Beiträge
    300
    Points
    5.636
    Level
    48
    Downloads
    0
    Uploads
    0

    Standard

    I see.... I was trying to copy the screen into another variable:
    Code:
    zoomOut = screen
    But obviously this didn't work. Do you know any way I could make it work?

  12. #8262
    Developer and Tutor.
    Points: 8.736, Level: 62
    Level completed: 96%, Points required for next Level: 14
    Overall activity: 0%

    Registriert seit
    Jul 2007
    Ort
    Widnes, England
    Beiträge
    1.649
    Points
    8.736
    Level
    62
    My Mood
    Happy
    Downloads
    0
    Uploads
    0

    Standard

    why may i ask do you want to do that

    from what you have said i can hazzard a guess that you want to take the screen content and soom out from it you could do this one of two ways that i can think of

    screen:save() the screen and resize that
    or
    use the gu functions i dont know the specific commands off my head as i try to avoid using them where i dont need to and also because i havent learnt to use them properly

    thanks
    ------ FaT3oYCG -----
    AKA Craig, call me what you want to It's your preference.
    My Website: http://www.modern-gamer.co.uk/

    Currently working on:
    (0) MediaGrab
    (0) PGE Gears Of War - On hold (Very large project).
    (0) PS???? -On Hold A tactical 2d side scrolling game involving AI and online multiplayer features. - Tile engine nearley finished (1 bug to fix).

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

    Learn the GU functions.
    Its faster.

  14. #8264
    QJ Gamer Blue
    Points: 5.636, Level: 48
    Level completed: 44%, Points required for next Level: 114
    Overall activity: 0%

    Registriert seit
    Sep 2005
    Beiträge
    300
    Points
    5.636
    Level
    48
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von FaT3oYCG
    why may i ask do you want to do that

    from what you have said i can hazzard a guess that you want to take the screen content and soom out from it you could do this one of two ways that i can think of

    screen:save() the screen and resize that
    or
    use the gu functions i dont know the specific commands off my head as i try to avoid using them where i dont need to and also because i havent learnt to use them properly

    thanks
    Your dead on. It's not REALLY a zoom effect though, more of a cropping effect. I was considering doing the screen:save(), but it wouldn't really be that efferent since I would have to save a file and delete it every time. I guess I'll have to learn the GU functions. Thanks. :)

  15. #8265
    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

    Zitat Zitat von Highsight
    Your dead on. It's not REALLY a zoom effect though, more of a cropping effect. I was considering doing the screen:save(), but it wouldn't really be that efferent since I would have to save a file and delete it every time. I guess I'll have to learn the GU functions. Thanks. :)
    What did you use for mazegen then ?

  16. #8266
    QJ Gamer Blue
    Points: 5.636, Level: 48
    Level completed: 44%, Points required for next Level: 114
    Overall activity: 0%

    Registriert seit
    Sep 2005
    Beiträge
    300
    Points
    5.636
    Level
    48
    Downloads
    0
    Uploads
    0

    Standard

    That was 3DGU, I believe they are referring to non 3D GU functions... right? XD

    Incidentally, where can I learn about the GU functions Anti? I can't seem to find anything other than 3D GU, and I don't see how those would help. :/

  17. #8267
    Developer and Tutor.
    Points: 8.736, Level: 62
    Level completed: 96%, Points required for next Level: 14
    Overall activity: 0%

    Registriert seit
    Jul 2007
    Ort
    Widnes, England
    Beiträge
    1.649
    Points
    8.736
    Level
    62
    My Mood
    Happy
    Downloads
    0
    Uploads
    0

    Standard

    its gu and gum commands if i am correct the 3d cube shows most of the commands but if you want to crop an image im sure that there is a much simpler way

    for example create a blank image the size that you would like to crop to this will act like a view finder then blit the original image to that with minus co ordinate for that image and only the part that you want to see should be shown - that isnt a very good way though

    im sure that screen:blit() accepts about 7 commands max which will do what you want with ease one mo ill try and find out the specific order they are in

    EDIT:

    screen:blit(x position, y position, full image to use, tile x start position on that image, tile y start position on that image, tile width, tile height)

    an example of this would be

    Code:
    lua_image = Image.load("lua_image.png") -- for example 200 x 200 image
    
    screen:blit(10, 10, lua_image, 30, 40, 100, 100) -- blits the image to 10, 10 x and y co-ordinates, tells it to use the lua_image and start 30 across from the start position in the image and 40 down, then takes 100 x 100 pixels of the image and blits that
    ------ FaT3oYCG -----
    AKA Craig, call me what you want to It's your preference.
    My Website: http://www.modern-gamer.co.uk/

    Currently working on:
    (0) MediaGrab
    (0) PGE Gears Of War - On hold (Very large project).
    (0) PS???? -On Hold A tactical 2d side scrolling game involving AI and online multiplayer features. - Tile engine nearley finished (1 bug to fix).

  18. #8268
    QJ Gamer Blue
    Points: 5.636, Level: 48
    Level completed: 44%, Points required for next Level: 114
    Overall activity: 0%

    Registriert seit
    Sep 2005
    Beiträge
    300
    Points
    5.636
    Level
    48
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von FaT3oYCG
    its gu and gum commands if i am correct the 3d cube shows most of the commands but if you want to crop an image im sure that there is a much simpler way

    for example create a blank image the size that you would like to crop to this will act like a view finder then blit the original image to that with minus co ordinate for that image and only the part that you want to see should be shown - that isnt a very good way though

    im sure that screen:blit() accepts about 7 commands max which will do what you want with ease one mo ill try and find out the specific order they are in

    EDIT:

    screen:blit(x position, y position, full image to use, tile x start position on that image, tile y start position on that image, tile width, tile height)

    an example of this would be

    Code:
    lua_image = Image.load("lua_image.png") -- for example 200 x 200 image
    
    screen:blit(10, 10, lua_image, 30, 40, 100, 100) -- blits the image to 10, 10 x and y co-ordinates, tells it to use the lua_image and start 30 across from the start position in the image and 40 down, then takes 100 x 100 pixels of the image and blits that
    Er, my code is already set up just like that, but that's not the problem. XD The problem is that the image I want to crop is an image that I get from the screen. What I am trying to do is create a transition between the player playing the game, and the brief pause between each game. So to do that, I need to get a picture of the screen and use that for the cropping process. The only thing is, I would like to be able to do this WITHOUT saving it as a PNG first, I would much rather use it as an Image object, if that is possible.

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

    Try creating a smaller blank image that is size of the crop and blitting the screen onto the blank image. No idea if it works though.

  20. #8270
    Developer and Tutor.
    Points: 8.736, Level: 62
    Level completed: 96%, Points required for next Level: 14
    Overall activity: 0%

    Registriert seit
    Jul 2007
    Ort
    Widnes, England
    Beiträge
    1.649
    Points
    8.736
    Level
    62
    My Mood
    Happy
    Downloads
    0
    Uploads
    0

    Standard

    in that case wouldn't cropping_image = screen:save() do the trick and use that ??? not sure but anyway if you dont want to keep the image there is a function in lua to save a file as a temporary file and it is deleted after it has finished being used - you would have to search for that though

    EDIT:

    oh and yaustar i mentioned that before

    Zitat Zitat von FaT3oYCG
    for example create a blank image the size that you would like to crop to this will act like a view finder then blit the original image to that with minus co ordinate for that image and only the part that you want to see should be shown - that isn't a very good way though
    ------ FaT3oYCG -----
    AKA Craig, call me what you want to It's your preference.
    My Website: http://www.modern-gamer.co.uk/

    Currently working on:
    (0) MediaGrab
    (0) PGE Gears Of War - On hold (Very large project).
    (0) PS???? -On Hold A tactical 2d side scrolling game involving AI and online multiplayer features. - Tile engine nearley finished (1 bug to fix).

  21. #8271
    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

    screen:save returns nil and ALWAYS saves to the memory stick.
    -= Double Post =-
    Zitat Zitat von FaT3oYCG
    EDIT:

    oh and yaustar i mentioned that before
    Why wouldn't it be a good way?
    Geändert von yaustar (01-10-2008 um 11:02 AM Uhr) Grund: Automerged Doublepost

  22. #8272
    Developer and Tutor.
    Points: 8.736, Level: 62
    Level completed: 96%, Points required for next Level: 14
    Overall activity: 0%

    Registriert seit
    Jul 2007
    Ort
    Widnes, England
    Beiträge
    1.649
    Points
    8.736
    Level
    62
    My Mood
    Happy
    Downloads
    0
    Uploads
    0

    Standard

    fair enough oh and i wasn't trying to undermine you sorry if it seemed that way

    because it is using minus values what i meant was there may be better ways but i dont like using minus values in my code, most of the time you could use an addition instead just by revising your code but i guess this is an exception
    ------ FaT3oYCG -----
    AKA Craig, call me what you want to It's your preference.
    My Website: http://www.modern-gamer.co.uk/

    Currently working on:
    (0) MediaGrab
    (0) PGE Gears Of War - On hold (Very large project).
    (0) PS???? -On Hold A tactical 2d side scrolling game involving AI and online multiplayer features. - Tile engine nearley finished (1 bug to fix).

  23. #8273
    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 FaT3oYCG
    because it is using minus values what i meant was there may be better ways but i dont like using minus values in my code, most of the time you could use an addition instead just by revising your code but i guess this is an exception
    Why don't you like using minus numbers? It really seems a little odd especially in programming.

  24. #8274
    Developer and Tutor.
    Points: 8.736, Level: 62
    Level completed: 96%, Points required for next Level: 14
    Overall activity: 0%

    Registriert seit
    Jul 2007
    Ort
    Widnes, England
    Beiträge
    1.649
    Points
    8.736
    Level
    62
    My Mood
    Happy
    Downloads
    0
    Uploads
    0

    Standard

    because most of the time using a negative number will make your code more hard to understand and sometimes more complicated than it needs to be

    not that this would happen but say for example you wanted to print some text at 10, 10 then you could use this

    screen:print(480 - 470, 272 - 262, "text", white)

    but that is much harder than just putting

    screen:print(10, 10, "text", white)

    i just used that as an example but you should get what i mean as when it does occur it is usually with complex code

    but as i said that is why i try to avoid using minus numbers where i can
    ------ FaT3oYCG -----
    AKA Craig, call me what you want to It's your preference.
    My Website: http://www.modern-gamer.co.uk/

    Currently working on:
    (0) MediaGrab
    (0) PGE Gears Of War - On hold (Very large project).
    (0) PS???? -On Hold A tactical 2d side scrolling game involving AI and online multiplayer features. - Tile engine nearley finished (1 bug to fix).

  25. #8275
    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

    thats just bad programing. you're unnecessarily doing two subtractions every frame. but i dont usually have a problem with minus values, unless they're used the way you mentioned. other than that, they're ok.
    --------------------------------------------------------------------------------------

  26. #8276
    Developer and Tutor.
    Points: 8.736, Level: 62
    Level completed: 96%, Points required for next Level: 14
    Overall activity: 0%

    Registriert seit
    Jul 2007
    Ort
    Widnes, England
    Beiträge
    1.649
    Points
    8.736
    Level
    62
    My Mood
    Happy
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Grimfate126
    thats just bad programing. you're unnecessarily doing two subtractions every frame. but i dont usually have a problem with minus values, unless they're used the way you mentioned. other than that, they're ok.
    thats my point basically what im trying to say is that i dont like using minuses as they make the code sometimes do unnecesary calculations that is why i try to avoid using them i was only using that as an example to show that i dont use them because it sometimes makes the code unefficient i will use them where needed but as you say if you use a minus where none is needed its bad programming - if you are doing complex coding whith lots of variables and values then you may unnececarily use a subtraction where the value can be obtained by not doing one which is uneficcient coding

    if you still dont understand what i mean then dont try to instead read my sig and you will understand why

    but anyway i think we have had enough discussion on using minuses on the help thread so lets leave it there
    ------ FaT3oYCG -----
    AKA Craig, call me what you want to It's your preference.
    My Website: http://www.modern-gamer.co.uk/

    Currently working on:
    (0) MediaGrab
    (0) PGE Gears Of War - On hold (Very large project).
    (0) PS???? -On Hold A tactical 2d side scrolling game involving AI and online multiplayer features. - Tile engine nearley finished (1 bug to fix).

  27. #8277
    Points: 2.739, Level: 31
    Level completed: 93%, Points required for next Level: 11
    Overall activity: 0%

    Registriert seit
    Jan 2008
    Beiträge
    2
    Points
    2.739
    Level
    31
    Downloads
    0
    Uploads
    0

    Exclamation

    Hi all,

    Am new to Lua and relatively new to programming too i guess, anyway can anoyne help me with this problem please. I am getting the "loop in gettable" error when i try to mute my music. Code below:

    Code:
    -- Activate USB Mode
    System.usbDiskModeActivate()
    
    -- Define Color White
    white=Color.new(255,255,255)
    
    -- Load Loading Image
    loadingImage = Image.load("images/loading.jpg")
    
    
    -- Print Loading Image as Background
    screen:blit(0, 0, loadingImage, false)
    
    screen.waitVblankStart()
    screen:print(200,130,"Loading - 0%",white)
    screen.flip()
    
    
    -- Begin Loading All Other Images
    backgroundImage = Image.load("images/background.jpg")
    screen:clear()
    screen:print(200,130,"Loading - 20%",white)
    screen.flip()
    gameimageImage = Image.load("images/game.jpg")
    screen:clear()
    screen:print(200,130,"Loading - 40%",white)
    screen.flip()
    dartImage = Image.load("images/dart.jpg")
    screen:clear()
    screen:print(200,130,"Loading - 60%",white)
    screen.flip()
    gameoverImage = Image.load("images/gameover.jpg")
    screen:clear()
    screen:print(200,130,"Loading - 80%",white)
    screen.flip()
    themeSound = Sound.load("sounds/theme.wav", true)
    splashImage = Image.load("images/splash.jpg")
    screen:clear()
    screen:print(200,130,"Loading - 100%",white)
    screen.flip()
    
    --Pause At 100%
    screen.waitVblankStart(60)
    
    
    --Clear The Screen Of Loading Text
    screen:clear()
    
    --Load The Splash Screen
    screen:blit(0, 0, splashImage, false)
    screen.flip()
    
    --Pause For One Second
    screen.waitVblankStart(180)
    
    --Load The Background Image
    screen:blit(0, 0, backgroundImage, false)
    screen.flip()
    
    --Play The Theme Music
    Music.volume(128)
    themeSound:play()
    
    --Update The Screen
    screen.waitVblankStart()
    
    
    while true do
    pad = Controls.read()
    	if pad:start() then
    	   break
    	end
    	if pad:select() then 
          screen:save("screenshot.png") 
      end
    		if pad:l() then
    		  if themeSound:playing() then
    	      themeSound:stop()
    	    else
    	       themeSound:play()
    	    end
    		end
    end
    The screenshot and quit functions mapped to Select and Start respectively work fine, however when i try to stop the music or set Music.volume(0) i get "error - loop in gettable".:Argh:

    If anyone can offer some pointers please i would be most grateful.

    Many thanks.

  28. #8278
    QJ Gamer Silver
    Points: 10.921, Level: 69
    Level completed: 18%, Points required for next Level: 329
    Overall activity: 0%

    Registriert seit
    May 2006
    Ort
    Behind you.
    Beiträge
    1.814
    Points
    10.921
    Level
    69
    Downloads
    0
    Uploads
    0

    Standard

    Ok, i haven't seen lua in a while (concept is same though), but here are some tips:

    1) Try to indent properly. It helps when you have your code organized.
    2) It seems that you are loading a lot of images, but not blitting them.
    3) Instead of having a lot of "Loading..." printing, you could make a only one "Loading" printing when "if" blah is true, then change the "%" of loading. For example, if some image finishes loading, update the loading "%".
    Geändert von SuperBatXS (01-14-2008 um 07:54 PM Uhr)
    Calypso - Enjoy the excellent 2D space shooter:
    http://dl.qj.net/Calypso-v1-PSP-Home...6542/catid/195

    "Quoting yourself in your signature means you love to masterbate while looking at the mirror." -me (oh, wait...)

  29. #8279
    Ænima
    Points: 6.447, Level: 52
    Level completed: 49%, Points required for next Level: 103
    Overall activity: 0%

    Registriert seit
    Sep 2007
    Beiträge
    587
    Points
    6.447
    Level
    52
    Downloads
    0
    Uploads
    0

    Standard

    Also, when blitting an image, you don't need the fourth argument. You only need it if it's true.
    [IMG]http://upload.wikimedia.org/wikipedia/commons/thumb/c/c5/Zoso.svg/744px-Zoso.svg.png[/IMG]

    Looking for some good C programming tutorials for the PSP? Look no further! [URL="http://psp-coding.com/"]PSP-Coding.com[/URL] is your source for all your PSP coding needs.

  30. #8280
    Developer and Tutor.
    Points: 8.736, Level: 62
    Level completed: 96%, Points required for next Level: 14
    Overall activity: 0%

    Registriert seit
    Jul 2007
    Ort
    Widnes, England
    Beiträge
    1.649
    Points
    8.736
    Level
    62
    My Mood
    Happy
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Andysan
    Hi all,

    Am new to Lua and relatively new to programming too i guess, anyway can anoyne help me with this problem please. I am getting the "loop in gettable" error when i try to mute my music. Code below:

    Code:
    -- Activate USB Mode
    System.usbDiskModeActivate()
    
    -- Define Color White
    white=Color.new(255,255,255)
    
    -- Load Loading Image
    loadingImage = Image.load("images/loading.jpg")
    
    
    -- Print Loading Image as Background
    screen:blit(0, 0, loadingImage, false)
    
    screen.waitVblankStart()
    screen:print(200,130,"Loading - 0%",white)
    screen.flip()
    
    
    -- Begin Loading All Other Images
    backgroundImage = Image.load("images/background.jpg")
    screen:clear()
    screen:print(200,130,"Loading - 20%",white)
    screen.flip()
    gameimageImage = Image.load("images/game.jpg")
    screen:clear()
    screen:print(200,130,"Loading - 40%",white)
    screen.flip()
    dartImage = Image.load("images/dart.jpg")
    screen:clear()
    screen:print(200,130,"Loading - 60%",white)
    screen.flip()
    gameoverImage = Image.load("images/gameover.jpg")
    screen:clear()
    screen:print(200,130,"Loading - 80%",white)
    screen.flip()
    themeSound = Sound.load("sounds/theme.wav", true)
    splashImage = Image.load("images/splash.jpg")
    screen:clear()
    screen:print(200,130,"Loading - 100%",white)
    screen.flip()
    
    --Pause At 100%
    screen.waitVblankStart(60)
    
    
    --Clear The Screen Of Loading Text
    screen:clear()
    
    --Load The Splash Screen
    screen:blit(0, 0, splashImage, false)
    screen.flip()
    
    --Pause For One Second
    screen.waitVblankStart(180)
    
    --Load The Background Image
    screen:blit(0, 0, backgroundImage, false)
    screen.flip()
    
    --Play The Theme Music
    Music.volume(128)
    themeSound:play()
    
    --Update The Screen
    screen.waitVblankStart()
    
    
    while true do
    pad = Controls.read()
        if pad:start() then
           break
        end
        if pad:select() then 
          screen:save("screenshot.png") 
      end
            if pad:l() then
              if themeSound:playing() then
              themeSound:stop()
            else
               themeSound:play()
            end
            end
    end
    The screenshot and quit functions mapped to Select and Start respectively work fine, however when i try to stop the music or set Music.volume(0) i get "error - loop in gettable".:Argh:

    If anyone can offer some pointers please i would be most grateful.

    Many thanks.
    other than the fact your code is set out wrong well its in the wrong order - logical order

    for a start the Music.volume(128) is before while true do

    so threfore if you change it its not true so it will crash

    looks like you have some logic and indenting errors

    - try fix your logic and indenting and see if it works

    EDIT:

    here i fixed most of it for you and laid it out better with proper indentations

    Code:
    -- Activate USB Mode - should only be done while testing or creating a game with a game refresh function to start ti again if you save a file currently in use
    System.usbDiskModeActivate()
    
    -- Define Color White
    white = Color.new(255,255,255)
    
    -- Load Loading Image
    loadingImage = Image.load("images/loading.jpg")
    
    -- Load All Other Images
    backgroundImage = Image.load("images/background.jpg")
    gameimageImage = Image.load("images/game.jpg")
    dartImage = Image.load("images/dart.jpg")
    gameoverImage = Image.load("images/gameover.jpg")
    splashImage = Image.load("images/splash.jpg")
    themeSound = Sound.load("sounds/theme.wav", true)
    
    
    -- Print Loading Image as Background
    screen:blit(0, 0, loadingImage, false)
    screen.waitVblankStart()
    
    -- display loading text
    screen:clear()
    screen:print(200,130,"Loading - 0%",white)
    screen.flip()
    screen:clear()
    screen:print(200,130,"Loading - 20%",white)
    screen.flip()
    screen:clear()
    screen:print(200,130,"Loading - 40%",white)
    screen.flip()
    screen:clear()
    screen:print(200,130,"Loading - 60%",white)
    screen.flip()
    screen:clear()
    screen:print(200,130,"Loading - 80%",white)
    screen.flip()
    screen:clear()
    screen:print(200,130,"Loading - 100%",white)
    screen.flip()
    
    --Pause At 100% - for 1 second
    screen.waitVblankStart(60)
    
    --Clear The Screen Of all previous data
    screen:clear()
    
    --"display" The Splash Screen
    screen:blit(0, 0, splashImage, false)
    screen.flip()
    
    --Pause For One Second - that is three seconds 60 miliseconds in one second
    screen.waitVblankStart(180)
    
    -- "display" The Background Image
    screen:blit(0, 0, backgroundImage, false)
    screen.flip()
    
    --Update The Screen - keep whatever is on the screen untill told not to
    screen.waitVblankStart()
    
    while true do
    
    pad = Controls.read()
    
    --Play The Theme Music
    Music.volume(128)
    themeSound:play()
    
    if pad:start() then
    	break
    end
    
    if pad:select() then 
    	screen:save("screenshot.png") 
    end
    
    if pad:l() then
    	if themeSound:playing() then
    		themeSound:stop()
    	else
    		themeSound:play()
    	end
    end
    
    end
    here is a simple lua file template aswell

    Code:
    white = color.new(255, 255, 255) -- create white as a colour
    
    oldpad = Controls.read() -- set oldpad as a secondary controller setup
    
    while true do -- while the above is true
    
    pad = Controls.read() -- set pad as a primary controller setup
    
    screen:clear() -- clear anything previously on the screen
    
    -- insert your main code here
    
    -- e.g.
    if pad:cross() then
    	-- if cross is being held
    	screen:print(10, 10, "i pressed cross", white)
    end
    
    if pad:cross() and oldpad:cross() ~= pad:cross() then
    	-- do something if cross is pressed and not held
    end
    
    -- insert your main code here
    
    if Controls.read():start() then -- if you press start exit
    	break -- break the current state
    end -- end the if
    
    oldpad = pad -- oldpad is the same as pad
    
    screen.flip() -- flip the screen at the end of every while loop - if set right the while loop should be continuous
    screen.waitVblankStart() -- keep any of that data on the screen untill specified otherwise
    
    end
    thanks
    Geändert von FaT3oYCG (01-15-2008 um 09:58 AM Uhr)
    ------ FaT3oYCG -----
    AKA Craig, call me what you want to It's your preference.
    My Website: http://www.modern-gamer.co.uk/

    Currently working on:
    (0) MediaGrab
    (0) PGE Gears Of War - On hold (Very large project).
    (0) PS???? -On Hold A tactical 2d side scrolling game involving AI and online multiplayer features. - Tile engine nearley finished (1 bug to fix).


 

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

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