Results 1 to 6 of 6

Thread: Help with a basic Lua code - new to lua scripting

  
  1. #1
    originalfragster is offline -Hacks Newbie
    Join Date
    Nov 2006
    Location
    New Zealand
    Posts
    48
    Rep Power
    13

    Default

    I'm trying to learn Lua, I'm at a simple level. however when i try to run this code, I receive the error:

    Code:
    error: script.lua:16: (eof) expected near 'end'
    btw - this is running on windows Lua Player

    Heres the code:

    Code:
    --test App
    --Author: Originalfragster
    
    --*Variables*
    display = "lolz u suxorz"
    red = Color.new(255,0,0)
    pad = Controls.read()
    
    --*Main Loop*
    screen:clear()
    if pad:up() then screen:print(100,100,display,red)
    end
    
    screen.waitVblankStart()
    screen.flip()
    end
    I know it has something to do with the "end" statement at the end of the script, but I do not know how to remedy it.

    Any help is greatly appreciated.


  2. #2
    LordCthulu is offline Senior Member -Hacks Enthusiast
    Join Date
    Mar 2005
    Posts
    578
    Rep Power
    15

    Default

    Why is that last end there? I don't see anything to end, other than the if statement, but you closed that already.
    Oldest psp-hacks member ever.

  3. #3
    romero126 is offline -Hacks Neophyte
    Join Date
    Jan 2006
    Posts
    81
    Rep Power
    14

    Default

    That wont work because you dont have a loop


    -- Variables
    while true do

    -- Your code


    -- The bottom end in the script.


    That might help

  4. #4
    originalfragster is offline -Hacks Newbie
    Join Date
    Nov 2006
    Location
    New Zealand
    Posts
    48
    Rep Power
    13

    Default

    lol - its so simple now I see it like that :o

    thanks romero and lordcthulu

  5. #5
    Blade_punk's Avatar
    Blade_punk is offline Programmer -Hacks Guru
    Join Date
    Nov 2006
    Location
    Candy Mountain
    Posts
    2,314
    Rep Power
    15

    Default

    good to see someone getting into LUA coding. if you have any more problems i would be glad to help

    -Rock Station-
    PSN: Xsjado7


  6. #6
    lua scripter is offline -Hacks Newbie
    Join Date
    Aug 2008
    Posts
    14
    Rep Power
    0

    Default

    your code is messed up try putting this code in i edited it for you
    you dident have a loop in your program display= what ever you had is not needed it will not work just use screen:print its much easyer

    Code:
    --test App
    --Author: Originalfragster
    red = Color.new(255,0,0)
    
    
    
    
    while true do
    pad = Controls.read()
    screen:clear()
    
    if pad:cross() then
    screen:print (50,110 , "lolz u suxorz" ,red)
    screen.waitVblankStart()
    end
    
    
    screen.waitVblankStart()
    screen.flip()
    end

Posting Permissions

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