Seite 291 von 342 ErsteErste ... 191 241 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 341 ... LetzteLetzte
Zeige Ergebnis 8.701 bis 8.730 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; I'm not (Well, not in any recent programs), I've just seen it used in a few examples, and was curious ...

  
  1. #8701
    QJ Gamer Bronze
    Points: 5.381, Level: 47
    Level completed: 16%, Points required for next Level: 169
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Beiträge
    550
    Points
    5.381
    Level
    47
    Downloads
    1
    Uploads
    0

    Standard

    I'm not (Well, not in any recent programs), I've just seen it used in a few examples, and was curious is all. Thanks.



  2. #8702
    Lua guy
    Points: 11.690, Level: 71
    Level completed: 10%, Points required for next Level: 360
    Overall activity: 0%

    Registriert seit
    Jan 2008
    Ort
    Wales, cardiff
    Beiträge
    1.442
    Points
    11.690
    Level
    71
    My Mood
    Blah
    Downloads
    0
    Uploads
    0

    Standard

    I just need an quick explaintion of what this does cause it don't have an clue
    Code:
     
    colour = col:pixel(mar.x + 2, mar.y + 15)
    i don't understand this, and have never used this function

  3. #8703
    QJ Gamer Green
    Points: 3.721, Level: 38
    Level completed: 48%, Points required for next Level: 79
    Overall activity: 0%

    Registriert seit
    Jan 2008
    Beiträge
    612
    Points
    3.721
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    someimagenameixel(x,y) returns the color of the pixel at the x,y coordinates in the image someimagename
    someimagenameixel(x,y,color) sets the pixel in the image someimagename at coordinates x,y to the color color

  4. #8704
    QJ Gamer Green
    Points: 3.810, Level: 39
    Level completed: 7%, Points required for next Level: 140
    Overall activity: 0%

    Registriert seit
    May 2008
    Beiträge
    246
    Points
    3.810
    Level
    39
    Downloads
    0
    Uploads
    0

    Standard

    What's wrong with my code?

    --if currentlySelectedLineNumb er = 1 and pad:cross() then
    --Code goes here
    --end

    --if currentlySelectedLineNumb er = 2 and pad:cross() then
    --Code goes here
    --end

    if currentlySelectedLineNumb er = 3 and pad:cross() then
    break
    end
    My menu works perfectly without this, so everything is configured alright.
    This is the error I get:
    'then' expected near '='

  5. #8705
    QJ Gamer Green
    Points: 3.721, Level: 38
    Level completed: 48%, Points required for next Level: 79
    Overall activity: 0%

    Registriert seit
    Jan 2008
    Beiträge
    612
    Points
    3.721
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    when comparing one number to the other use ==
    when setting one value equal to another use =
    therefore in an if clause, you must use if somevariablename == somenumber, not =

    also tonight ill be able to help you more on msn

  6. #8706
    QJ Gamer Green
    Points: 3.810, Level: 39
    Level completed: 7%, Points required for next Level: 140
    Overall activity: 0%

    Registriert seit
    May 2008
    Beiträge
    246
    Points
    3.810
    Level
    39
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von TurtlesPwn Beitrag anzeigen
    when comparing one number to the other use ==
    when setting one value equal to another use =
    therefore in an if clause, you must use if somevariablename == somenumber, not =

    also tonight ill be able to help you more on msn
    Thanks it worked!
    And I don't know when it's day or night in your country, so I'll just be online untill u get there

    You're a great teacher btw

  7. #8707
    Lua guy
    Points: 11.690, Level: 71
    Level completed: 10%, Points required for next Level: 360
    Overall activity: 0%

    Registriert seit
    Jan 2008
    Ort
    Wales, cardiff
    Beiträge
    1.442
    Points
    11.690
    Level
    71
    My Mood
    Blah
    Downloads
    0
    Uploads
    0

    Standard

    Would something like this world work?
    Code:
     
    colour = col:pixel(mar.x + 2, mar.y + 15) 
    
    if colour = red then mario.x = oldx  
    end
    if colour = blue then mario.y = oldy 
    end
    Because i've used dofile ( experimenting ) with this but every time i use oldx, oldy it never works :?

  8. #8708
    QJ Gamer Green
    Points: 3.721, Level: 38
    Level completed: 48%, Points required for next Level: 79
    Overall activity: 0%

    Registriert seit
    Jan 2008
    Beiträge
    612
    Points
    3.721
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    again, if colour ==, not =. Also, I assume you have red and blue declared as Color.new(255,0,0) and Color.new(0,0,255)

  9. #8709
    QJ Gamer Green
    Points: 3.810, Level: 39
    Level completed: 7%, Points required for next Level: 140
    Overall activity: 0%

    Registriert seit
    May 2008
    Beiträge
    246
    Points
    3.810
    Level
    39
    Downloads
    0
    Uploads
    0

    Standard

    Aww me and my problems...

    I try to use danzeff osk, and it either writes in black, or not at all.
    This is my code:
    screenrint(5,5,typingstring, white)

    keyboard.process(2,105,pa d,oldpad)
    typingstring = keyboard.typeToString(typ ingstring)
    Of course I got the color white installed, and here are a few other lines:
    dofile("keybd.lua")
    typingstring = ""
    displaykeyboard = true
    I don't get any error, but when I use the OSK it doesn't write.
    (which means all the variables are ok and the code is stable, which is why I didn't gave u the whole code).

    I will soon check if it writes in black (screen:clear(white)).

    Oh and penguin I haven't worked on it since we talked coz I ****ed up my leg... which is why I have to ask here

  10. #8710
    Developer and Tutor.
    Points: 8.736, Level: 62
    Level completed: 96%, Points required for next Level: 14
    Overall activity: 0%

    Registriert seit
    Jul 2007
    Ort
    Widnes, England
    Beiträge
    1.649
    Points
    8.736
    Level
    62
    My Mood
    Happy
    Downloads
    0
    Uploads
    0

    Standard

    make sure typingstring is above while true do
    ------ FaT3oYCG -----
    AKA Craig, call me what you want to It's your preference.
    My Website: http://www.modern-gamer.co.uk/

    Currently working on:
    (0) MediaGrab
    (0) PGE Gears Of War - On hold (Very large project).
    (0) PS???? -On Hold A tactical 2d side scrolling game involving AI and online multiplayer features. - Tile engine nearley finished (1 bug to fix).

  11. #8711
    QJ Gamer Green
    Points: 3.810, Level: 39
    Level completed: 7%, Points required for next Level: 140
    Overall activity: 0%

    Registriert seit
    May 2008
    Beiträge
    246
    Points
    3.810
    Level
    39
    Downloads
    0
    Uploads
    0

    Standard

    of course it's above.
    but it's in the main loop, the loop of the menu.
    Maybe I should put it in the loop of the certain part?
    (above while true do)

  12. #8712
    QJ Gamer Green
    Points: 3.810, Level: 39
    Level completed: 7%, Points required for next Level: 140
    Overall activity: 0%

    Registriert seit
    May 2008
    Beiträge
    246
    Points
    3.810
    Level
    39
    Downloads
    0
    Uploads
    0

    Standard

    No, I tried changing background color to white, and moving the variables to that certain loop.

  13. #8713
    Lua guy
    Points: 11.690, Level: 71
    Level completed: 10%, Points required for next Level: 360
    Overall activity: 0%

    Registriert seit
    Jan 2008
    Ort
    Wales, cardiff
    Beiträge
    1.442
    Points
    11.690
    Level
    71
    My Mood
    Blah
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von TurtlesPwn Beitrag anzeigen
    again, if colour ==, not =. Also, I assume you have red and blue declared as Color.new(255,0,0) and Color.new(0,0,255)
    Oh my Bad, i typed it out wrong. I do know it should be == just to stay:)
    yes i do have the colours declared lol
    = means declaring variables
    == declares arguments against variables e.g
    Code:
    if whatever == 0 then
    whatever = 1 
    end
    just to clarify

  14. #8714
    QJ Gamer Platinum
    Points: 66.627, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Feb 2006
    Ort
    National Front Disco
    Beiträge
    13.057
    Points
    66.627
    Level
    100
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von dan369 Beitrag anzeigen
    Oh my Bad, i typed it out wrong. I do know it should be == just to stay:)
    yes i do have the colours declared lol
    = means declaring variables
    == declares arguments against variables e.g
    Code:
    if whatever == 0 then
    whatever = 1 
    end
    just to clarify
    Yeah, using a '==' verifies something (sees if it is true), whereas '=' changes the variable to, in this case, 1. I'm not sure if it works in Lua, but using '!==' checks to see if something is not true:

    Code:
    if whatever !== 0 then
    whatever = 0
    end
    Or, you could do:

    Code:
    if whatever == 1 then
    whatever = 0 
    end
    You see? :)

  15. #8715
    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

    Moose_Island - your explanation is worded somewhat awkward, and wrong about the 'not equal' operator.

    The '=' symbol alone is used to assign the preceding variable with the following value where the '==' symbol is used to compare the preceding and following variables if they are true (of the same data type), returning true or false respectively.

    With C's syntax, the != operator is the same as saying 'not equal'. In Lua the ~= operator is the equivalent of != in C.

    ...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


  16. #8716
    QJ Gamer Green
    Points: 3.810, Level: 39
    Level completed: 7%, Points required for next Level: 140
    Overall activity: 0%

    Registriert seit
    May 2008
    Beiträge
    246
    Points
    3.810
    Level
    39
    Downloads
    0
    Uploads
    0

    Standard

    Hey I write this again, because it got lost in those 872 pages.

    What's wrong with my code?

    Code:
    --if currentlySelectedLineNumb er = 1 and pad:cross() then
    --Code goes here
    --end
    
    --if currentlySelectedLineNumb er = 2 and pad:cross() then
    --Code goes here
    --end
    
    if currentlySelectedLineNumb er = 3 and pad:cross() then
    break
    end
    My menu works perfectly without this, so everything is configured alright.
    This is the error I get:
    'then' expected near '='
    Geändert von Moose (06-14-2008 um 03:24 AM Uhr)

  17. #8717
    QJ Gamer Bronze
    Points: 8.665, Level: 62
    Level completed: 72%, Points required for next Level: 85
    Overall activity: 0%

    Registriert seit
    Mar 2007
    Beiträge
    758
    Points
    8.665
    Level
    62
    Downloads
    0
    Uploads
    0

    Standard

    It's "==" instead of "=".

  18. #8718
    Lua guy
    Points: 11.690, Level: 71
    Level completed: 10%, Points required for next Level: 360
    Overall activity: 0%

    Registriert seit
    Jan 2008
    Ort
    Wales, cardiff
    Beiträge
    1.442
    Points
    11.690
    Level
    71
    My Mood
    Blah
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von michaelp Beitrag anzeigen
    It's "==" instead of "=".
    michaelp is right thats the promblem, basically what the first posts on this page is about lol
    look at the other posts above yours.

    Also does Mp3me.eos() work???
    cause i try to say
    Code:
     
    if the end of song (Mp3me.eos() ) is true (it uses true/false to determine ) then
    --whatever 
    end

  19. #8719
    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

    Still dan?

    Make sure you are constantly polling, a song is loaded into mp3me and '--whatever' is actual code that will somehow signify the if clause is true.

    ...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


  20. #8720
    Lua guy
    Points: 11.690, Level: 71
    Level completed: 10%, Points required for next Level: 360
    Overall activity: 0%

    Registriert seit
    Jan 2008
    Ort
    Wales, cardiff
    Beiträge
    1.442
    Points
    11.690
    Level
    71
    My Mood
    Blah
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von SG57 Beitrag anzeigen
    Still dan?

    Make sure you are constantly polling, a song is loaded into mp3me and '--whatever' is actual code that will somehow signify the if clause is true.
    huh?? i dont get that but yess i have loaded the song, plays fine. All i want is just to screen print song is finished
    currently what i have
    Code:
     
    if Mp3me.eos() then
    screen:clear()
    screen:print(10,10,"Song Finished",white)
    end

  21. #8721
    QJ Gamer Bronze
    Points: 5.381, Level: 47
    Level completed: 16%, Points required for next Level: 169
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Beiträge
    550
    Points
    5.381
    Level
    47
    Downloads
    1
    Uploads
    0

    Standard

    LuaplayerHM is retarded and returns strings: "true" and "false"

  22. #8722
    Lua guy
    Points: 11.690, Level: 71
    Level completed: 10%, Points required for next Level: 360
    Overall activity: 0%

    Registriert seit
    Jan 2008
    Ort
    Wales, cardiff
    Beiträge
    1.442
    Points
    11.690
    Level
    71
    My Mood
    Blah
    Downloads
    0
    Uploads
    0

    Standard

    so would i pu this instead
    Code:
     
    if Mp3me.eos() == true then
    screen:clear() 
    screen:print(10,10,"Song Finished",white) 
    end

  23. #8723
    QJ Gamer Green
    Points: 3.810, Level: 39
    Level completed: 7%, Points required for next Level: 140
    Overall activity: 0%

    Registriert seit
    May 2008
    Beiträge
    246
    Points
    3.810
    Level
    39
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Nielkie Beitrag anzeigen
    LuaplayerHM is retarded and returns strings: "true" and "false"
    Who are u talkin to?

  24. #8724
    Developer and Tutor.
    Points: 8.736, Level: 62
    Level completed: 96%, Points required for next Level: 14
    Overall activity: 0%

    Registriert seit
    Jul 2007
    Ort
    Widnes, England
    Beiträge
    1.649
    Points
    8.736
    Level
    62
    My Mood
    Happy
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von dan369 Beitrag anzeigen
    so would i pu this instead
    Code:
     
    if Mp3me.eos() == true then
    screen:clear() 
    screen:print(10,10,"Song Finished",white) 
    end
    Mp3me.eos() returns its values as "true" and "false" with the quatoation marks, because they are strings, i dont know why they are returned like that because they should just be boolean values, which would make it easier because if we needed them as a string we could use tostring()
    ------ FaT3oYCG -----
    AKA Craig, call me what you want to It's your preference.
    My Website: http://www.modern-gamer.co.uk/

    Currently working on:
    (0) MediaGrab
    (0) PGE Gears Of War - On hold (Very large project).
    (0) PS???? -On Hold A tactical 2d side scrolling game involving AI and online multiplayer features. - Tile engine nearley finished (1 bug to fix).

  25. #8725
    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've looked at the source and it's because he doesn't know how to return a boolean embarrassingly enough (for the record, with every 'me' release, that luaplayer is getting slower and bigger meaning slower and bigger games if any)

    ...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


  26. #8726
    QJ Gamer Silver
    Points: 12.501, Level: 73
    Level completed: 13%, Points required for next Level: 349
    Overall activity: 62,0%

    Registriert seit
    Sep 2007
    Ort
    AUS
    Beiträge
    284
    Points
    12.501
    Level
    73
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von SG57 Beitrag anzeigen
    I've looked at the source and it's because he doesn't know how to return a boolean embarrassingly enough (for the record, with every 'me' release, that luaplayer is getting slower and bigger meaning slower and bigger games if any)
    I can return boolean's now. just remember guys i ave only been learning C++ for 5 months now. If you want them to return boolean values then i can do that.

    BTW i am doing my best to keep the LuaPlayer size to a minimum. To try to keep it fast.
    Geändert von Moose (06-15-2008 um 12:18 AM Uhr) Grund: Double Post Merge
    Wyvern. That is all

  27. #8727
    QJ Gamer Green
    Points: 3.810, Level: 39
    Level completed: 7%, Points required for next Level: 140
    Overall activity: 0%

    Registriert seit
    May 2008
    Beiträge
    246
    Points
    3.810
    Level
    39
    Downloads
    0
    Uploads
    0

    Standard

    First of all thanks HomeMister for the quick help.

    Now, I got this interesting issue:
    [QUOTE]screenrint(5,20,"You should take in "..(typingstring*2.1) .." grams of protein each day", white)[/QUOTE
    I got an osk installed and everything.
    Now, the only way this line will work, is to configure typingstring as a number.
    I did this:
    typingstring = "0"
    Now it works, but the users gotta delete the 0 before they start to write their own number.
    (if I set typingstring = "" then the value wouldn't be a number).

    Is there any way that the users can start writing from nothing?
    instead of having to delete my number before?
    (If I set the intial value of typingstring to nothing, then it's not a number and the luaplayer crashes).

  28. #8728
    Developer and Tutor.
    Points: 8.736, Level: 62
    Level completed: 96%, Points required for next Level: 14
    Overall activity: 0%

    Registriert seit
    Jul 2007
    Ort
    Widnes, England
    Beiträge
    1.649
    Points
    8.736
    Level
    62
    My Mood
    Happy
    Downloads
    0
    Uploads
    0

    Standard

    just put

    Code:
    typingstring = ""
    and then to convert it to a number use

    Code:
    number_choice = tonumber(typingstring)
    p.s. use code tags

    [code]
    Code:
     and then the second has a / before the word code [ /-Here code]
    ------ FaT3oYCG -----
    AKA Craig, call me what you want to It's your preference.
    My Website: http://www.modern-gamer.co.uk/

    Currently working on:
    (0) MediaGrab
    (0) PGE Gears Of War - On hold (Very large project).
    (0) PS???? -On Hold A tactical 2d side scrolling game involving AI and online multiplayer features. - Tile engine nearley finished (1 bug to fix).

  29. #8729
    QJ Gamer Green
    Points: 3.810, Level: 39
    Level completed: 7%, Points required for next Level: 140
    Overall activity: 0%

    Registriert seit
    May 2008
    Beiträge
    246
    Points
    3.810
    Level
    39
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von FaT3oYCG Beitrag anzeigen
    just put

    Code:
    typingstring = ""
    and then to convert it to a number use

    Code:
    number_choice = tonumber(typingstring)
    p.s. use code tags

    [code]
    Code:
     and then the second has a / before the word code [ /-Here code]
    where to put

    Code:
    number_choice = tonumber(typingstring)
    and what to do with it?

    i'm using danzeff osk btw

  30. #8730
    Developer and Tutor.
    Points: 8.736, Level: 62
    Level completed: 96%, Points required for next Level: 14
    Overall activity: 0%

    Registriert seit
    Jul 2007
    Ort
    Widnes, England
    Beiträge
    1.649
    Points
    8.736
    Level
    62
    My Mood
    Happy
    Downloads
    0
    Uploads
    0

    Standard

    omg this thing is stupid it wont let you edit posts and it always posts the same thing twice meh arg grr

    put it where you need the number, i take it that you want the user to enter a number well

    Code:
    number_choice = tonumber(typingstring)
    is the number it will convert the data from the osk into a number
    Geändert von Moose (06-15-2008 um 04:34 AM Uhr) Grund: Added [code] tags.
    ------ FaT3oYCG -----
    AKA Craig, call me what you want to It's your preference.
    My Website: http://www.modern-gamer.co.uk/

    Currently working on:
    (0) MediaGrab
    (0) PGE Gears Of War - On hold (Very large project).
    (0) PS???? -On Hold A tactical 2d side scrolling game involving AI and online multiplayer features. - Tile engine nearley finished (1 bug to fix).


 

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:53 AM Uhr.

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