Page 4 of 4 FirstFirst 1234
Results 31 to 37 of 37

Thread: Lua Coding

                  
   
  1. #31

    Default

    this is my whole script
    ------------------------------------------------

    -- My First Lua Program
    -- Author: YoungProdigy
    Room_width = 480
    Room_height = 272
    player1x = 15
    player1y = 136
    weapon=Image.load("weapon.PNG")
    background=weapon
    car1=Image.load("car1.PNG")
    player1=car1

    if pad:up() then
    character=car1
    player.y = player.y - 2
    end

    if pad:down() then
    character = car1
    player.y = player.y + 2
    end

    if pad:left() then
    character = car1
    player.x = player.x - 2
    end

    if pad:right() then
    character = car1
    player.x = player.x + 2
    end

  2. #32
    DCEmu Coder splodger15's Avatar
    Join Date
    Jun 2006
    Location
    London
    Age
    34
    Posts
    4,123
    Rep Power
    95

    Default

    -- My First Lua Program
    -- Author: YoungProdigy

    Room_width = 480
    Room_height = 272
    player1x = 15
    player1y = 136
    weapon=Image.load("weapon.PNG")
    background=weapon
    car1=Image.load("car1.PNG")
    player1=car1

    pad = Controls.read()

    if pad:up() then
    character=car1
    player.y = player.y - 2
    end

    if pad:down() then
    character = car1
    player.y = player.y + 2
    end

    if pad:left() then
    character = car1
    player.x = player.x - 2
    end

    if pad:right() then
    character = car1
    player.x = player.x + 2
    end

    ------------------------------------------------------------------

    Give it a try now

    as you may of noticed i added
    pad = Controls.read()

    PSN ID: splodger15

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

    Default

    I hope both of you realise that code won't display anything on the screen.

  4. #34

    Default

    ok i added exactly what you have there and run it but i still have another error.

    error: script.lua:13: calling 'blit' on bad self (number expected, got nil)

  5. #35
    DCEmu Coder splodger15's Avatar
    Join Date
    Jun 2006
    Location
    London
    Age
    34
    Posts
    4,123
    Rep Power
    95

    Default

    Lil swish try this i have uploaded it for you

    Here's the new code
    -----------------------------------------------------------------

    -- My First Lua Program
    -- Author: YoungProdigy

    Room_width = 480
    Room_height = 272
    player1x =15
    player1y =136
    background =Image.load ("weapon.PNG")
    player1=Image.load("car1.PNG")

    function checkcontrols()
    pad = Controls.read()
    if pad:start() then
    exitgame = 1
    end
    if pad:right() then
    player1x = player1x +2
    end
    if pad:left() then
    player1x = player1x -2
    end
    if pad:up() then
    player1y = player1y - 2
    end
    if pad:down() then
    player1y = player1y +2
    end
    end
    function drawall()
    screen:blit (0,0,background)
    screen:blit(player1x,player1y,player1)
    screen.waitVblankStart()
    screen.flip()

    end

    while true do

    checkcontrols()
    drawall()
    if exitgame ==1 then
    break
    end
    end

    PSN ID: splodger15

  6. #36

    Default

    ok so after i have this...how would i go about making another app or program

  7. #37
    DCEmu Coder splodger15's Avatar
    Join Date
    Jun 2006
    Location
    London
    Age
    34
    Posts
    4,123
    Rep Power
    95

    Default

    Depends On what you want doing

    If i was you i would stick to basic lua programs to start with

    PSN ID: splodger15

Page 4 of 4 FirstFirst 1234

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
  •