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; thx anyways, ya was playing around with some of the code and it worked. now just have a diff question. ...
-
01-14-2009, 03:07 PM #9661QJ Gamer Bronze
- Registriert seit
- Dec 2005
- Beiträge
- 20
- Points
- 4.297
- Level
- 41
- Downloads
- 0
- Uploads
- 0
thx anyways, ya was playing around with some of the code and it worked. now just have a diff question.
|
|
|
\/
does anyone know how to extract a number from a string?
Geändert von icemasta (01-14-2009 um 05:18 PM Uhr)
-
01-14-2009, 03:39 PM #9662Look at my user title :p
- Registriert seit
- Feb 2006
- Ort
- Texas
- Beiträge
- 1.183
- Points
- 14.103
- Level
- 77
- Downloads
- 0
- Uploads
- 0
im no expert, but if you typed the code like you did above then your problem is that you have your function inside a table. the format should be:
so you would make it:Code:function functionName()
if thats what you want your function named. hope tht helpsCode:function collision(obj1,obj2)
Lol you fixed it just as i posted sucks
**********, ********** :p
http://img143.imageshack.us/img143/6...boysfanij8.gif
-
01-14-2009, 05:38 PM #9663QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
edit: oops thought this was c/c++ help thread, none of my answers would help
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
-
01-15-2009, 06:14 AM #9664QJ Gamer Green
- Registriert seit
- Jan 2008
- Beiträge
- 612
- Points
- 3.721
- Level
- 38
- Downloads
- 0
- Uploads
- 0
use string.find and string.sub
read this and don't post until you have read it and learned how the functions worked and tried to figure it out[size=3][url=http://luaplayer.org/forums/index.php?topic=507]Complete Lua development cycle outline[/url][/size]
-
01-15-2009, 02:25 PM #9665Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
also seen as you are extracting a number from a string you may want to take a look at the tonumber() function, as it would be held as a string because that is what you are extracting it from.
------ 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).
-
01-15-2009, 05:11 PM #9666QJ Gamer Green
- Registriert seit
- Jan 2008
- Beiträge
- 612
- Points
- 3.721
- Level
- 38
- Downloads
- 0
- Uploads
- 0
if he uses the string as if it were a number, lua will generally autoconvert it - generally tostring is the only casting function ever needed in lua.
[size=3][url=http://luaplayer.org/forums/index.php?topic=507]Complete Lua development cycle outline[/url][/size]
-
01-18-2009, 12:34 PM #9667Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
didnt know that, do now thanks for lettin me know i have never come across that situation, but yeah i was just using logic but if its not needed then what the hey.
------ 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).
-
01-18-2009, 12:51 PM #9668Look at my user title :p
- Registriert seit
- Feb 2006
- Ort
- Texas
- Beiträge
- 1.183
- Points
- 14.103
- Level
- 77
- Downloads
- 0
- Uploads
- 0
nvm found one
**********, ********** :p
http://img143.imageshack.us/img143/6...boysfanij8.gif
-
01-18-2009, 11:51 PM #9669
Achievements:
- Registriert seit
- Jan 2009
- Beiträge
- 5
- Points
- 2.005
- Level
- 27
- Downloads
- 0
- Uploads
- 0
having probs
i have a couple questions..
i have this code setup inside of the while loop to exit the game when i want by simply changing the variable Quit to true. It doesnt seem to work. It just freezes the psp.
if Quit == true then
os.exit()
end
also, when i am writing a game and a map editor, and it seems when i go back and forth between the 2 i sometimes get errors like not enough memory or something along those lines. My question is.. Is there a way to clear all the memory from the last .lua you were running so you can start fresh with the new file. Im really new to programming in general and im not sure how im supposed to do everything. learning by trial and error. so i appreciate the help.
thnx in advance.
-
01-19-2009, 12:56 PM #9670QJ Gamer Green
- Registriert seit
- Jan 2008
- Beiträge
- 612
- Points
- 3.721
- Level
- 38
- Downloads
- 0
- Uploads
- 0
1. os.exit doesn't and never really has worked
2. just manage your memory carefully, use tables and local vars, etc - you really shouldn't ever be running out of memory unless there's something drastic that is being overlooked[size=3][url=http://luaplayer.org/forums/index.php?topic=507]Complete Lua development cycle outline[/url][/size]
-
01-24-2009, 11:18 AM #9671QJ Gamer Green
- Registriert seit
- Jul 2008
- Ort
- In your pocket.
- Beiträge
- 192
- Points
- 5.875
- Level
- 49
- My Mood
-
- Downloads
- 0
- Uploads
- 0
I need some tuts for PgeLua if anyone can post some links I would be greatful. ^^
AIM: Digikid91 | PSN: Digikid13 | GaiaOnline: Digikid13
-
01-24-2009, 12:21 PM #9672QJ Gamer Green
- Registriert seit
- Jan 2008
- Beiträge
- 612
- Points
- 3.721
- Level
- 38
- Downloads
- 0
- Uploads
- 0
read my signature
[size=3][url=http://luaplayer.org/forums/index.php?topic=507]Complete Lua development cycle outline[/url][/size]
-
01-25-2009, 04:43 PM #9673QJ Gamer Green
- Registriert seit
- Jul 2008
- Ort
- In your pocket.
- Beiträge
- 192
- Points
- 5.875
- Level
- 49
- My Mood
-
- Downloads
- 0
- Uploads
- 0
-
01-25-2009, 04:47 PM #9674QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
umm...alot,
swizzle an image allows for the image to be drawn faster, however it does make it harder to modify the image data.
where's loading an image is simple that, loading an image into ram.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
-
01-25-2009, 05:06 PM #9675QJ Gamer Green
- Registriert seit
- Jul 2008
- Ort
- In your pocket.
- Beiträge
- 192
- Points
- 5.875
- Level
- 49
- My Mood
-
- Downloads
- 0
- Uploads
- 0
OK that is good for when I don't need to change an image, but how do I use the image.
Code:mypicture = pge.texture.load("test.png") --This returns a pointer to the image data. swpicture = pge.texture.swizzle("test.png") --This just returns true or false (maybe 0 or 1).AIM: Digikid91 | PSN: Digikid13 | GaiaOnline: Digikid13
-
01-25-2009, 07:48 PM #9676QJ Gamer Bronze
- Registriert seit
- Aug 2007
- Ort
- Everywhere
- Beiträge
- 206
- Points
- 5.826
- Level
- 49
- Downloads
- 0
- Uploads
- 0
When you load an image, it automatically swizzles it...
You usually don't need to unless you un-swizzled it, to change the alpha, color, or some pixels.
To use the image, depends on how you want to use it.object = pge.texture.load(filename , [memorylocation], [swizzle])
Parameters:
filename - The name of the PNG image to load.
memorylocation - Optional argument. Either PGE_RAM to load to RAM or PGE_VRAM to load to VRAM. Defaults to PGE_RAM if omitted.
swizzle - Optional argument. A boolean representing whether to swizzle the texture or not. Defaults to true if omitted.
To print it onto the screen :
pge.texture.draweasy(text ure, x, y, [rotation], [alpha])
or
pge.texture.draw(texture, x, y, [width], [height], [texstartx], [texstarty], [texendx], [texendy], [rotation], [alpha])
http://lmgtfy.com/?q=pge+lua+documentation
-
01-26-2009, 01:08 PM #9677
Achievements:
- Registriert seit
- Jan 2009
- Beiträge
- 5
- Points
- 2.005
- Level
- 27
- Downloads
- 0
- Uploads
- 0
summo questions
is there a way to encrypt lua or whatever it is called to hide your source code?
i want to
PGE how much better then regular lua player for psp? i think they are on .20.
would it be worth me moving from lua.20 to using pge?
ill release something for you guys to play as soon as i can find a way to hide the code. I will probably go open source later, but for now its our baby(working with another) and id like to see it through first.
so far we have some basic physics done like Mario(im using those gfx for now)
Sidescroller.
Mario physics include.
run/jump/crouch/climb
theres some makeshift monster code in with a lil ai.
i also have a map editor made with some basic features.
add/delete tile
change tile attributes (visible/collision/kill/rope/warp)
you can save to a user specified name.
anyway..... all of this done using lua player 0.20. is PGE worth moving ny project? Ive been using lplayer and have been running into issues with the psp slowing down. Im sure its my sloppy code but to an extent. Is there any significant speed boost that i can get from pge?
anywho thnx in advance, ill try and release some beta version soon.
-
01-26-2009, 03:51 PM #9678QJ Gamer Green
- Registriert seit
- Jan 2008
- Beiträge
- 612
- Points
- 3.721
- Level
- 38
- Downloads
- 0
- Uploads
- 0
-
01-26-2009, 04:33 PM #9679QJ Gamer Green
- Registriert seit
- Jul 2008
- Ort
- In your pocket.
- Beiträge
- 192
- Points
- 5.875
- Level
- 49
- My Mood
-
- Downloads
- 0
- Uploads
- 0
@TurtlesPwn
Hmmm what can I say.....
@SectionEight
Ya it should give you a great boost, PGELUA is made from scrap so everything is made for speed, everything is alot faster.
Here is the Benchmark.
I think it is very well worth it, and as far as I know you can't encrypt lua code.......although if you find anything out plz PM me.Geändert von Digikid13 (01-26-2009 um 04:48 PM Uhr) Grund: Adding Info.
AIM: Digikid91 | PSN: Digikid13 | GaiaOnline: Digikid13
-
01-26-2009, 08:26 PM #9680QJ Gamer Bronze
- Registriert seit
- Aug 2007
- Ort
- Everywhere
- Beiträge
- 206
- Points
- 5.826
- Level
- 49
- Downloads
- 0
- Uploads
- 0
Protecting or Encrypting Lua/PGE code : http://luaplayer.org/forums/index.php?topic=471.0
-
01-26-2009, 09:17 PM #9681QJ Gamer Green
- Registriert seit
- Jan 2008
- Beiträge
- 612
- Points
- 3.721
- Level
- 38
- Downloads
- 0
- Uploads
- 0
-
01-27-2009, 03:58 PM #9682QJ Gamer Green
- Registriert seit
- Jul 2008
- Ort
- In your pocket.
- Beiträge
- 192
- Points
- 5.875
- Level
- 49
- My Mood
-
- Downloads
- 0
- Uploads
- 0
-
01-27-2009, 05:42 PM #9683QJ Gamer Green
- Registriert seit
- Jan 2008
- Beiträge
- 612
- Points
- 3.721
- Level
- 38
- Downloads
- 0
- Uploads
- 0
Did you look on lua.org?
[size=3][url=http://luaplayer.org/forums/index.php?topic=507]Complete Lua development cycle outline[/url][/size]
-
01-28-2009, 11:14 AM #9684QJ Gamer Green
- Registriert seit
- Jul 2008
- Ort
- In your pocket.
- Beiträge
- 192
- Points
- 5.875
- Level
- 49
- My Mood
-
- Downloads
- 0
- Uploads
- 0
-
01-28-2009, 03:41 PM #9685
Achievements:
- Registriert seit
- Jan 2009
- Beiträge
- 5
- Points
- 2.005
- Level
- 27
- Downloads
- 0
- Uploads
- 0
Im not familiar with pgelua, can someone who has worked with regular luaplayer and pge know if it may be possible to write out a script to maybe convert luaplayer files to pge compatible files.
Im aware that pge will have more functions, but id much rather look through an already converted lua file looking for ways to optimize my code, then it would be for me to totally rewrite the program.
I always seem to have trouble describing what i mean, please lemme know if i made my self clear hehe.
-
01-28-2009, 06:23 PM #9686QJ Gamer Green
- Registriert seit
- Jan 2008
- Beiträge
- 612
- Points
- 3.721
- Level
- 38
- Downloads
- 0
- Uploads
- 0
You have a terrible misconception on the difference between Lua and Luaplayer etc. Read more, it helps. And did you even click on my link?
sectioneight - while it would be possible, it would not be practical or take advantage of PGE's capabilities. I would recommend looking at PGE's samples and programs written with it and just relearning rather than trying to base off LP's API.[size=3][url=http://luaplayer.org/forums/index.php?topic=507]Complete Lua development cycle outline[/url][/size]
-
01-28-2009, 11:07 PM #9687
Achievements:
- Registriert seit
- Jan 2009
- Beiträge
- 5
- Points
- 2.005
- Level
- 27
- Downloads
- 0
- Uploads
- 0
yeh ive read over the documentation that they have up and it seems like it would help me out alot, just on the gfx rendering stuff alone. the problem is i am far along in my project and it would sux majorly if i were to have to rewrite everything all over again. I guess im looking for an easy answer where there is none. The advantage would be a speed boost but in order to do that i am going to have to completely rewrite the code. There's no windows pge luaplayer and that would mean i lose my partner. I think ill just wait till they release a windows player .
-
01-29-2009, 12:00 PM #9688QJ Gamer Bronze
- Registriert seit
- Aug 2007
- Ort
- Everywhere
- Beiträge
- 206
- Points
- 5.826
- Level
- 49
- Downloads
- 0
- Uploads
- 0
It's not too hard to switch over to PGE. I did it while in mid project in about 3 hours.
Basically, you only need to rewrite the drawing functions, and texture handling.
Everything else is pretty much fine. PGE has it's own math functions, but Lua's are still there if you don't want to bother.
All I did was look at what the PGE's functions were for drawing and setting up the screen, "find and replace"'d the code, and a bit more tweaking, and I had it done.
Once you get used to, and learn OOP then it's all basically the same.
-
02-26-2009, 07:37 AM #9689
Achievements:
- Registriert seit
- Feb 2009
- Beiträge
- 17
- Points
- 1.973
- Level
- 26
- Downloads
- 0
- Uploads
- 0
Hi guys
I bet this is asked so many times before, but how do you get flash0 access with lua?
This is a small piece of a simple menu with different options, including copying files to flash1.
What do i have to change to make this work with flash0???Code:if pad:cross() and not oldpad:cross() and ms == 1 then System.removeFile("flash1:/new/test.txt") end if pad:cross() and not oldpad:cross() and ms == 2 then afbeelding1 = Image.load("vc.png") screen:blit(0, 0, afbeelding1, false) screen.flip() screen.waitVblankStart(300) end if pad:cross() and not oldpad:cross() and ms == 3 then direxsist = System.doesDirExist("flash1:/new") if direxsist == 1 then else System.createDirectory("flash1:/new") screen.flip() end curdir = System.currentDirectory() filexist = System.doesFileExist("flash1:/new/test.txt") if filexist == 1 then System.removeFile("flash1:/new/test.txt") screen.flip() end System.copyFile(curdir.."/test1.txt","flash1:/new/test1.txt",0) screen.flip() end
tnx
-
02-26-2009, 04:07 PM #9690lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
SG57 made a LuaPlayer with flash write access.
You have to search for it. I remember you had to assign something to something then write a file to flash0.


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