Seite 241 von 342 ErsteErste ... 141 191 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 291 341 ... LetzteLetzte
Zeige Ergebnis 7.201 bis 7.230 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; gman - string.gsub(stringname,wh attoreplace,whattoreplace itwith)...

  
  1. #7201
    QJ Gamer Gold
    Points: 11.629, Level: 70
    Level completed: 95%, Points required for next Level: 21
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Beiträge
    1.633
    Points
    11.629
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    gman -
    string.gsub(stringname,wh attoreplace,whattoreplace itwith)



  2. #7202
    QJ Gamer Green
    Points: 11.800, Level: 71
    Level completed: 38%, Points required for next Level: 250
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Ort
    Middle Europe
    Beiträge
    1.281
    Points
    11.800
    Level
    71
    Downloads
    0
    Uploads
    0

    Standard

    tactical: how does string.sub() works? same like gsub?

  3. #7203
    Developer
    Points: 4.318, Level: 41
    Level completed: 84%, Points required for next Level: 32
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Beiträge
    205
    Points
    4.318
    Level
    41
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von myschoo
    tactical: how does string.sub() works? same like gsub?
    No:

    Zitat Zitat von Anti-QJ
    Doesnt anyone go to lua.org anymore?

    http://www.lua.org/manual/5.1/manual.html#5.4
    Not the people who need to the most.

  4. #7204
    QJ Gamer Green
    Points: 11.800, Level: 71
    Level completed: 38%, Points required for next Level: 250
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Ort
    Middle Europe
    Beiträge
    1.281
    Points
    11.800
    Level
    71
    Downloads
    0
    Uploads
    0

    Standard

    oh yeah... ill test it thx

  5. #7205
    QJ Gamer Blue
    Points: 5.344, Level: 46
    Level completed: 97%, Points required for next Level: 6
    Overall activity: 0%

    Registriert seit
    May 2006
    Beiträge
    347
    Points
    5.344
    Level
    46
    Downloads
    0
    Uploads
    0

    Standard

    nvm SG57 i figured it out.

  6. #7206
    QJ Gamer Gold
    Points: 11.629, Level: 70
    Level completed: 95%, Points required for next Level: 21
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Beiträge
    1.633
    Points
    11.629
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    myschoo - sub returns a portion of the string specified by one or two nuber arguments, gsub returns the string with the certain parts replaced.

  7. #7207
    Points: 24.247, Level: 94
    Level completed: 90%, Points required for next Level: 103
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    texas
    Beiträge
    2.803
    Points
    24.247
    Level
    94
    Downloads
    0
    Uploads
    0

    Standard

    http://lua-users.org/wiki/TutorialDirectory

    Not that anyone cares that every lua function and method is documented there.
    牧来栠摩琠敨映汩獥
    PSN: youresam
    From Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
    --Mike Hollingsworth

  8. #7208
    QJ Gamer Gold
    Points: 11.629, Level: 70
    Level completed: 95%, Points required for next Level: 21
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Beiträge
    1.633
    Points
    11.629
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    Yea I spent like a day reading crap there if you guys care. So seriously read it nao.

  9. #7209
    QJ Gamer Blue
    Points: 4.369, Level: 42
    Level completed: 10%, Points required for next Level: 181
    Overall activity: 0%

    Registriert seit
    Feb 2007
    Beiträge
    246
    Points
    4.369
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    Maybe one of the mods or admins should put a large banner message at the top of the forum with a link to the lua tuts in it.

    Well, maybe not. The people who are really dumb probably wouldn't notice it, and the people who are really lazy would probably just ignore it and ask the stupid questions anyway

  10. #7210
    QJ Gamer Blue
    Points: 3.525, Level: 37
    Level completed: 17%, Points required for next Level: 125
    Overall activity: 0%

    Registriert seit
    Apr 2007
    Beiträge
    81
    Points
    3.525
    Level
    37
    Downloads
    0
    Uploads
    0

    Standard

    How do I make the image flip around. I want the character to face right when right it pushed...

  11. #7211
    QJ Gamer Green
    Points: 11.300, Level: 70
    Level completed: 13%, Points required for next Level: 350
    Overall activity: 0%

    Registriert seit
    Dec 2006
    Ort
    main();
    Beiträge
    1.071
    Points
    11.300
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von yumCOOKIEZZ
    How do I make the image flip around. I want the character to face right when right it pushed...
    Sprites. Look around, sprite examples are everywhere.

  12. #7212
    QJ Gamer Blue
    Points: 3.525, Level: 37
    Level completed: 17%, Points required for next Level: 125
    Overall activity: 0%

    Registriert seit
    Apr 2007
    Beiträge
    81
    Points
    3.525
    Level
    37
    Downloads
    0
    Uploads
    0

    Standard

    hmm...so theirs no way I can just flip this single image around the other way?

  13. #7213
    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 yumCOOKIEZZ
    hmm...so theirs no way I can just flip this single image around the other way?
    no. (not in lua atleast)just make another image, and use a image edting program to mirror your character.
    --------------------------------------------------------------------------------------

  14. #7214
    QJ Gamer Blue
    Points: 3.525, Level: 37
    Level completed: 17%, Points required for next Level: 125
    Overall activity: 0%

    Registriert seit
    Apr 2007
    Beiträge
    81
    Points
    3.525
    Level
    37
    Downloads
    0
    Uploads
    0

    Standard

    I guess. I was hoping I wouldn't have to do this because in total there are 199 different parts to my character >.< Different positions when using a different weapon etc. Thanks for the help anyway -.-

  15. #7215
    Points: 24.247, Level: 94
    Level completed: 90%, Points required for next Level: 103
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    texas
    Beiträge
    2.803
    Points
    24.247
    Level
    94
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Grimfate126
    no. (not in lua atleast)just make another image, and use a image edting program to mirror your character.
    ...theres this magical thing called the GU.
    If your player is less than 64x64 use Gu.SPRITE mode, if not, youll have to draw every vertex with Gu.TRIANGLE_STRIP.
    If worse comes to worse and you have to use TRIANGLE_STRIP, remember to use the following vertex pattern: (X2,Y2) (X1,Y2) (X2,Y1) (Y1,X1)
    牧来栠摩琠敨映汩獥
    PSN: youresam
    From Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
    --Mike Hollingsworth

  16. #7216
    QJ Gamer Blue
    Points: 3.525, Level: 37
    Level completed: 17%, Points required for next Level: 125
    Overall activity: 0%

    Registriert seit
    Apr 2007
    Beiträge
    81
    Points
    3.525
    Level
    37
    Downloads
    0
    Uploads
    0

    Standard

    Thanks. I'll try that tomorrow after I get home from school. I had already re done 10 pictures in their opposite but if this works it will save me the time of changing 100's of pictures..

  17. #7217
    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 youresam
    ...theres this magical thing called the GU.
    If your player is less than 64x64 use Gu.SPRITE mode, if not, youll have to draw every vertex with Gu.TRIANGLE_STRIP.
    If worse comes to worse and you have to use TRIANGLE_STRIP, remember to use the following vertex pattern: (X2,Y2) (X1,Y2) (X2,Y1) (Y1,X1)
    i REALLY dont think he's upto that yet, but he may be. i dunno.
    --------------------------------------------------------------------------------------

  18. #7218
    Points: 24.247, Level: 94
    Level completed: 90%, Points required for next Level: 103
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    texas
    Beiträge
    2.803
    Points
    24.247
    Level
    94
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von yumCOOKIEZZ
    Thanks. I'll try that tomorrow after I get home from school. I had already re done 10 pictures in their opposite but if this works it will save me the time of changing 100's of pictures..
    Yeah, saves load time and memory. I'll show you how to use it tomorrow.
    牧来栠摩琠敨映汩獥
    PSN: youresam
    From Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
    --Mike Hollingsworth

  19. #7219
    QJ Gamer Blue
    Points: 4.369, Level: 42
    Level completed: 10%, Points required for next Level: 181
    Overall activity: 0%

    Registriert seit
    Feb 2007
    Beiträge
    246
    Points
    4.369
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    Actually, Gu.SPRITE mode will work with images over 64x64. Thanks to some help I got from Cools, I was able to put together this function for flipping images with the Gu.

    Code:
    function Gu.blit(x, y, image, scale, flip)
    
    	if not scale or type(scale) == "string" then 
    		flip = scale
    		scale = 1
    	end
    	
    	if flip then
    		if flip == "H" then
    			x_start = image:width()
    			y_start = 0
    			x_end  = 0
    			y_end = image:height()
    		elseif  flip == "V" then
    			x_start = 0
    			y_start = image:height()
    			x_end  = image:width()
    			y_end = 0
    		elseif flip == "HV" then
    			x_start = image:width()
    			y_start = image:height()
    			x_end = 0
    			y_end = 0
    		end
    	else
    		x_start = 0
    		y_start = 0
    		x_end = image:width()
    		y_end = image:height()
    	end
    	
    	width = (image:width()*scale)+x
    	height = (image:height()*scale)+y
    
    	temp = {
    	{x_start, y_start, x, y, 0},
    	{x_end, y_end, width, height, 0}
    	}
    
    	Gu.enable(Gu.TEXTURE_2D)
    	Gu.texImage(image)
    	Gum.drawArray(Gu.SPRITES, Gu.TEXTURE_32BITF+Gu.VERTEX_32BITF+Gu.TRANSFORM_2D, temp)
    end
    Use it like this:

    Code:
    Gu.start3d() 
    Gu.blit( 20,   20, image, 0.5, "H")  -- this will blit the image at half normal size and flipped horizontally
    Gu.blit(100,  20, image, 1.5, "V")  -- this will blit it at 1.5 times normal size, flipped vertically
    Gu.blit(300,  20, image, "HV")  -- this will blit it at normal size, flipped both horizontally and vertically
    Gu.end3d()
    Although the function takes four arguments, because the last one is a string I've been able to set it up so that you can skip the 3rd argument "scale" and still have it work properly (see the third example). Put any images you want to blit as resized or flipped between the Gu.start and Gu.end, however don't try to use the regular blit while the Gu is running or the game will crash. I've used this without problems with images over 100 pixels in both the official Lua PLayer v0.20 and in Cools mod 3, but I haven't tried it with any of the earlier versions.

    The reason I've set it up without the Gu.start3d and Gu.end3d inside the function itself is because if you're going to be using this for a lot of images, starting and stopping the gu from inside the function would slow down your program quite a bit.

  20. #7220
    Points: 24.247, Level: 94
    Level completed: 90%, Points required for next Level: 103
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    texas
    Beiträge
    2.803
    Points
    24.247
    Level
    94
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Merick
    Actually, Gu.SPRITE mode will work with images over 64x64.
    Em, it *does* but is oh-my-god slow. Not worth it, it'll cut your FPS in half.
    牧来栠摩琠敨映汩獥
    PSN: youresam
    From Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
    --Mike Hollingsworth

  21. #7221
    QJ Gamer Blue
    Points: 4.561, Level: 43
    Level completed: 6%, Points required for next Level: 189
    Overall activity: 0%

    Registriert seit
    May 2006
    Beiträge
    224
    Points
    4.561
    Level
    43
    Downloads
    0
    Uploads
    0

    Standard

    ok, will the flipping function using the gu work fine if the rest of your code is non-gu? Because i heard that using the gu with other regualr 2-d things won't work right or something?

    or maybe i have no idea what i am talking about, because i don't really even know what the gu is. just 3-d enabled stuff?

  22. #7222
    Developer
    Points: 4.205, Level: 41
    Level completed: 28%, Points required for next Level: 145
    Overall activity: 0%

    Registriert seit
    Oct 2006
    Ort
    San Diego
    Beiträge
    177
    Points
    4.205
    Level
    41
    Downloads
    0
    Uploads
    0

    Standard

    This is a function posted on Evilmana and modded slightly by merick
    It'll take care of the flipping for you.
    Code:
    function Gu.blit(x, y, image, scale, flip) 
        
       if scale then 
          if type(scale) == "string" then 
             flip = scale 
             scale = 1 
          else 
             scale = (scale/100) 
          end 
       end 
        
       if flip then 
          if flip == "H" then 
             x_start = image:width() 
             y_start = 0 
             x_end  = 0 
             y_end = image:height() 
          elseif  flip == "V" then 
             x_start = 0 
             y_start = image:height() 
             x_end  = image:width() 
             y_end = 0 
          elseif flip == "HV" then 
             x_start = image:width() 
             y_start = image:height() 
             x_end = 0 
             y_end = 0 
          end 
       else 
          x_start = 0 
          y_start = 0 
          x_end = image:width() 
          y_end = image:height() 
       end 
        
       temp = { 
       {x_start, y_start, 0+x, 0+y, 0}, 
       {x_end, y_end, (image:width()*scale)+x, (image:height()*scale)+y, 0} 
       } 
       Gu.enable(Gu.TEXTURE_2D) 
       Gu.texImage(image) 
       Gum.drawArray(Gu.SPRITES, Gu.TEXTURE_32BITF+Gu.VERTEX_32BITF+Gu.TRANSFORM_2D, temp) 
    end
    Merick:
    use it like this:

    Gu.start3d()
    Gu.blit(x, y, image, scale in %, flip mode)
    Gu.end3d()

    for flip mode, you have to put in a string - "H" for horizontal, "V" for vertical, and "HV" for both

    Also, I put in a type checker so if you want to just flip the image and not resize it you can just leave out the scale parameter and it'll automatically swap the the flip code string to the flip parameter:

    Gu.blit(x, y, image, flip mode)

    Klepto:
    I've tested this and it works great. Also, you can blit as many thing as you like in between the start and end 3d calls.

  23. #7223
    QJ Gamer Blue
    Points: 3.525, Level: 37
    Level completed: 17%, Points required for next Level: 125
    Overall activity: 0%

    Registriert seit
    Apr 2007
    Beiträge
    81
    Points
    3.525
    Level
    37
    Downloads
    0
    Uploads
    0

    Standard

    Thanks =D


    I already converted 36 images but this will definitely save me the time... in total the different characters add up to like 700 sprites..but I may not include them all.


    The Largest sprite is like 35x 24 or around there, so would I use that function and then use like
    gu.blit(x, y, body, h)

    And it will be facing opposite?


    Also, will this affect the collision codes (when I add them). It would really suck if the character cant be hit when facing right -.-
    -= Double Post =-
    Code:
    if char then
    screen:clear()
    screen:blit(0,0, background, true)
    screen:blit(x,y, Stand1, true)
    screen:blit(x-3,y-34, Head, true)
    screen:blit(x+17,y+2, Arm, true)
    screen:blit(x, y-18, FaceSmile, true)
    screen:blit(x-10,y-38, Hair, true)
    else
    screen:clear()
    screen:blit(0,0, background, true)
    Gu.start3d()
    Gu.blit(x, y, Stand1,100, h)
    gu.blit(x-3,y-34, Head, h)
    gu.blit(x+17,y+2, Arm, h)
    gu.blit(x, y-18, FaceSmile, h)
    gu.blit(x-10,y-38, Hair, h)
    Gu.end3d()
    end
    I get errors on the bolded area. I have the function on a different LUA file that is accessed through DoFile.
    Geändert von yumCOOKIEZZ (05-04-2007 um 12:51 PM Uhr) Grund: Automerged Doublepost

  24. #7224
    Developer
    Points: 4.205, Level: 41
    Level completed: 28%, Points required for next Level: 145
    Overall activity: 0%

    Registriert seit
    Oct 2006
    Ort
    San Diego
    Beiträge
    177
    Points
    4.205
    Level
    41
    Downloads
    0
    Uploads
    0

    Standard

    The H has to be a string, so you have to pass, "H" <- quotes included

    Also, this shouldn't hinder collision in the least, as your coordinate system is identical using the Gu in this manner.

  25. #7225
    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 emericaska8r
    ok, will the flipping function using the gu work fine if the rest of your code is non-gu? Because i heard that using the gu with other regualr 2-d things won't work right or something?

    or maybe i have no idea what i am talking about, because i don't really even know what the gu is. just 3-d enabled stuff?
    the GU is the PSP's graphics utility. you use it without knowing, if youre using lua, or graphics.c. all 2d and 3d functions are done with the GU.

    about your question: what do you mean by non-gu? you may have to mod the code a bit, but it shouldnt be too much of a hassle in lua. (i think ) for the record, i havent used the gu in lua at all, so meh.
    --------------------------------------------------------------------------------------

  26. #7226
    QJ Gamer Blue
    Points: 3.525, Level: 37
    Level completed: 17%, Points required for next Level: 125
    Overall activity: 0%

    Registriert seit
    Apr 2007
    Beiträge
    81
    Points
    3.525
    Level
    37
    Downloads
    0
    Uploads
    0

    Standard

    I fixed it, but now, when I do it, no person. He disappears.

    Heres my code o.O
    Code:
    if char then
    screen:clear()
    screen:blit(0,0, background, true)
    screen:blit(x,y, Stand1, true)
    screen:blit(x-3,y-34, Head, true)
    screen:blit(x+17,y+2, Arm, true)
    screen:blit(x, y-18, FaceSmile, true)
    screen:blit(x-10,y-38, Hair, true)
    else
    screen:clear()
    screen:blit(0,0, background, true)
    Gu.start3d()
    Gu.blit(x, y, Stand1,100, "H")
    Gu.blit(x-3,y-34, Head, "H")
    Gu.blit(x+17,y+2, Arm, "H")
    Gu.blit(x, y-18, FaceSmile, "H")
    Gu.blit(x-10,y-38, Hair, "H")
    Gu.end3d()
    end

  27. #7227
    QJ Gamer Blue
    Points: 4.369, Level: 42
    Level completed: 10%, Points required for next Level: 181
    Overall activity: 0%

    Registriert seit
    Feb 2007
    Beiträge
    246
    Points
    4.369
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    Lol Klepto, I already posted that on the previous page, also the version I posted has some small changes to it. The original version (which you just posted) was written so that the scale argument would be divided by 100, I.E. putting 100 for scale would equal 100%, or normal size. However, I realized that having the function divide a number every time it was called would probably slow down the program, so I edited it to take out the divide by 100 part.

    yumCOOKIEZZ, in that code, is it only the Stand1 image which doesn't get displayed? if you're using the version of the function that I posted, then in this line:

    Gu.blit(x, y, Stand1,100, "H")

    you should remove the 100, because with that version using 100 for scale would mean 100 times the normal size, and at that size the of the image would be larger than the screen size.

    emericaska8r:
    As for your question about the Gu, the problems your talking about only happen if you try to use the regular blit function while the Gu is running. Basically, when you use the regular blit it starts the Gu, draws the image, then stops the Gu. So, if the Gu is already running and you try to use screen:blit it tries to start it again, and thats what causes lua player to crash. As long at you don't use the regular blit function inside the Gu.start3d() and Gu.end3d() statements, you shouldn't have any problems

  28. #7228
    QJ Gamer Blue
    Points: 4.561, Level: 43
    Level completed: 6%, Points required for next Level: 189
    Overall activity: 0%

    Registriert seit
    May 2006
    Beiträge
    224
    Points
    4.561
    Level
    43
    Downloads
    0
    Uploads
    0

    Standard

    ok thanks everyone for the clarification. helped a lot!!!

  29. #7229
    QJ Gamer Blue
    Points: 3.525, Level: 37
    Level completed: 17%, Points required for next Level: 125
    Overall activity: 0%

    Registriert seit
    Apr 2007
    Beiträge
    81
    Points
    3.525
    Level
    37
    Downloads
    0
    Uploads
    0

    Standard

    They all disappear. I'll make some experiments and see if I can fix it.

  30. #7230
    QJ Gamer Blue
    Points: 3.525, Level: 37
    Level completed: 17%, Points required for next Level: 125
    Overall activity: 0%

    Registriert seit
    Apr 2007
    Beiträge
    81
    Points
    3.525
    Level
    37
    Downloads
    0
    Uploads
    0

    Standard

    Hrm...Still nothing. Whenever I turn right, the entire character disappears...


 

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 .