| |||||||
| Register | Top Posters | FAQ | PSP Downloads | Arcade | Wallpapers | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
![]() |
| | LinkBack (1) | Thread Tools |
| |
#1 (permalink)
|
| GamingCrazy Semi-Addict ![]() ![]() Join Date: Jul 2005 Location: You are Here ---> Status: Backup Provider Thanked: 35 Times in 2 Posts Age: 17
Posts: 648
Credits: 803 | Lua Programming Tutorials LUA PROGRAMMING LINKS! These links will help you discover more about the world of lua, Once you finish PSPCrazy's Lua Tutorials you may be seeking more knowledge around lua so i have provided the following links until i finish the rest of this tutorials .[Only registered and activated users can see links. ] and [Only registered and activated users can see links. ] LUA PLAYER PROGRAMMING TUTORIALS! I thought it would help to get pspcrazy more involved with coding in Lua . As many others have been asking "howdo i code in lua?" or "How do i make my own game?" .Well we will start off with hello world! This is a simple app in lua that will display the text "Hello World" Until you exit back to the XMB or Turn of your psp .1 - Getting Started Now to start off we need to create some space for your projects.So create a new folder anywhere on your PC named "Projects" or anything you would remember where you are going to store your projects .When you have that done create an "EMPTY" Text document, open the text document in your favorite Word/Text editor program. Now this is where we are gonna start coding your first project in Lua "HELLO WORLD!" (finally lol). 2 - Coding Your First Simple App Okay, now we want to tell your program what color to load for the text to display on your PSP, so insert this into your empty text document: Code: white = Color.new(255, 255, 255) well "white = Color.new" is telling your program that Color.new is gonna be named "white". The "(255, 255, 255)" is telling your program where the specific RGB is located. Here is what the "," stands for: -(000, 000, 000)- RED, GREEN, BLUE You can find the color you want by opening any paint editor and changing the RGB like so > ![]() So now that we know how to load the color we will want to keep the the program in a loop! If we didn't have our program in a loop it would skip past the text we told it to display within miliseconds! So now we are going to make a "LOOP" also known as "While true do" .So put this in our code: Code: while true do is exited or given a command to stop!. [NOTE:] The "while true do loop" will also loop any other given command like screen:blit(). So now that we have our "while true do" we will want to display the text "Hello World" (Finally). This is quite easy and the text can be changed to your liking too! So insert this into your code: Code: screen:print(5, 5, "Hello World by c5cha7",white) around "Hello World by c5cha7", well thats where you can insert any text that you want it to display. The 5, 5, is where the text will be printed on your PSP screen. The first 5, is known as X and the second 5, is usually known as Y. This isn't complicated one bit, just open paint and look at the bottom right hand side and you'll see this when you move your cursor in paint itwill display different numbers based on where you are located on screen! Now then, we want to keep our text printed properly on the screen with no "hiccups" at all! So we are going to insert this into our code Code: screen.waitVblankStart() It can hold more functions but i highly doubt we will need any extra functions for it as of yet! So if you've made it this far then please pat yourself on the back because my grammer is not the best lol. Now moving on! We still have to refresh the screen and keep it updated. If we don't have this code in our program it wouldn't display the text at all. It is known to set the offscreen buffer to make your screen call's visible (sorry but i aint good at explaining stuff lol). So we are going to insert this next line of code into your program: Code: screen.flip() to this one! We can tell the screen.flip to refresh every so often. But we dont need to do that just yet. Moving on! You remeber the "While true do" loop we inserted into our small app before? Well we haven't quite finished that function yet! Now that we have put all of our code in the "while true do" function/loop, we will need to tell it that this is the end of our code. So this is the last line of code we are going to put in. Please insert this into your code at the end: Code: end confusing, but thats for C Programmers! Now then your code should look like the following: Code: white = Color.new(255, 255, 255) while true do screen:print(5, 5, "Hello World by c5cha7",white) screen.waitVblankStart() screen.flip() end Should display as the following: ![]() So download Lua player from [Only registered and activated users can see links. ] and install Lua Player on you PSP in "PSP/GAME/" Then open "PSP/GAME/LUAPLAYER/" and insert your text document there! Rename your text document to index.lua and startup luaplayer on your psp. More tutorials coming soon! Including grammer check lol... Sorry about the real bad English but i will correct it soon! 3 - Blitting Image's Okay, now that you have learn't the basic's of the text function forLua i bet you want to do more? Yes really? lol! Okay this tutorial will teach you how to blit an image to your screen! As once again i ain't too good with my grammer and spelling so please ask any questions if you are stuck! Follow [1 - Getting Started] and create a new folder named "Blitting Images" now create a new text document in the folder you have just made. First of all open the new text document with your favorite text editor. Now then, lets get started shall we? This time we want to load the image so we put this in our new text document! Code: background = Image.load("background.png") it that Image.load is now called background! ("background.png") is where the background is located on your PSP . (note that it is located in the same folder where the script is!) Now then we have just learn't how to load our image! Then what we want to do is put our image in a "LOOP" again! Just like the "Hello World" Tutorial we will have to insert this into our code! So make sure you insert the following: Code: while true do looping or as i like to say blitted on-screen. Okay heres the fun part (or maybe not)... We next want to blit our image to screen! So when we told "background = Image.load" we will be calling the background. So make sure you insert this into your code: Code: screen:blit(0, 0, background) thats because they are both calling the screen. The 0, 0, is once again the same as the screen:prints 0, 0, ! All that it does is tells the PSP where to place the image (See simple!). Now then you remember we told background = Image.load ? Well thats why our code has background in the end of it. So our code activates the background and our background activates the image in which we told it to load! Please don't get confused yet with me lol. Now we do the same as the "Hello World" tutorial again! Remeber when we used the screen.waitVblankStart() screen.flip() functions? Well we will be using them once again. You should already know what they are for, so if you don't please learn the "Hello World" Tutorial! Okay, then please insert this into your code! Code: screen.waitVblankStart() screen.flip() that this is the end of our code! So insert this into your script: Code: end Jpeg/JPG/PNG images at the moment! Your following code should look like this: Code: background = Image.load("background.png")
while true do
screen:blit(0,0, background)
screen.waitVblankStart()
screen.flip()
end
(Depending on what image you choose to load!) ![]()
__________________ http://i17.photobucket.com/albums/b58/c5cha7/sig-1.png My Wallpapers Full Version! - Flashmod V2.60 Lua Programming Tutorials Last edited by c5cha7; 06-21-2006 at 04:31 PM. |
| | |
| Sponsored Links | |
| | |
| | #3 (permalink) |
| GamingCrazy Semi-Addict ![]() ![]() Join Date: Jul 2005 Location: You are Here ---> Status: Backup Provider Thanked: 35 Times in 2 Posts Age: 17
Posts: 648
Credits: 803 | Re: Lua Programming Tutorials Reserved for More Tutorials! Please check back soon and feel free to ask questions or ask for help . |
| | |
| | #5 (permalink) | |
| GamingCrazy Semi-Addict ![]() ![]() Join Date: Jul 2005 Location: You are Here ---> Status: Backup Provider Thanked: 35 Times in 2 Posts Age: 17
Posts: 648
Credits: 803 | Re: Lua Programming Tutorials Quote:
.Updating them soon! Also adding more tutorials on how to create your own game etc... ![]() | |
| | |
| | #7 (permalink) |
| GamingCrazy Semi-Addict ![]() ![]() Join Date: Jul 2005 Location: You are Here ---> Status: Backup Provider Thanked: 35 Times in 2 Posts Age: 17
Posts: 648
Credits: 803 | Re: Lua Programming Tutorials Image Blitting Added !Have fun and hopefully more coming soon! Would it be possible to sticky this thread? unless a mod is gonna create there own lua programming tutorials thread? Just wondering! Also to the mod's of pspcrazy! Please feel free change some stuff and add spelling checks etc. I did this tutorial specially for pspcrazy so dont claim it for your own site if . |
| | |
| | #9 (permalink) | |
| GamingCrazy Semi-Addict ![]() ![]() Join Date: Jul 2005 Location: You are Here ---> Status: Backup Provider Thanked: 35 Times in 2 Posts Age: 17
Posts: 648
Credits: 803 | Re: Lua Programming Tutorials Quote:
I did some grammer checks too! Also thanks for deleting the double post lol! Thanks again! your da man . | |
| | |
![]() |
|
LinkBacks (?)
LinkBack to this Thread: http://www.pspcrazy.com/forums/psp-homebrew-discussion/46886-lua-programming-tutorials.html | ||||
| Posted By | For | Type | Date | |
| Как се пише homebrew? - PSP-Bulgaria Forums | This thread | Refback | 10-01-2007 06:54 PM | |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |