LPP Help

Discussion in '3DS - Homebrew Development and Emulators' started by Megalegacy98, Oct 7, 2015.

  1. Megalegacy98
    OP

    Megalegacy98 ( ͡° ͜ʖ ͡°)™

    Member
    505
    259
    Aug 11, 2015
    United States
    Just around the corner™
    Code:
    Sound.init()
    topscreenimg = Screen.loadImage("/theme/top.png")
    bottomscreenimg = Screen.loadImage("/theme/bottom.png")
    bgmusic = Sound.openWav("/theme/bgmusic.wav",false)
    sysdetailmenu = 0
    homebrew = 0
    gamecard = 0
    themes = 0
    maxy = 6
    y = 1
    selected = Color.new(255,255,0)
    unselect = Color.new(0,255,255)
    oldpad = Controls.read()
    
    while true do
    pad = Controls.read()
    
    if (Controls.check(pad,KEY_DUP)) and not (Controls.check(oldpad,KEY_DUP)) then
       y = y - 1
    end
    
    if (Controls.check(pad,KEY_DDOWN)) and not (Controls.check(oldpad,KEY_DDOWN)) then
       y = y + 1
    end
    
    if maxy < y then
       y = 1
    end
    
    if y <= 0 then
       y = maxy
    end
    
    Screen.waitVblankStart()
    Screen.refresh()
    Screen.clear(TOP_SCREEN)
    lol = {unselect,unselect,unselect,unselect,unselect,unselect}
    lol[y] = selected
    Screen.debugPrint(45,0, "Homebrew Menu v 0.1a",unselect,TOP_SCREEN)
    Screen.debugPrint(45,30,"Load Game Cartridge",lol[1],TOP_SCREEN)
    Screen.debugPrint(45,45,"Load Homebrew",lol[2],TOP_SCREEN)
    Screen.debugPrint(45,60,"Reboot System",lol[3],TOP_SCREEN)
    Screen.debugPrint(45,75,"See system details",lol[4],TOP_SCREEN)
    Screen.debugPrint(45,90,"Toggle themes",lol[5],TOP_SCREEN)
    Screen.debugPrint(45,105,"Exit",lol[6],TOP_SCREEN)
    Screen.flip()
    
    
    if homebrew == 1 then
       dofile(System.currentDirectory().."/homebrew.lua")
    end
    
    if sysdetailmenu == 1 then
       dofile(System.currentDirectory().."/sysdetails.lua")
    end
    
    if gamecard == 1 then
       dofile(System.currentDirectory().."/gamecard.lua")
    end
    
    if themes == 1 then
       if Sound.isPlaying(bgmusic) then
         Sound.close(bgmusic)
       end
       Screen.clear(TOP_SCREEN)
       Screen.clear(BOTTOM_SCREEN)
    end
    
    if themes == 2 then
       Screen.drawImage(0,0,topscreenimg,TOP_SCREEN)
       Screen.drawImage(0,0,bottomscreenimg,BOTTOM_SCREEN)
       Sound.play(bgmusic,LOOP,0x09)
    end
    
    if (Controls.check(pad,KEY_A)) and not (Controls.check(oldpad,KEY_A)) and y == 1 then
       gamecard = 1
    end
    
    if (Controls.check(pad,KEY_A)) and not (Controls.check(oldpad,KEY_A)) and y == 2 then
       homebrew = 1
    end
    
    if (Controls.check(pad,KEY_A)) and not (Controls.check(oldpad,KEY_A)) and y == 3 then
       System.reboot()
    end
    
    if (Controls.check(pad,KEY_A)) and not (Controls.check(oldpad,KEY_A)) and y == 4 then
       sysdetailmenu = 1
    end
    
    if (Controls.check(pad,KEY_A)) and not (Controls.check(oldpad,KEY_A)) and y == 5 then
       themes = 2
       else
       themes = 1
    end
    
    if (Controls.check(pad,KEY_A)) and not (Controls.check(oldpad,KEY_A)) and y == 6 then
       Sound.term()
       System.exit()
    end
    
    Screen.refresh()
    Screen.waitVblankStart()
    oldpad = pad
    end
     
    Last edited by Megalegacy98, Oct 8, 2015
  2. 730

    730 Professional Shitposter

    Member
    465
    377
    Apr 2, 2015
    Argentina
    Well to begin with, indent your code or else nobody will understand anything.
    As for the code itself, you're doing some weird shit with the screen functions.
    The order should be like this:
    Code:
    Screen.waitVblankStart()
    Screen.refresh()
    Screen.clear(TOP_SCREEN)
    Screen.clear(BOTTOM_SCREEN)
    --Print/draw stuff
    Screen.flip()
     
    Last edited by 730, Oct 7, 2015
  3. Megalegacy98
    OP

    Megalegacy98 ( ͡° ͜ʖ ͡°)™

    Member
    505
    259
    Aug 11, 2015
    United States
    Just around the corner™
    Haha, I guess I should have. Sorry about that.

    I guess I'm blind because I don't see where I went wrong on the screen functions. That's what I did with my menu (the homebrew menu part). Are you talking about the y == * parts?
     
  4. 730

    730 Professional Shitposter

    Member
    465
    377
    Apr 2, 2015
    Argentina
    No, I mean there are lots of clean()s and whatnots. There should be just 2 at the beginning of the loop (one for top screen, the other for bottom screen) along with the waitforvblank and refresh or whatever, then just the flip() at the end of the loop.
    Oh also, variable naming conventions 101: capitalize the first letter on words on variables, except for the first word, i.e. when you have "topscreenimg" make it "topScreenImg". It's another thing that helps readablity, just like indentation.
     
    Last edited by 730, Oct 7, 2015
  5. Megalegacy98
    OP

    Megalegacy98 ( ͡° ͜ʖ ͡°)™

    Member
    505
    259
    Aug 11, 2015
    United States
    Just around the corner™
    I see. I will fix my code up a bit and see if that works. Thanks!

    — Posts automatically merged - Please don't double post! —

    Doesn't work. I got rid of the other stuff and put the Screen.flip() at the end of the loop and the other elements at the start.
     
    730 likes this.
  6. Rinnegatamante

    Rinnegatamante GBAtemp Psycho!

    Member
    3,127
    3,271
    Nov 24, 2014
    Italy
    Bologna
     
  7. Elveman

    Elveman B9S Shitpost Race Smogonite

    Member
    GBAtemp Patron
    Elveman is a Patron of GBAtemp and is helping us stay independent!

    Our Patreon
    444
    261
    Feb 1, 2015
    Russia
    Moscow city
     
    730 likes this.
  8. Jwiz33

    Jwiz33

    Banned
    2,654
    1,523
    Jun 5, 2014
    United States
    in the illuminati headquar—I have said too much!
    You didn't read the rest of the opening post.
     
    730 likes this.
  9. Megalegacy98
    OP

    Megalegacy98 ( ͡° ͜ʖ ͡°)™

    Member
    505
    259
    Aug 11, 2015
    United States
    Just around the corner™
    So is anyone gonna help me on this? I got it to work before, and I added elements before and was able to fix it but I forgot how to...
     
  10. BurningDesire
    This message by BurningDesire has been removed from public view by Sicklyboy, Oct 8, 2015, Reason: Drama.
    Oct 7, 2015
  11. Rinnegatamante

    Rinnegatamante GBAtemp Psycho!

    Member
    3,127
    3,271
    Nov 24, 2014
    Italy
    Bologna
    Yeah you right, i was in a hurry cause i was cooking for the launch so i asnwered first question i seen without overchecking the entirety of the post, my bad :(

    @Megalegacy98 can you ident your code? It's a bit hard to give support for hard-reading codes.
     
    Jwiz33 and 730 like this.
  12. Megalegacy98
    OP

    Megalegacy98 ( ͡° ͜ʖ ͡°)™

    Member
    505
    259
    Aug 11, 2015
    United States
    Just around the corner™
    fixed (i think)
     
  13. Rinnegatamante

    Rinnegatamante GBAtemp Psycho!

    Member
    3,127
    3,271
    Nov 24, 2014
    Italy
    Bologna
    Not at all but it's much more readable. What's the problem you encountered? (P.s., instead of 0-1 values like C, LUA accepts also boolean values but in reality they are equal. I prefer boolean ones to make my codes cleaner)
     
  14. Megalegacy98
    OP

    Megalegacy98 ( ͡° ͜ʖ ͡°)™

    Member
    505
    259
    Aug 11, 2015
    United States
    Just around the corner™
    I didn't say my problem was fixed lol. The problem is nothing shows up in the screen.
     
  15. Megalegacy98
    OP

    Megalegacy98 ( ͡° ͜ʖ ͡°)™

    Member
    505
    259
    Aug 11, 2015
    United States
    Just around the corner™
    Stupid me, I forgot that I had no image, no wonder nothing came up...
    got rid of the theme code, worked fine. It works now, thanks for the help guys.