Results 1 to 9 of 9

Thread: whats wrong with my code??

                  
   
  1. #1

    Question whats wrong with my code??

    im learning lua now and i get an eroow saying: loop in gettable
    my code look like this

    white=Color.new(255,255,255)
    upPressed='You are pressing the "UP" button'
    downPressed='You are pressing the "DOWN" button'
    leftPressed='You are pressing the "LEFT" button'
    rightPressed='You are pressing the "Right" button'
    crossPressed='You are pressing the "CROSS" button'
    trianglePressed='You are pressing the "TRIANGLE" button'
    squarePressed='You are pressing the "SQUARE" button'
    circlePressed='You are pressing the "CIRCLE" button'
    LPressed='You are pressing the "L" button'
    RPressed='You are pressing the "R" button'
    while true do
    screen:clear()
    pad=Controls.read()
    if pad:up()then
    screen: print(100,100,upPressed,white)
    end
    if pad:left()then
    screen: print(100,100,leftPressed,white)
    end
    if pad:right()then
    screen: print(100,100,rightPressed,white)
    end
    if pad:up()then
    screen: print(100,100,upPressed,white)
    end
    if pad:down()then
    screen: print(100,100,downPressed,white)
    end
    if pad:L()then
    screen: print(100,100,LPressed,white)
    end
    if pad:R()then
    screen: print(100,100,RPressed,white)
    end
    if pad:cross()then
    screen: print(100,100,crossPressed,white)
    end
    if pad:square()then
    screen: print(100,100,squarePressed,white)
    end
    if pad:triangle()then
    screen: print(100,100,trianglePressed,white)
    end
    if pad:circle()then
    screen: print(100,100,circlePressed,white)
    end
    screen.waitVblankStart()
    screen.flip()
    end

    edit: i know that between : and print no pace come but if a hadnt done it it would look like this screenrint

  2. #2
    DCEmu Coder dalejrrocks's Avatar
    Join Date
    Feb 2006
    Location
    Alabama
    Age
    33
    Posts
    240
    Rep Power
    67

    Default

    put " instead of ' and make it look like this : screenrint . is that all the code? what does the error say exactly?

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

    Default

    if pad:L()then
    screen: print(100,100,LPressed,white)
    end
    if pad:R()then
    screen: print(100,100,RPressed,white)
    end
    should be
    if pad:l()then
    screen: print(100,100,LPressed,white)
    end
    if pad:r()then
    screen: print(100,100,RPressed,white)
    end
    Notice the lower case L and R.

  4. #4
    DCEmu Coder MasterChafed's Avatar
    Join Date
    Jul 2005
    Location
    Colorado
    Age
    33
    Posts
    832
    Rep Power
    90

    Default

    you have to remember that lua is always case sensitive. so if you make a variable somthing like Image and later put image, it will think of it as a different variable. or sumtin like that.
    http://one.revver.com/watch/170516
    http://one.revver.com/watch/167200

    Please click the links above to watch my stick figure animations,
    and please, if you have the time, click the ads at the end to earn me some money.

  5. #5
    DCEmu Coder dalejrrocks's Avatar
    Join Date
    Feb 2006
    Location
    Alabama
    Age
    33
    Posts
    240
    Rep Power
    67

    Default

    yeah, that's right. that too.

  6. #6

    Default

    thx yaustar now it works

  7. #7

    Default

    i have another question
    i want to print a image to the screen if no button is pressed not always just if no button is pressed

  8. #8

    Default

    kind like this:
    if pad:nil() then
    screen:blit(............)
    nil is if no button is pressed

  9. #9

    Default

    yaustar maybe

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
  •