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)...
-
05-03-2007, 04:41 AM #7201QJ Gamer Gold
- Registriert seit
- Aug 2006
- Beiträge
- 1.633
- Points
- 11.629
- Level
- 70
- Downloads
- 0
- Uploads
- 0
gman -
string.gsub(stringname,wh attoreplace,whattoreplace itwith)
-
05-03-2007, 05:42 AM #7202QJ Gamer Green
- Registriert seit
- Jul 2006
- Ort
- Middle Europe
- Beiträge
- 1.281
- Points
- 11.800
- Level
- 71
- Downloads
- 0
- Uploads
- 0
tactical: how does string.sub() works? same like gsub?
[1 Year QJ Member]
[LUA Coder and C Learner]
[Ball Revamped Clone v0.1]
[Phil's Shooting Range v0.3]
[HideFile PRX v2]
[SSR PRX v1.1]
-
05-03-2007, 06:28 AM #7203Developer

- Registriert seit
- Jul 2006
- Beiträge
- 205
- Points
- 4.318
- Level
- 41
- Downloads
- 0
- Uploads
- 0
No:
Zitat von myschoo
Not the people who need to the most.
Zitat von Anti-QJ
-
05-03-2007, 07:33 AM #7204QJ Gamer Green
- Registriert seit
- Jul 2006
- Ort
- Middle Europe
- Beiträge
- 1.281
- Points
- 11.800
- Level
- 71
- Downloads
- 0
- Uploads
- 0
oh yeah... ill test it thx
[1 Year QJ Member]
[LUA Coder and C Learner]
[Ball Revamped Clone v0.1]
[Phil's Shooting Range v0.3]
[HideFile PRX v2]
[SSR PRX v1.1]
-
05-03-2007, 12:59 PM #7205
nvm SG57 i figured it out.
-
05-03-2007, 02:11 PM #7206QJ Gamer Gold
- Registriert seit
- Aug 2006
- Beiträge
- 1.633
- Points
- 11.629
- Level
- 70
- Downloads
- 0
- Uploads
- 0
myschoo - sub returns a portion of the string specified by one or two nuber arguments, gsub returns the string with the certain parts replaced.
-
05-03-2007, 03:49 PM #7207
http://lua-users.org/wiki/TutorialDirectory
Not that anyone cares that every lua function and method is documented there.牧来栠摩琠敨映汩獥
PSN: youresamFrom Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
--Mike Hollingsworth
-
05-03-2007, 03:50 PM #7208QJ Gamer Gold
- Registriert seit
- Aug 2006
- Beiträge
- 1.633
- Points
- 11.629
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Yea I spent like a day reading crap there if you guys care. So seriously read it nao.
-
05-03-2007, 04:58 PM #7209
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
-
05-03-2007, 06:25 PM #7210QJ Gamer Blue
- Registriert seit
- Apr 2007
- Beiträge
- 81
- Points
- 3.525
- Level
- 37
- Downloads
- 0
- Uploads
- 0
How do I make the image flip around. I want the character to face right when right it pushed...
-
05-03-2007, 06:31 PM #7211QJ Gamer Green
- Registriert seit
- Dec 2006
- Ort
- main();
- Beiträge
- 1.071
- Points
- 11.300
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Sprites. Look around, sprite examples are everywhere.
Zitat von yumCOOKIEZZ
-
05-03-2007, 06:37 PM #7212QJ Gamer Blue
- Registriert seit
- Apr 2007
- Beiträge
- 81
- Points
- 3.525
- Level
- 37
- Downloads
- 0
- Uploads
- 0
hmm...so theirs no way I can just flip this single image around the other way?
-
05-03-2007, 06:50 PM #7213Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
no. (not in lua atleast)just make another image, and use a image edting program to mirror your character.
Zitat von yumCOOKIEZZ
--------------------------------------------------------------------------------------
-
05-03-2007, 06:57 PM #7214QJ Gamer Blue
- Registriert seit
- Apr 2007
- Beiträge
- 81
- Points
- 3.525
- Level
- 37
- Downloads
- 0
- Uploads
- 0
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 -.-
-
05-03-2007, 07:07 PM #7215
...theres this magical thing called the GU.
Zitat von Grimfate126
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: youresamFrom Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
--Mike Hollingsworth
-
05-03-2007, 07:31 PM #7216QJ Gamer Blue
- Registriert seit
- Apr 2007
- Beiträge
- 81
- Points
- 3.525
- Level
- 37
- Downloads
- 0
- Uploads
- 0
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..
-
05-03-2007, 07:40 PM #7217Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
i REALLY dont think he's upto that yet, but he may be. i dunno.
Zitat von youresam
--------------------------------------------------------------------------------------
-
05-03-2007, 08:46 PM #7218
Yeah, saves load time and memory. I'll show you how to use it tomorrow.
Zitat von yumCOOKIEZZ
牧来栠摩琠敨映汩獥
PSN: youresamFrom Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
--Mike Hollingsworth
-
05-03-2007, 08:47 PM #7219
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.
Use it like this: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
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.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()
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.
-
05-03-2007, 09:02 PM #7220
Em, it *does* but is oh-my-god slow. Not worth it, it'll cut your FPS in half.
Zitat von Merick
牧来栠摩琠敨映汩獥
PSN: youresamFrom Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
--Mike Hollingsworth
-
05-04-2007, 11:04 AM #7221
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?
-
05-04-2007, 11:30 AM #7222Developer

- Registriert seit
- Oct 2006
- Ort
- San Diego
- Beiträge
- 177
- Points
- 4.205
- Level
- 41
- Downloads
- 0
- Uploads
- 0
This is a function posted on Evilmana and modded slightly by merick
It'll take care of the flipping for you.
Merick: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
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.
-
05-04-2007, 12:16 PM #7223QJ Gamer Blue
- Registriert seit
- Apr 2007
- Beiträge
- 81
- Points
- 3.525
- Level
- 37
- Downloads
- 0
- Uploads
- 0
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 =-
I get errors on the bolded area. I have the function on a different LUA file that is accessed through DoFile.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
Geändert von yumCOOKIEZZ (05-04-2007 um 12:51 PM Uhr) Grund: Automerged Doublepost
-
05-04-2007, 12:58 PM #7224Developer

- Registriert seit
- Oct 2006
- Ort
- San Diego
- Beiträge
- 177
- Points
- 4.205
- Level
- 41
- Downloads
- 0
- Uploads
- 0
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.
-
05-04-2007, 01:12 PM #7225Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
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.
Zitat von emericaska8r
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.
--------------------------------------------------------------------------------------
-
05-04-2007, 01:14 PM #7226QJ Gamer Blue
- Registriert seit
- Apr 2007
- Beiträge
- 81
- Points
- 3.525
- Level
- 37
- Downloads
- 0
- Uploads
- 0
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
-
05-04-2007, 01:43 PM #7227
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
-
05-04-2007, 03:54 PM #7228
ok thanks everyone for the clarification. helped a lot!!!
-
05-04-2007, 04:06 PM #7229QJ Gamer Blue
- Registriert seit
- Apr 2007
- Beiträge
- 81
- Points
- 3.525
- Level
- 37
- Downloads
- 0
- Uploads
- 0
They all disappear. I'll make some experiments and see if I can fix it.
-
05-05-2007, 07:16 AM #7230QJ Gamer Blue
- Registriert seit
- Apr 2007
- Beiträge
- 81
- Points
- 3.525
- Level
- 37
- Downloads
- 0
- Uploads
- 0
Hrm...Still nothing. Whenever I turn right, the entire character disappears...


LinkBack URL
About LinkBacks
Mit Zitat antworten

Hello everyone I am new here and I am glad to be part of this amazing community and I think there...
New to forum