Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Lua Help

                  
   
  1. #1
    DCEmu Regular vision's Avatar
    Join Date
    Dec 2006
    Location
    Mars
    Age
    32
    Posts
    397
    Rep Power
    71

    Default Lua Help

    Hey there can you tell me whats wrong with this script

    -- My First Lua Program
    --
    --
    -- ******* Variables ********
    green = Color.new(0,255,0)
    red = Color.new(255,0,0)
    blue = Color.new(0,0,255)
    --
    --
    --***Button Inputs
    upPressed = 'Up'
    downPressed = 'Down'
    leftPressed = 'Left'
    rightPressed = 'Right'
    LPressed = 'L'
    --
    --
    --*****Main Loop******
    while true do
    pad = Controls.read()
    screen:clear()
    screen.waitVblankStart()
    screen.flip()
    end
    --
    --
    --*****Button Print******
    if pad:up() then
    screenrint(100,100,upPressed,green)
    end
    if pad:down() then
    screenrint(100,100,downPressed,green)
    end
    if pad:left() then
    screenrint(100,100,leftPressed,green)
    end
    if pad:right() then
    screenrint(100,100,rightPressed,green)
    end
    if pad:l() then
    screenrint(100,100,LPressed,green)
    end
    if pad:r() then
    screenrint(100,100,'R',red)
    end
    if pad:triangle() then
    screenrint(100,100,'TRIANGLE',red)
    end
    if pad:circle() then
    screenrint(100,100,'CIRCLE',red)
    end
    if pad:cross() then
    screenrint(100,100,'X',red)
    end
    if pad:square() then
    screenrint(100,100,'SQUARE',red)
    end



    lol is : p but not spaced lol



    It is suppose to write stuff when you press up,down,right etc.. on ur psp but it doesnt work i just get a black screen anyone help?

  2. #2
    PS3 User Gizmo356's Avatar
    Join Date
    Feb 2006
    Age
    33
    Posts
    1,756
    Rep Power
    124

    Default

    you did the code rite but in the wrong place it should be like this

    -- ******* Variables ********
    green = Color.new(0,255,0)
    red = Color.new(255,0,0)
    blue = Color.new(0,0,255)
    --
    --
    --***Button Inputs
    upPressed = 'Up'
    downPressed = 'Down'
    leftPressed = 'Left'
    rightPressed = 'Right'
    LPressed = 'L'
    --
    --
    --*****Main Loop******
    while true do
    pad = Controls.read()
    screen:clear()
    --
    --
    --*****Button Print******
    if pad:up() then
    screenrint(100,100,upPressed,green)
    end
    if pad:down() then
    screenrint(100,100,downPressed,green)
    end
    if pad:left() then
    screenrint(100,100,leftPressed,green)
    end
    if pad:right() then
    screenrint(100,100,rightPressed,green)
    end
    if pad:l() then
    screenrint(100,100,LPressed,green)
    end
    if pad:r() then
    screenrint(100,100,'R',red)
    end
    if pad:triangle() then
    screenrint(100,100,'TRIANGLE',red)
    end
    if pad:circle() then
    screenrint(100,100,'CIRCLE',red)
    end
    if pad:cross() then
    screenrint(100,100,'X',red)
    end
    if pad:square() then
    screenrint(100,100,'SQUARE',red)
    end
    screen.waitVblankStart()
    screen.flip()
    end

  3. #3
    DCEmu Regular vision's Avatar
    Join Date
    Dec 2006
    Location
    Mars
    Age
    32
    Posts
    397
    Rep Power
    71

    Default

    It worked thanks man, but my i ask why it has to be in that order and what does screen.waitVblankStart()
    do?

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

    Default

    You can have it in a loop so

    while true do
    screen.waitVblankStart()
    end

    Also you can have screen.waitVblankStart() as

    This is taken from my PSP Turismo

    ----------detect other cars collision--------------
    function detectCollision(player, opponent)
    if (player.x + character:width() > opponent.x) and (player.x < opponent.x + opponent.pic:width()) and (player.y + character:height() > opponent.y) and (player.y < opponent.y + opponent.pic:height()) then
    screen.waitVblankStart(60)
    end
    end

    the screen.waitVblankStart(60) is when the car hit another car it is a 60 second wait to move on

    Someone else may be able to explain better

    PSN ID: splodger15

  5. #5
    DCEmu Regular vision's Avatar
    Join Date
    Dec 2006
    Location
    Mars
    Age
    32
    Posts
    397
    Rep Power
    71

    Default

    Hmm i see, but when i had it in a loop

    --*****Main Loop******
    while true do
    pad = Controls.read()
    screen:clear()
    screen.waitVblankStart()
    screen.flip()
    end


    it would not work

    If that what you mean

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

    Default

    This should be Ok

    -- ******* Variables ********
    green = Color.new(0,255,0)
    red = Color.new(255,0,0)

    -- ******* Button Inputs ********
    upPressed = 'Up'
    downPressed = 'Down'
    leftPressed = 'Left'
    rightPressed = 'Right'
    LPressed = 'L'

    -- *****Main Loop******
    while true do
    screen:clear()

    pad = Controls.read()

    if pad:up() then
    screenrint(100,100,upPressed,green)
    end

    if pad:down() then
    screenrint(100,100,downPressed,green)
    end
    if pad:left() then
    screenrint(100,100,leftPressed,green)
    end
    if pad:right() then
    screenrint(100,100,rightPressed,green)
    end
    if pad:l() then
    screenrint(100,100,LPressed,green)
    end

    if pad:r() then
    screenrint(100,100,'You are pressing the "R" button',red)
    end

    if pad:triangle() then
    screenrint(100,100,'You are pressing the "TRIANGLE" button',red)
    end

    if pad:circle() then
    screenrint(100,100,'You are pressing the "CIRCLE" button',red)
    end

    if pad:cross() then
    screenrint(100,100,'You are pressing the "X" button',red)
    end

    if pad:square() then
    screenrint(100,100,'You are pressing the "SQUARE" button',red)
    end

    screen.waitVblankStart()
    screen.flip()
    end

    You do not need a blue variable if you are not using it

    PSN ID: splodger15

  7. #7
    DCEmu Regular vision's Avatar
    Join Date
    Dec 2006
    Location
    Mars
    Age
    32
    Posts
    397
    Rep Power
    71

    Default

    Yeah i know i was just practicing to get the color variable thingy stuck in my head lol anyways thanks

    also i pmed you

  8. #8
    PS3 User Gizmo356's Avatar
    Join Date
    Feb 2006
    Age
    33
    Posts
    1,756
    Rep Power
    124

    Default

    If you need help aim me.

  9. #9
    DCEmu Regular vision's Avatar
    Join Date
    Dec 2006
    Location
    Mars
    Age
    32
    Posts
    397
    Rep Power
    71

    Default

    Oh you use aim me too thanks ill keep in mind

  10. #10
    PS3 User Gizmo356's Avatar
    Join Date
    Feb 2006
    Age
    33
    Posts
    1,756
    Rep Power
    124

    Default

    Yeah I have msn too so if you need help HIT ME UP!

    Lol!

Page 1 of 2 12 LastLast

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
  •