Results 1 to 5 of 5

Thread: Lua* help Edit ****

                  
   
  1. #1
    PSP User jason215's Avatar
    Join Date
    Mar 2006
    Location
    RAMEN !!
    Age
    34
    Posts
    89
    Rep Power
    0

    Unhappy Lua* help Edit ****

    hi,

    if got some problems whith my lua script
    (dont get angry because im a bit noob with lua)

    but if somebody can look at it thnx i appriciatet it
    *srry 4 my bad english


    anyways i'm always getting this error

    error: index.lua:81: bad argument #2 to 'blit' (image expected, got table)

    here's the code

    -- images
    background=Image.load("back.jpg")
    player1 = Image.load("Naruto.png")
    shadow = Image.load("shadow.png")

    -- player 1

    player={}
    player.gravity = 200
    player.x = 50
    player.y = 250
    player.jumpspeed = 10
    player.jumpstate = "ground"

    -- player 2

    shadow={}
    shadow.x = 30
    shadow.y = 230


    -- controls

    function controls()
    pad=Controls.read()
    end

    while true do
    controls()
    screen:blit(0,0,background,false)


    controls()
    if pad:right()then
    player.x = player.x + 4
    shadow.x = shadow.x + 4
    end

    if pad:left()then
    player.x = player.x - 4
    shadow.x = shadow.x - 4
    end


    -- jumping script

    if pad:cross() and player.jumpstate == "ground" then player.jumpstate = "jumping"

    end

    if player.jumpstate == "jumping"
    then player.jumpspeed = player.jumpspeed - 0.5
    player.gravity = player.gravity - player.jumpspeed

    end

    if player.gravity < 0 then
    player.jumpstate = "falling"

    end

    if player.gravity < 200 and player.jumpstate == "falling" then player.gravity = player.gravity + (player.jumpspeed + 3)

    end

    if player.gravity == 200 then
    player.jumpspeed = 10
    player.jumpstate = "ground"
    end

    if player.gravity > 200 then player.gravity = 200

    end

    player.y = player.gravity

    --end jumpscript

    -- Shadow Replication Script

    screen:blit(shadow.x,shadow.y,shadow)


    -- End Shadow script

    screen:blit(player.x,player.y,player1)

    screen.waitVblankStart()
    screen.flip()
    end

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

    Default

    Here is your problem:
    You use the shadow variable as an image here:
    shadow = Image.load("shadow.png")

    but you change it to a table here:
    shadow={}
    shadow.x = 30
    shadow.y = 230

    So in the blit command you are passing it a table which is bringing up the error.

  3. #3
    PSP User jason215's Avatar
    Join Date
    Mar 2006
    Location
    RAMEN !!
    Age
    34
    Posts
    89
    Rep Power
    0

    Default

    thnx man

  4. #4
    PSP User jason215's Avatar
    Join Date
    Mar 2006
    Location
    RAMEN !!
    Age
    34
    Posts
    89
    Rep Power
    0

    Default

    srry but why isnt this working if i press up nothing appears ... if someone can help again thnx



    -- Shadow Replication Script
    if pad:up() and player.jumpstate == "ground" then
    screen:blit(shadow.x,shadow.y,shadow1)

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

    Default

    Looks fine. Nothing wrong with those 2 lines of code.

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
  •