Seite 104 von 342 ErsteErste ... 4 54 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 154 204 ... LetzteLetzte
Zeige Ergebnis 3.091 bis 3.120 von 10238

Lua Programming Help Thread

This is a discussion on Lua Programming Help Thread within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; Yes, set a bool... Code: -- Note, I dont know LUAs syntax 100%, but I do understand the 'coding' --concept ...

  
  1. #3091
    words are stones in my <3
    Points: 35.274, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Spokane
    Beiträge
    5.008
    Points
    35.274
    Level
    100
    My Mood
    Lonely
    Downloads
    1
    Uploads
    0

    Standard

    Yes, set a bool...

    Code:
    -- Note, I dont know LUAs syntax 100%, but I do understand the 'coding' 
    --concept very well IMO, AKA LUA isnt C, so if you see C syntax, just ignore it ;)
    run = false
    
    while true do
        if run~=true then 
            function_needed_to_run_once_here()
            run = true
         end
    end
    ... SG57... out!



    ...at what speed must I live.. to be able to see you again?...

    Projects

    You can support my Open World 3D RPG for PSP by voting for it here


  2. #3092
    QJ Gamer Green
    Points: 7.057, Level: 55
    Level completed: 54%, Points required for next Level: 93
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Ort
    Scotland, UK
    Beiträge
    571
    Points
    7.057
    Level
    55
    Downloads
    0
    Uploads
    0

    Standard

    ok thanks. How did i not think of that

  3. #3093
    words are stones in my <3
    Points: 35.274, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Spokane
    Beiträge
    5.008
    Points
    35.274
    Level
    100
    My Mood
    Lonely
    Downloads
    1
    Uploads
    0

    Standard

    'Your young and naieve...' lol, jk... Id be a hypicrit for such a thought ;)

    ...at what speed must I live.. to be able to see you again?...

    Projects

    You can support my Open World 3D RPG for PSP by voting for it here


  4. #3094
    QJ Gamer Green
    Points: 7.057, Level: 55
    Level completed: 54%, Points required for next Level: 93
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Ort
    Scotland, UK
    Beiträge
    571
    Points
    7.057
    Level
    55
    Downloads
    0
    Uploads
    0

    Standard

    dont worry i am only 12 so yeah i am young

  5. #3095
    words are stones in my <3
    Points: 35.274, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Spokane
    Beiträge
    5.008
    Points
    35.274
    Level
    100
    My Mood
    Lonely
    Downloads
    1
    Uploads
    0

    Standard

    I am only 14, and I get judged/treaed differently then the average... I want to say 16 ish coder... Most are around there Im assuming.

    ...at what speed must I live.. to be able to see you again?...

    Projects

    You can support my Open World 3D RPG for PSP by voting for it here


  6. #3096
    QJ Gamer Green
    Points: 7.057, Level: 55
    Level completed: 54%, Points required for next Level: 93
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Ort
    Scotland, UK
    Beiträge
    571
    Points
    7.057
    Level
    55
    Downloads
    0
    Uploads
    0

    Standard

    hey is there a way to make the controls less sensitive because sometimes when you press x it goes straight through two scripts because the game thinks i pressed it twice

  7. #3097
    sceKernelExitGame();
    Points: 19.955, Level: 89
    Level completed: 21%, Points required for next Level: 395
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Ort
    New York
    Beiträge
    3.126
    Points
    19.955
    Level
    89
    Downloads
    0
    Uploads
    0

    Standard

    yeah add a
    Code:
    screen.waitVblankStart(10)
    somewhere in you code. remember each number in that is a millisecond.
    Also you could incorporate a timer, but thats the hard way ;)

  8. #3098
    Developer
    Points: 5.650, Level: 48
    Level completed: 50%, Points required for next Level: 100
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    USA, Virginia
    Beiträge
    580
    Points
    5.650
    Level
    48
    Downloads
    0
    Uploads
    0

    Standard

    i had this problem too , i put pad = oldpad in the function and it worked for me... i could be wrong so dont get mad if it dosent work out..
    -= Double Post =-
    is that even remotely right? check my above post.. sorry for the double post if it dosent merge it.
    Geändert von branin (08-03-2006 um 06:43 AM Uhr) Grund: Automerged Doublepost

  9. #3099
    6201ymereJ
    Points: 7.062, Level: 55
    Level completed: 56%, Points required for next Level: 88
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Baltimore
    Beiträge
    588
    Points
    7.062
    Level
    55
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von mark.sparky
    hey is there a way to make the controls less sensitive because sometimes when you press x it goes straight through two scripts because the game thinks i pressed it twice
    have it be

    Code:
    if pad:cross and oldpad ~= pad then
    --your code
    end
    
    oldpad = pad

  10. #3100
    QJ Gamer Green
    Points: 7.057, Level: 55
    Level completed: 54%, Points required for next Level: 93
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Ort
    Scotland, UK
    Beiträge
    571
    Points
    7.057
    Level
    55
    Downloads
    0
    Uploads
    0

    Standard

    ok thnx

  11. #3101
    Developer
    Points: 4.006, Level: 40
    Level completed: 28%, Points required for next Level: 144
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Beiträge
    57
    Points
    4.006
    Level
    40
    Downloads
    0
    Uploads
    0

    Standard

    if anyone could i would like to know how to fix a problem with my fps cause it slows down when i blit a background and since i screen clear whenever the player moves or jumps it slows down with the background in but without it its perfect:Argh: please help.....thanks

  12. #3102
    Developer
    Points: 5.650, Level: 48
    Level completed: 50%, Points required for next Level: 100
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    USA, Virginia
    Beiträge
    580
    Points
    5.650
    Level
    48
    Downloads
    0
    Uploads
    0

    Standard

    @mark.sparky

    Nice Game! Actually seeing how hard lua can be i have a differant outlook on LUA coders.. i know that took alot of work so... good job!

  13. #3103
    QJ Gamer Blue
    Points: 5.453, Level: 47
    Level completed: 52%, Points required for next Level: 97
    Overall activity: 0%

    Registriert seit
    Jun 2005
    Beiträge
    166
    Points
    5.453
    Level
    47
    Downloads
    0
    Uploads
    0

    Standard

    if someone could help me with a problem I'm having.

    I'm trying to make a game, and have everything I need already done, except I need to be able to get the color of certain pixels as the game goes on.
    I tried using
    Code:
    Color image:pixel(x, y)
    buit had to change it to screen:pixel, instead of image:pixel before it would do anything.

    what I want to know is, is it possible to get the r,g,b,a values out of the table made with that function and put the values into variables.

  14. #3104
    words are stones in my <3
    Points: 35.274, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Spokane
    Beiträge
    5.008
    Points
    35.274
    Level
    100
    My Mood
    Lonely
    Downloads
    1
    Uploads
    0

    Standard

    How did you try to use it? That function right there returns a color strctured like:

    Color.new(r,g,b)

    So make a variable = imageixel(x,y) If this isnt what u were saying, sorry but i didnt quite understand..

    ...at what speed must I live.. to be able to see you again?...

    Projects

    You can support my Open World 3D RPG for PSP by voting for it here


  15. #3105
    QJ Gamer Blue
    Points: 5.453, Level: 47
    Level completed: 52%, Points required for next Level: 97
    Overall activity: 0%

    Registriert seit
    Jun 2005
    Beiträge
    166
    Points
    5.453
    Level
    47
    Downloads
    0
    Uploads
    0

    Standard

    edit- nvm I figured it out and fixed it.

    but is it possible to extract the color values from a color?
    for example can I extract the Blue value into a variable?
    Geändert von vettefan (08-04-2006 um 11:07 AM Uhr)

  16. #3106
    words are stones in my <3
    Points: 35.274, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Spokane
    Beiträge
    5.008
    Points
    35.274
    Level
    100
    My Mood
    Lonely
    Downloads
    1
    Uploads
    0

    Standard

    Yes im sure it is... Id need to look at the pixel function in LUA players source though, as i may make it into a structure and easily extract the blue data from it...

    ...at what speed must I live.. to be able to see you again?...

    Projects

    You can support my Open World 3D RPG for PSP by voting for it here


  17. #3107
    QJ Gamer Blue
    Points: 5.453, Level: 47
    Level completed: 52%, Points required for next Level: 97
    Overall activity: 0%

    Registriert seit
    Jun 2005
    Beiträge
    166
    Points
    5.453
    Level
    47
    Downloads
    0
    Uploads
    0

    Standard

    I think I have something that does what I need it to.


    thanks for the help though, I was getting something with the pixel colors wrong, now everything's fine :Jump:

  18. #3108
    QJ Gamer Green
    Points: 7.057, Level: 55
    Level completed: 54%, Points required for next Level: 93
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Ort
    Scotland, UK
    Beiträge
    571
    Points
    7.057
    Level
    55
    Downloads
    0
    Uploads
    0

    Standard

    Hey what does this erorr mean. "<eof> expected near 'end'" .
    Any help would be useful

  19. #3109
    Your Fate is Grim...
    Points: 11.640, Level: 70
    Level completed: 98%, Points required for next Level: 10
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Beiträge
    2.269
    Points
    11.640
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von mark.sparky
    Hey what does this erorr mean. "<eof> expected near 'end'" .
    Any help would be useful

    usually (for me) it means that u have an exta a "end" in ur code.

    im not 100% sur tho.
    --------------------------------------------------------------------------------------

  20. #3110
    QJ Gamer Green
    Points: 7.057, Level: 55
    Level completed: 54%, Points required for next Level: 93
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Ort
    Scotland, UK
    Beiträge
    571
    Points
    7.057
    Level
    55
    Downloads
    0
    Uploads
    0

    Standard

    thnx. The code thought there was an extra end because i didnt declare the function

  21. #3111
    Your Fate is Grim...
    Points: 11.640, Level: 70
    Level completed: 98%, Points required for next Level: 10
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Beiträge
    2.269
    Points
    11.640
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von mark.sparky
    thnx. The code thought there was an extra end because i didnt declare the function
    no prob.

    BTW, is there any command that gives u how many sub-sets are in an array??

    E.g.:
    Code:
    bob = {}
    
    bob[1] = "joe"
    bob[2] = "zOMG"
    bob[3] = "can we build it??"

    the array "bob" would have 3 sub-sets.
    --------------------------------------------------------------------------------------

  22. #3112
    words are stones in my <3
    Points: 35.274, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Spokane
    Beiträge
    5.008
    Points
    35.274
    Level
    100
    My Mood
    Lonely
    Downloads
    1
    Uploads
    0

    Standard

    In C, the equivalent is the 'sizeof' operator...

    Code:
    char bob[3] = { 'S','G','5','7' };
    int bob_size = (sizeof(bob));
    VERY useful when allocating memory (for me, i need it alot for my 3d texture loading...)

    So if ther eis a LUA equivalent, you got it ;)

    ...at what speed must I live.. to be able to see you again?...

    Projects

    You can support my Open World 3D RPG for PSP by voting for it here


  23. #3113
    Your Fate is Grim...
    Points: 11.640, Level: 70
    Level completed: 98%, Points required for next Level: 10
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Beiträge
    2.269
    Points
    11.640
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von SG57
    In C, the equivalent is the 'sizeof' operator...

    Code:
    char bob[3] = { 'S','G','5','7' };
    int bob_size = (sizeof(bob));
    VERY useful when allocating memory (for me, i need it alot for my 3d texture loading...)

    So if ther eis a LUA equivalent, you got it ;)
    thx! ill reseach it.
    --------------------------------------------------------------------------------------

  24. #3114
    QJ Gamer Blue
    Points: 4.519, Level: 42
    Level completed: 85%, Points required for next Level: 31
    Overall activity: 0%

    Registriert seit
    Apr 2006
    Beiträge
    120
    Points
    4.519
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    Anything wrong with this, I keep getting an error saying "no script found"

    Code:
     -- Functions
    file = io.open("counter.txt", "r")
    counter = file:read("*n")
    file:close()
    selector = { image = Image.createEmpty(145,15), x = 147,y = 77 }
    selector.image:clear(blue)
    function drawMenu()
    screen:clear()
    pad = Controls.read()
    screen:blit(selector.x,selector.y,selector.image)
    screen:print(150,80,"Start Game (Black)",white)
    screen:print(150,100,"Start Game (Blue)",white)
    if pad:up() and oldpad:up() ~= pad:up() then
    selector.y = 77
    startcolor = black
    local sound = menusound
    voice = sound:play()
    end
    
    if pad:down() and oldpad:down() ~= pad:down() then
    selector.y = 97
    startcolor = blue
    local sound = menusound
    voice = sound:play()
    end
    
    if pad:cross() and oldpad:cross() ~= pad:cross() then
    gamestate = "game"
    counter = counter + 1
    file = io.open("counter.txt","w")
    file:write(counter)
    file:close()
    end
    end
    
    function playGame()
    screen:clear(startcolor)
    pad = Controls.read()
    
    screen:print(100,100,"This program has been executed " .. counter .. " times.",white)
    screen:print(100,110,"Press Start to exit to Menu",white)
    
    if pad:start() then
    gamestate = "menu"
    local sound = goodbye
    voice = sound:play()
    end
    end
    
    -- Main Loop
    while true do
    
    if gamestate == "menu" then
    drawMenu()
    end
    
    if gamestate == "game" then
    playGame()
    end
    
    screen.flip()
    oldpad = pad
    end

  25. #3115
    Your Fate is Grim...
    Points: 11.640, Level: 70
    Level completed: 98%, Points required for next Level: 10
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Beiträge
    2.269
    Points
    11.640
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Shadox75
    Anything wrong with this, I keep getting an error saying "no script found"

    Code:
     -- Functions
    file = io.open("counter.txt", "r")
    counter = file:read("*n")
    file:close()
    selector = { image = Image.createEmpty(145,15), x = 147,y = 77 }
    selector.image:clear(blue)
    function drawMenu()
    screen:clear()
    pad = Controls.read()
    screen:blit(selector.x,selector.y,selector.image)
    screen:print(150,80,"Start Game (Black)",white)
    screen:print(150,100,"Start Game (Blue)",white)
    if pad:up() and oldpad:up() ~= pad:up() then
    selector.y = 77
    startcolor = black
    local sound = menusound
    voice = sound:play()
    end
    
    if pad:down() and oldpad:down() ~= pad:down() then
    selector.y = 97
    startcolor = blue
    local sound = menusound
    voice = sound:play()
    end
    
    if pad:cross() and oldpad:cross() ~= pad:cross() then
    gamestate = "game"
    counter = counter + 1
    file = io.open("counter.txt","w")
    file:write(counter)
    file:close()
    end
    end
    
    function playGame()
    screen:clear(startcolor)
    pad = Controls.read()
    
    screen:print(100,100,"This program has been executed " .. counter .. " times.",white)
    screen:print(100,110,"Press Start to exit to Menu",white)
    
    if pad:start() then
    gamestate = "menu"
    local sound = goodbye
    voice = sound:play()
    end
    end
    
    -- Main Loop
    while true do
    
    if gamestate == "menu" then
    drawMenu()
    end
    
    if gamestate == "game" then
    playGame()
    end
    
    screen.flip()
    oldpad = pad
    end

    does it give a line number?? or it just could be that ur using windows luaplayer and u named ur script wonrg.
    --------------------------------------------------------------------------------------

  26. #3116
    QJ Gamer Blue
    Points: 4.519, Level: 42
    Level completed: 85%, Points required for next Level: 31
    Overall activity: 0%

    Registriert seit
    Apr 2006
    Beiträge
    120
    Points
    4.519
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    I forgot to include some of the code.

    Code:
     -- Colors
    white = Color.new(255,255,255)
    blue = Color.new(0,0,255)
    black = Color.new(0,0,0)
    
    -- Variables
    oldpad = Control.read()
    startcolor = black
    gamestate = "menu"
    menusound = Sound.load("Sounds/beep.wav",false)
    goodbye = Sound.load("Sounds/goodbye.wav",false)
    
    -- Functions
    file = io.open("counter.txt", "r")
    counter = file:read("*n")
    file:close()
    selector = { image = Image.createEmpty(145,15), x = 147,y = 77 }
    selector.image:clear(blue)
    function drawMenu()
    screen:clear()
    pad = Controls.read()
    screen:blit(selector.x,selector.y,selector.image)
    screen:print(150,80,"Start Game (Black)",white)
    screen:print(150,100,"Start Game (Blue)",white)
    if pad:up() and oldpad:up() ~= pad:up() then
    selector.y = 77
    startcolor = black
    local sound = menusound
    voice = sound:play()
    end
    
    if pad:down() and oldpad:down() ~= pad:down() then
    selector.y = 97
    startcolor = blue
    local sound = menusound
    voice = sound:play()
    end
    
    if pad:cross() and oldpad:cross() ~= pad:cross() then
    gamestate = "game"
    counter = counter + 1
    file = io.open("counter.txt","w")
    file:write(counter)
    file:close()
    end
    end
    
    function playGame()
    screen:clear(startcolor)
    pad = Controls.read()
    
    screen:print(100,100,"This program has been executed " .. counter .. " times.",white)
    screen:print(100,110,"Press Start to exit to Menu",white)
    
    if pad:start() then
    gamestate = "menu"
    local sound = goodbye
    voice = sound:play()
    end
    end
    
    -- Main Loop
    while true do
    
    if gamestate == "menu" then
    drawMenu()
    end
    
    if gamestate == "game" then
    playGame()
    end
    
    screen.flip()
    oldpad = pad
    end
    It won't work.

    It says
    error: index.lua:7: attempt to index global 'Control' (a nil value)
    ERROR: No script file found
    I am using LUA on my PSP.

  27. #3117
    I'm Baaaack!
    Points: 17.067, Level: 83
    Level completed: 44%, Points required for next Level: 283
    Overall activity: 52,0%

    Registriert seit
    May 2006
    Ort
    Nowhere
    Beiträge
    2.186
    Points
    17.067
    Level
    83
    Downloads
    0
    Uploads
    0

    Standard

    At line 7 it's Controls.read() not Conrol.read(). You have to put the "s" in controls.
    -= Double Post =-
    Does anyone know of a way where if I hold down the UP/DOWN button, it scrolls fast, but if I just tap it, it scrolls one at a time. Like in the PSP's XMB.
    Geändert von Access_Denied (08-04-2006 um 04:00 PM Uhr) Grund: Automerged Doublepost

  28. #3118
    QJ Gamer Blue
    Points: 5.453, Level: 47
    Level completed: 52%, Points required for next Level: 97
    Overall activity: 0%

    Registriert seit
    Jun 2005
    Beiträge
    166
    Points
    5.453
    Level
    47
    Downloads
    0
    Uploads
    0

    Standard

    if your using lua player through eloader you may get no script found error.
    that kept happening to me when I had to use eloader.

  29. #3119
    QJ Gamer Blue
    Points: 4.519, Level: 42
    Level completed: 85%, Points required for next Level: 31
    Overall activity: 0%

    Registriert seit
    Apr 2006
    Beiträge
    120
    Points
    4.519
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    I was using 1.50, I got to it work.

  30. #3120
    QJ Gamer Gold
    Points: 17.453, Level: 84
    Level completed: 21%, Points required for next Level: 397
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    everywhere
    Beiträge
    3.526
    Points
    17.453
    Level
    84
    Downloads
    1
    Uploads
    0

    Standard

    @access_denied just try the following:

    Code:
    blue = Color.new(0,0,255)
    screen:clear()
    player = Image.createNew(5,5) -- i know it's sometin like that
    player:clear(blue)
    
    button = "no"
    time_held = 0
    x = 240
    y = 0
    oldpad = pad
    while true do
    pad = controls.read()
    if time_held < 20
    if pad:left() then
    time_held = time_held + 1
    endif
    if pad:left() and oldpad:left() ~= pad:left() then
    x = x - 1
    end
    end
    if oldpad:left() ~= pad:left() then
    time_held = 0
    end
    if time_held > 19 then
    if pad:left() then
    x = x - 1
    end
    end
    screen:blit(x,y,player)
    screen.flip()
    screen.waitVblankStart()
    oldpad = pad
    end
    somtin like that should work
    1. Failed....again...
    2. http://slicer.gibbocool.com/ stay updated on all my projects
    3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been


 

Tags for this Thread

Forumregeln

  • Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
  • Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
  • Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
  • Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.
  •  





Alle Zeitangaben in WEZ -8. Es ist jetzt 07:52 AM Uhr.

Use of this Web site constitutes acceptance of the TERMS & CONDITIONS and PRIVACY POLICY
Copyright © , Caputo Media, LLC. All Rights Reserved. Cluster .