Seite 21 von 342 ErsteErste ... 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 71 121 ... LetzteLetzte
Zeige Ergebnis 601 bis 630 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; Thats because it only goes through the function if you hold X. And the function distracts/adds from y only once ...

  
  1. #601
    QJ Gamer Green
    Points: 5.559, Level: 48
    Level completed: 5%, Points required for next Level: 191
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Beiträge
    506
    Points
    5.559
    Level
    48
    Downloads
    0
    Uploads
    0

    Standard

    Thats because it only goes through the function if you hold X. And the function distracts/adds from y only once and only if you hold X. If you want to make it do a full jump, then you can add a special variable, and if that var is say 1, then you let it do your functon. If its 0 then it wont. I hope its clear enough, im kinda drunk lol>


    LUA manual:
    [url]http://www.lua.org/manual/5.0/manual.html[/url]

    LUA Wiki:
    [url]http://wiki.ps2dev.org/psp:lua_player[/url]

  2. #602
    QJ Gamer Blue
    Points: 5.036, Level: 45
    Level completed: 44%, Points required for next Level: 114
    Overall activity: 0%

    Registriert seit
    Feb 2006
    Beiträge
    224
    Points
    5.036
    Level
    45
    Downloads
    0
    Uploads
    0

    Standard

    Lol thanks, I put jump = false and in the jump function I put if jump==true then ... the rest of the function then jump = false so it stops jumping.... and if pad:cross() then jump = true .. works now thanks Alatair!

  3. #603
    QJ Gamer Blue
    Points: 5.631, Level: 48
    Level completed: 41%, Points required for next Level: 119
    Overall activity: 0%

    Registriert seit
    Jun 2005
    Beiträge
    375
    Points
    5.631
    Level
    48
    Downloads
    0
    Uploads
    0

    Standard

    of that was the solution to the problem. now i just have to do collision and what to do when the poles reach the endof the screen. ill probly need help somewhere in there

  4. #604
    QJ Gamer Green
    Points: 5.559, Level: 48
    Level completed: 5%, Points required for next Level: 191
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Beiträge
    506
    Points
    5.559
    Level
    48
    Downloads
    0
    Uploads
    0

    Standard

    sure no prob. I'll try and help anybody who i can help!
    LUA manual:
    [url]http://www.lua.org/manual/5.0/manual.html[/url]

    LUA Wiki:
    [url]http://wiki.ps2dev.org/psp:lua_player[/url]

  5. #605
    is not posting very often
    Points: 33.152, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 99,6%

    Registriert seit
    Feb 2006
    Ort
    omnipresent
    Beiträge
    5.162
    Points
    33.152
    Level
    100
    Downloads
    0
    Uploads
    0

    Standard

    What happened is I blitted the cursor at X, Y and it said that the value was nil

    if i said X = 100, Y = 100, it didn't move even though the code said X = X+1, so... im confused

  6. #606
    QJ Gamer Green
    Points: 5.559, Level: 48
    Level completed: 5%, Points required for next Level: 191
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Beiträge
    506
    Points
    5.559
    Level
    48
    Downloads
    0
    Uploads
    0

    Standard

    Heres what i used for my cursor:
    Code:
    mouse=Image.load('mouse.png')
    x=240
    y=136
    while true do
    screen:blit(x, y, mouse, 0, 0, mouse:width(), mouse:height())
    pad = Controls.read()
    		dx = pad:analogX()
    	        if math.abs(dx) > 32 then
    	                x = x + dx / 32
    	        end
    
    	        dy = pad:analogY()
    	        if math.abs(dy) > 32 then
    	                y = y + dy / 32
    	        end
    screen.waitVblankStart()
    	screen:flip()
    end
    This works perfectly for me. Dont just copy it, but also see if you understand it.
    LUA manual:
    [url]http://www.lua.org/manual/5.0/manual.html[/url]

    LUA Wiki:
    [url]http://wiki.ps2dev.org/psp:lua_player[/url]

  7. #607
    QJ Gamer Blue
    Points: 5.036, Level: 45
    Level completed: 44%, Points required for next Level: 114
    Overall activity: 0%

    Registriert seit
    Feb 2006
    Beiträge
    224
    Points
    5.036
    Level
    45
    Downloads
    0
    Uploads
    0

    Standard

    I need a little help getting my gun to work in lua

    if pad:cross() then
    shootright()
    end

    how would I make it so it does shootright() when I just tap X instead of while I hold it?
    is it a different command to make it read the pad or something?
    I already tried using variables like..

    shootis = false

    function shootright()
    if shootis==true then
    if shoottime>=1 then
    bulletx = bulletx + 50
    shoottime = 0
    shoottime = shoottime + 1
    end
    end
    end

    if pad:cross() then
    shootis = true
    shootright()
    end

    But it still meant I had to hold in the cross button...
    so does anyone know if there is a way to make it happen on 1 tap of the cross button??
    thanks...

  8. #608
    11th Squad Captain
    Points: 26.490, Level: 97
    Level completed: 14%, Points required for next Level: 860
    Overall activity: 0%

    Registriert seit
    Jun 2005
    Ort
    You are here -----> 名前: アダム | 飲むコー&#1
    Beiträge
    2.562
    Points
    26.490
    Level
    97
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von lui2603
    I need a little help getting my gun to work in lua

    if pad:cross() then
    shootright()
    end

    how would I make it so it does shootright() when I just tap X instead of while I hold it?
    is it a different command to make it read the pad or something?
    I already tried using variables like..

    shootis = false

    function shootright()
    if shootis==true then
    if shoottime>=1 then
    bulletx = bulletx + 50
    shoottime = 0
    shoottime = shoottime + 1
    end
    end
    end

    if pad:cross() then
    shootis = true
    shootright()
    end

    But it still meant I had to hold in the cross button...
    so does anyone know if there is a way to make it happen on 1 tap of the cross button??
    thanks...
    Thats pretty messed up lol...
    I Will see what i can do for ya :mrgreen: .
    This is pretty simple for what your asking
    so if i cant do it today then someone else will
    probally sort this out asap lol..
    FAVORITE GAME! - BEER & ANIME! - SO EXICTING!

    開発者, 携帯用プログラマー 日本サポータおよび恋人 本名のアダムの鍛冶屋
    Currently Working On: - Flashmod V2.50 - Flashmod V2.60
    Currently Drinking: Coffee! - 私はコーヒーを飲む
    Chao Garden: DEMO v0.6
    Chao Garden V0.5b Review!

  9. #609
    QJ Gamer Blue
    Points: 5.036, Level: 45
    Level completed: 44%, Points required for next Level: 114
    Overall activity: 0%

    Registriert seit
    Feb 2006
    Beiträge
    224
    Points
    5.036
    Level
    45
    Downloads
    0
    Uploads
    0

    Standard

    Lol, thanks

  10. #610
    11th Squad Captain
    Points: 26.490, Level: 97
    Level completed: 14%, Points required for next Level: 860
    Overall activity: 0%

    Registriert seit
    Jun 2005
    Ort
    You are here -----> 名前: アダム | 飲むコー&#1
    Beiträge
    2.562
    Points
    26.490
    Level
    97
    Downloads
    0
    Uploads
    0

    Standard

    if pad:cross() then
    shootright=true
    end

    if shootright==true then
    bulletx = bulletx + 50
    end
    if shootright==false then
    end

    Maybe that will work?
    But i really need a more detailed
    destriction/code for this to understand...
    I Will make a better version soon, cause
    thats just a small test lol. ;)
    FAVORITE GAME! - BEER & ANIME! - SO EXICTING!

    開発者, 携帯用プログラマー 日本サポータおよび恋人 本名のアダムの鍛冶屋
    Currently Working On: - Flashmod V2.50 - Flashmod V2.60
    Currently Drinking: Coffee! - 私はコーヒーを飲む
    Chao Garden: DEMO v0.6
    Chao Garden V0.5b Review!

  11. #611
    QJ Gamer Blue
    Points: 5.036, Level: 45
    Level completed: 44%, Points required for next Level: 114
    Overall activity: 0%

    Registriert seit
    Feb 2006
    Beiträge
    224
    Points
    5.036
    Level
    45
    Downloads
    0
    Uploads
    0

    Standard

    Hm it won't work because the bullet will only go to bulletx + 50
    that's why I had shoottime going in a loop so that bulletx will keep adding 50..
    the thing is if I have it on a loop which is started by pressing x it wont keep going unless I hold in x all the time...

    edit: also does anyone know how I make lua read from a tileset in a single .png file? like if each tile was 10 pixels wide and 10 pixels long?
    Geändert von lui2603 (03-08-2006 um 07:28 AM Uhr)

  12. #612
    QJ Gamer Green
    Points: 5.559, Level: 48
    Level completed: 5%, Points required for next Level: 191
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Beiträge
    506
    Points
    5.559
    Level
    48
    Downloads
    0
    Uploads
    0

    Standard

    Maybe this willl work (i did it really fast, maybe i need to adjust some things):
    Code:
    function shootright()
    
    for shoottime=1,10 do
    bulletx = bulletx + 50
    shoottime = shoottime + 1
    end
    
    end
    
    if pad:cross() then
    shootright()
    end
    About the tiles:
    Just load them all from that picture. You can see how at the basic LUA tutorial. Im sorry i forgot the site and im not at home. Its something like: add 10 pixels eachtime you load a part from that picture. Ill look up the site when im back home.

    Altair
    LUA manual:
    [url]http://www.lua.org/manual/5.0/manual.html[/url]

    LUA Wiki:
    [url]http://wiki.ps2dev.org/psp:lua_player[/url]

  13. #613
    is not posting very often
    Points: 33.152, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 99,6%

    Registriert seit
    Feb 2006
    Ort
    omnipresent
    Beiträge
    5.162
    Points
    33.152
    Level
    100
    Downloads
    0
    Uploads
    0

    Standard

    AltairHeres what i used for my cursor:
    Code:
    mouse=Image.load('mouse.p ng')x=240y=136while true doscreen:blit(x, y, mouse, 0, 0, mouse:width(), mouse:height())pad = Controls.read() dx = pad:analogX() if math.abs(dx) > 32 then x = x + dx / 32 end dy = pad:analogY() if math.abs(dy) > 32 then y = y + dy / 32 endscreen.waitVblankStart () screen:flip()end



    This works perfectly for me. Dont just copy it, but also see if you understand it.
    Cheers its quite similar to mine and i think i know where I'm going wrong!

    thanks

  14. #614
    QJ Gamer Blue
    Points: 5.036, Level: 45
    Level completed: 44%, Points required for next Level: 114
    Overall activity: 0%

    Registriert seit
    Feb 2006
    Beiträge
    224
    Points
    5.036
    Level
    45
    Downloads
    0
    Uploads
    0

    Standard

    My game was working just fine but after I added this peice of code:

    if pad:up() and spritenum = car[1] then
    direction = "up"
    spritey = spritey - 1
    end
    if pad:down() and spritenum = car[1] then
    direction = "down"
    spritey = spritey + 1
    end
    if pad:right() and spritenum = car[1] then
    direction = "right"
    spritex = spritex + 1
    end
    if pad:left() and spritenum = car[1] then
    direction = "left"
    spritex = spritex - 1
    end



    it gave me an error saying "'then' expected near '='"
    anyone know what's wrong with it?

  15. #615
    QJ Gamer Green
    Points: 5.559, Level: 48
    Level completed: 5%, Points required for next Level: 191
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Beiträge
    506
    Points
    5.559
    Level
    48
    Downloads
    0
    Uploads
    0

    Standard

    oo-oo, i know! To check if something is equal you have to use "==", not "=". So you have to change those.
    For example: "if pad:up() and spritenum = car[1] then", becomes "if pad:up() and spritenum == car[1] then"
    LUA manual:
    [url]http://www.lua.org/manual/5.0/manual.html[/url]

    LUA Wiki:
    [url]http://wiki.ps2dev.org/psp:lua_player[/url]

  16. #616
    QJ Gamer Blue
    Points: 5.036, Level: 45
    Level completed: 44%, Points required for next Level: 114
    Overall activity: 0%

    Registriert seit
    Feb 2006
    Beiträge
    224
    Points
    5.036
    Level
    45
    Downloads
    0
    Uploads
    0

    Standard

    Oh yeah, didn't see that... Cheers Altair!

  17. #617
    QJ Gamer Green
    Points: 6.374, Level: 52
    Level completed: 12%, Points required for next Level: 176
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Ort
    OMG where AM I!?!?!?!?
    Beiträge
    820
    Points
    6.374
    Level
    52
    Downloads
    0
    Uploads
    0

    Standard

    How can I change the sensitivity of the buttons. Its going too much.
    Geändert von InhumanElmo (03-08-2006 um 01:11 PM Uhr)
    [SPOILER="For PSP History"]1.50 > 1.52 > 2.00 > 1.5 > 1.5 (POC CF) > 1.5 (Harleyg) > 1.5 (Casual) > 3.03 OE-A > 3.03 OE-C[/SPOILER]
    Check it out: [URL="http://youtube.com/watch?v=xNVPKM07TWs&mode=related&search="]Pen Spinning[/URL]

  18. #618
    QJ Gamer Blue
    Points: 5.631, Level: 48
    Level completed: 41%, Points required for next Level: 119
    Overall activity: 0%

    Registriert seit
    Jun 2005
    Beiträge
    375
    Points
    5.631
    Level
    48
    Downloads
    0
    Uploads
    0

    Standard

    ive started doing my collision(checking pixels) and i get this error

    Index.lua:201: An argument was incorrect

    these are the things that i added

    Code:
    TR = image:pixel(XAxis+48, YAxis)
    TL = image:pixel(XAxis, YAxis)
    BR = image:pixel(XAxis+48, YAxis+64)
    BL = image:pixel(XAxis, YAxis+64)
    TRcolor = TR:colors()
    TLcolor = TL:colors()
    BRcolor = BR:colors()
    BLcolor = BL:colors()
    im pretty sure im just doing it wrong because all i have to gooff of is that command. nothing else(like how it works)

  19. #619
    QJ Gamer Green
    Points: 5.559, Level: 48
    Level completed: 5%, Points required for next Level: 191
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Beiträge
    506
    Points
    5.559
    Level
    48
    Downloads
    0
    Uploads
    0

    Standard

    @InhumanElmo
    Do you mean for the Analogstick?

    @Soadnation
    What line is line 201? I think your code is correct, but i have never used it though.
    LUA manual:
    [url]http://www.lua.org/manual/5.0/manual.html[/url]

    LUA Wiki:
    [url]http://wiki.ps2dev.org/psp:lua_player[/url]

  20. #620
    QJ Gamer Green
    Points: 6.374, Level: 52
    Level completed: 12%, Points required for next Level: 176
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Ort
    OMG where AM I!?!?!?!?
    Beiträge
    820
    Points
    6.374
    Level
    52
    Downloads
    0
    Uploads
    0

    Standard

    No I mean for the actual dpad buttons. Is it possible? I need it for scrolling through numbers but it always goes too fast and skips numbers!
    [SPOILER="For PSP History"]1.50 > 1.52 > 2.00 > 1.5 > 1.5 (POC CF) > 1.5 (Harleyg) > 1.5 (Casual) > 3.03 OE-A > 3.03 OE-C[/SPOILER]
    Check it out: [URL="http://youtube.com/watch?v=xNVPKM07TWs&mode=related&search="]Pen Spinning[/URL]

  21. #621
    QJ Gamer Green
    Points: 5.559, Level: 48
    Level completed: 5%, Points required for next Level: 191
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Beiträge
    506
    Points
    5.559
    Level
    48
    Downloads
    0
    Uploads
    0

    Standard

    well you can say "if oldpad~=pad then" and then your code there. Where you add "oldpad=pad" at the end of your controlcheck part. What it does is check if your controls are the same as the last one and if so then it doesn't do anything. If they are different then it reads the controls. If it isnt clear i can post some code.

    You can also put some WaitVBlank's after it. Then it has a pause and goes slower.
    LUA manual:
    [url]http://www.lua.org/manual/5.0/manual.html[/url]

    LUA Wiki:
    [url]http://wiki.ps2dev.org/psp:lua_player[/url]

  22. #622
    QJ Gamer Green
    Points: 6.374, Level: 52
    Level completed: 12%, Points required for next Level: 176
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Ort
    OMG where AM I!?!?!?!?
    Beiträge
    820
    Points
    6.374
    Level
    52
    Downloads
    0
    Uploads
    0

    Standard

    The Vblanks work. Thanks alot!
    [SPOILER="For PSP History"]1.50 > 1.52 > 2.00 > 1.5 > 1.5 (POC CF) > 1.5 (Harleyg) > 1.5 (Casual) > 3.03 OE-A > 3.03 OE-C[/SPOILER]
    Check it out: [URL="http://youtube.com/watch?v=xNVPKM07TWs&mode=related&search="]Pen Spinning[/URL]

  23. #623
    QJ Gamer Blue
    Points: 5.631, Level: 48
    Level completed: 41%, Points required for next Level: 119
    Overall activity: 0%

    Registriert seit
    Jun 2005
    Beiträge
    375
    Points
    5.631
    Level
    48
    Downloads
    0
    Uploads
    0

    Standard

    line 201 is trhe first one

  24. #624
    QJ Gamer Green
    Points: 5.559, Level: 48
    Level completed: 5%, Points required for next Level: 191
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Beiträge
    506
    Points
    5.559
    Level
    48
    Downloads
    0
    Uploads
    0

    Standard

    np!

    @Soadnation
    Where you have "image" you have to write the name of YOUR image. So if its background it becomes "backgroundixel(x,y,)". Or if you want it of the whole screen its "screenixel(x,y)".
    LUA manual:
    [url]http://www.lua.org/manual/5.0/manual.html[/url]

    LUA Wiki:
    [url]http://wiki.ps2dev.org/psp:lua_player[/url]

  25. #625
    QJ Gamer Blue
    Points: 5.631, Level: 48
    Level completed: 41%, Points required for next Level: 119
    Overall activity: 0%

    Registriert seit
    Jun 2005
    Beiträge
    375
    Points
    5.631
    Level
    48
    Downloads
    0
    Uploads
    0

    Standard

    thanks that helped alot. now i got the collision working*when it collides it says somtyhing) just have to change that to do somthing when they colide

  26. #626
    QJ Gamer Blue
    Points: 5.036, Level: 45
    Level completed: 44%, Points required for next Level: 114
    Overall activity: 0%

    Registriert seit
    Feb 2006
    Beiträge
    224
    Points
    5.036
    Level
    45
    Downloads
    0
    Uploads
    0

    Standard

    How would I make it do a different thing if X is pressed if it already does something else?
    at the moment I have X shooting

    pad = Controls.read()

    if pad:cross() then
    shoot()
    end

    *some more code to make sprite change*

    then after
    newpad = Controls.read()
    if newpad:cross() then
    *something else*
    end


    but when I press cross through newpad it still shoots...
    end

  27. #627
    QJ Gamer Green
    Points: 5.559, Level: 48
    Level completed: 5%, Points required for next Level: 191
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Beiträge
    506
    Points
    5.559
    Level
    48
    Downloads
    0
    Uploads
    0

    Standard

    Hmm never tried that. Maybe you can just make a variable for that like:
    pad = Controls.read()

    if pad:cross() then
    whatever=1
    shoot()
    end

    *some more code to make sprite change*

    then after

    if pad:cross() and whatever==1 then
    *something else*
    end


    The thing is you should have a puase in between i think, because otherwise it will do it immediately afterwards.
    Geändert von Altair (03-10-2006 um 04:40 AM Uhr)
    LUA manual:
    [url]http://www.lua.org/manual/5.0/manual.html[/url]

    LUA Wiki:
    [url]http://wiki.ps2dev.org/psp:lua_player[/url]

  28. #628
    QJ Gamer Blue
    Points: 5.036, Level: 45
    Level completed: 44%, Points required for next Level: 114
    Overall activity: 0%

    Registriert seit
    Feb 2006
    Beiträge
    224
    Points
    5.036
    Level
    45
    Downloads
    0
    Uploads
    0

    Standard

    Ok I done it now.

    if pad:cross() and spritenum==sprites then
    shoot()
    end
    if pad:cross() and spritenum==carnum and direction=="up" then
    spritey = spritey - 5
    end

  29. #629
    QJ Gamer Green
    Points: 5.559, Level: 48
    Level completed: 5%, Points required for next Level: 191
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Beiträge
    506
    Points
    5.559
    Level
    48
    Downloads
    0
    Uploads
    0

    Standard

    and it works?
    LUA manual:
    [url]http://www.lua.org/manual/5.0/manual.html[/url]

    LUA Wiki:
    [url]http://wiki.ps2dev.org/psp:lua_player[/url]

  30. #630
    QJ Gamer Blue
    Points: 5.036, Level: 45
    Level completed: 44%, Points required for next Level: 114
    Overall activity: 0%

    Registriert seit
    Feb 2006
    Beiträge
    224
    Points
    5.036
    Level
    45
    Downloads
    0
    Uploads
    0

    Standard

    Yeah... thanks for the help but just after posting I realised I could do it this way

    Oh and if anyone knows how to do this, help would be really appreciated! I've been trying for so long to get it working...
    I'm trying to get the lua script to read from a text file (map.txt) and have the numbers or letters which are in map.txt assigned to a table in my script.

    So if i had

    Tile = {}

    Tile[1] = Image.load("grass.png")

    and had "G" in the map.txt so that if I put

    GGGGGG
    GGGGGG

    It would do 2 lines of the same image repeated...

    thanks if anyone can help.

    edit: Could somebody maybe upload an lua script which only has the code and map?
    Geändert von lui2603 (03-10-2006 um 11:46 AM Uhr)


 

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 .