Results 1 to 10 of 10

Thread: code help

                  
   
  1. #1
    DCEmu Legend gunntims0103's Avatar
    Join Date
    May 2006
    Location
    Brentwood, NY
    Age
    34
    Posts
    2,976
    Rep Power
    112

    Default code help

    i rather not put out the code that iv done out like this but i need help as i keep getting an error with my menu.lua for sora adventure. It keeps saying attempt to global 'LoadA' but there seems to be nothing wrong. can anyone help heres the code below

    status = "menu"

    Black = Color.new(0, 0, 0)
    Red = Color.new(255, 0, 0)

    --load images--
    Background = Image.load("backgrounds/menu.png")

    --load files--
    LoadA = loadfile("scene.lua")
    LoadB = loadfile("instructions.lua")
    LoadC = loadfile("credits.lua")

    while true do

    current = 1
    oldpad = Controls.read()

    while true do

    pad = Controls.read()
    screen:clear()

    ----prints to the screen-------
    screen:blit(0, 0, Background)
    screen:print(185, 175, "Start Game", Black)
    screen:print(185, 195, "Instructions", Black)
    screen:print(185, 215, "Credits", Black)
    screen:print(314, 263, "Press Home to exit", Black)
    screen:print(320, 4, "Gunntims0103-Coder", Black)

    -----this code is so that when you highlight an option in a menu it turns red-----
    if current == 1 then
    screen:print(185, 175, "Start Game", Red)
    end

    if current == 2 then
    screen:print(185, 195, "Instructions", Red)
    end

    if current == 3 then
    screen:print(185, 215, "Credits", Red)
    end

    -----this makes it so that you can scroll through your menu----
    if pad:up() and oldpad:up() ~= pad:up() then
    current = current-1
    end

    if pad:down() and oldpad:down() ~= pad:down() then
    current = current+1
    end

    if current == 4 then
    current = 1
    end

    if current == 0 then
    current = 3
    end

    -----this is to select your menu options------
    if pad:cross() and current == 1 then
    LoadA()
    end

    if pad:cross() and current == 2 then
    LoadB()
    end

    if pad:cross() and current == 3 then
    LoadC()
    end

    screen.waitVblankStart()
    screen:flip()
    oldpad = pad

    end

    end

  2. #2
    GP2X Coder/Moderator
    Join Date
    Jan 2006
    Posts
    1,678
    Rep Power
    87

    Default

    scene.lua is most likely to have errors so it can't loadfile it. Therefore when you call/use loadA, it is nil and crashes.

  3. #3
    DCEmu Legend gunntims0103's Avatar
    Join Date
    May 2006
    Location
    Brentwood, NY
    Age
    34
    Posts
    2,976
    Rep Power
    112

    Default scene.lua

    this is the code im using for the scene in the game

    Black = Color.new(0, 0, 0)

    --load images, this is for the cutscene--
    Background = Image.load("backgrounds/scene1.png")
    Sora = Image.load("sprites/sora.png")
    Enemie = Image.load("sprites/enemie.png")
    Talk = Image.load("sprites/talk.png")

    --load files--
    loadA = loadfile("menu.lua")

    pad = Controls.read()

    --prints to screen--
    Screen:blit(0, 0,Background)
    Screen:blit(31, 230,Sora)
    Screen:blit(330, 230,Enemie)
    Screen:blit(35, 30,Talk)

    if pad:cross() then
    loadA()
    end

    Screen:waitVblankStart()
    Screen:flip()
    end
    i keep getting this error

    error: scene.lua:26: <eof> expected near 'end'

    what do i do. i also removed the "ingame.lua" loading from my script as there is no such file at the moment so i just made it go back to the menu after you press X.

  4. #4
    DCEmu Coder drEDN4wt's Avatar
    Join Date
    Aug 2005
    Location
    U.K.
    Posts
    172
    Rep Power
    0

    Default

    too many ends....delete 1 of them

  5. #5
    DCEmu Legend gunntims0103's Avatar
    Join Date
    May 2006
    Location
    Brentwood, NY
    Age
    34
    Posts
    2,976
    Rep Power
    112

    Default

    Quote Originally Posted by drEDN4wt View Post
    too many ends....delete 1 of them
    thanx worked like a charm

    now im having another bug actaully 2 of them

    -menu.lua doesnt load instructins or credits when i try to access them the game goes to the scene.lua

    -the scene.lua keeps the options of the menu.lua on the screen why this is happening i have no idea

    drEN4wt can i email you what i have cause the game is getting bizzare on me and i can fix it

  6. #6
    DCEmu Coder drEDN4wt's Avatar
    Join Date
    Aug 2005
    Location
    U.K.
    Posts
    172
    Rep Power
    0

    Default

    sure , but i cant look at it for a few hours, my psp has been conviscated by my 4 yr old son

    will pm my email

  7. #7
    DCEmu Legend gunntims0103's Avatar
    Join Date
    May 2006
    Location
    Brentwood, NY
    Age
    34
    Posts
    2,976
    Rep Power
    112

    Default

    drEDN4wt you dont use luaplayerwindows for the computer

    o yea thanx for helping me il send you a copy when i get the pm

  8. #8
    DCEmu Old Pro
    Join Date
    May 2006
    Posts
    1,073
    Rep Power
    75

    Default

    Quote Originally Posted by gunntims0103 View Post
    -the scene.lua keeps the options of the menu.lua on the screen why this is happening i have no idea
    its probably cause you didnt clear the screen
    use screen:clear() just before you print to the screen

  9. #9
    DCEmu Legend gunntims0103's Avatar
    Join Date
    May 2006
    Location
    Brentwood, NY
    Age
    34
    Posts
    2,976
    Rep Power
    112

    Default

    Quote Originally Posted by jak66 View Post
    its probably cause you didnt clear the screen
    use screen:clear() just before you print to the screen
    i did that look at this code

    Black = Color.new(0, 0, 0)

    --load images, this is for the cutscene--
    Background = Image.load("backgrounds/scene1.png")
    Sora = Image.load("sprites/sora.png")
    Enemie = Image.load("sprites/enemie.png")
    Talk = Image.load("sprites/talk.png")

    --load files--
    LoadA = loadfile("menu.lua")

    pad = Controls.read()
    screen:clear()

    --prints to screen--
    screen:blit(0, 0,Background)
    screen:blit(31, 230,Sora)
    screen:blit(330, 230,Enemie)
    screen:blit(35, 30,Talk)

    if pad:cross() then
    LoadA()

    Screen:waitVblankStart()
    Screen:flip()
    end
    screen clear is in the bold but i still have the problem i pm'ed yaustar as well for help to this problem and sent him a rapidshare link to what i have so far hope i can get this bug fixed

  10. #10
    DCEmu Legend gunntims0103's Avatar
    Join Date
    May 2006
    Location
    Brentwood, NY
    Age
    34
    Posts
    2,976
    Rep Power
    112

    Default

    Also is it possible to have a cut scene in lua set up like this

    have 2 sprites on screen facing each other enemies they will be blit to the screen in the code

    then have a talk sprite, the every time you press X the old talk sprite gets cleared and a new one appears. To give the effect of a cut scene and to give the effect as if players are talking. also would i have to use dofiles to do this like

    if pad:cross then
    loadA()
    end

    loadA would be the code that blits the new talk sprite to the screen and gets rid of the new one every time you press X

    is this even possible im sure it is

    im going to try it after the bugs are fixed

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •