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; Zitat von Savagefreak Could anyone tell me how to print the OS time with a custom TTF font? I have ...
-
09-17-2007, 05:46 PM #8011
See this line that was posted above yours?
Zitat von Savagefreak
math.randomseed(os.time())
Haven't coded lua in a while, but it should work.Code:screen:fontPrint(font_top,210,25,os.time(),black)
-
09-19-2007, 02:05 AM #8012Developer

- Registriert seit
- Oct 2006
- Ort
- San Diego
- Beiträge
- 177
- Points
- 4.205
- Level
- 41
- Downloads
- 0
- Uploads
- 0
Screen Buffer
Does anyone know how to take what is on the screen front buffer and blit it to the back buffer without reblitting all items and without blitting to a storage image first.
What I want to do is,
I know its a wierd request, but it has to do with some userforms I'm developing.Code:screen:blit(x,y,image) screen:blit(x,y,image) screen.flip() screen:blit(0,0,screen)
funny thing is that this process works in windows luaplayer, but not on the psp. Any help would be greatly appreciated. (and this does need to be quick so saving and loading a screen shot would not be a useful technique.)
-
09-19-2007, 07:53 AM #8013Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
why not use a .txt file load it let the user enter the data and use a save button or something
------ 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).
-
09-19-2007, 01:35 PM #8014
I'm not sure what you're asking, but do you want to basically stick two pictures together as one? If so, load the first image. Then, blit the second, but not to the screen, to the other image. I know the C graphics library has it (blitAlphaImagetoImage), but I'm not sure what the Lua function is. You could also modify the Lua source code to make the save image function to save into the RAM.
Zitat von KleptoOne
-
09-20-2007, 01:42 AM #8015Developer

- Registriert seit
- Oct 2006
- Ort
- San Diego
- Beiträge
- 177
- Points
- 4.205
- Level
- 41
- Downloads
- 0
- Uploads
- 0
The lua function is image:blit(x,y,loadedimag e). Thats not what I'm trying to do though. Basically I'm making vba like userforms, and I would like to be able to call them on the fly without worrying about the background. When the form is called, it is stuck within a loop until the user finishes input, so I would like to reblit the already existing front buffer to a temp image and reblit that within my form loop. All I want is to be able to access the front or back buffer in the screen object, but doing a pairs printout of the screen table, it doesn't look like that will be possible, oh well.
Zitat von Judas
-
09-20-2007, 02:43 AM #8016PREMIUM Member
- Registriert seit
- Oct 2005
- Beiträge
- 29
- Points
- 4.816
- Level
- 44
- Downloads
- 0
- Uploads
- 0
Zitat von emericaska8r
No, that one doesn't work, it gives me a crash message. Team Noobz recommended the 1.50 version, which does start. The only problem is it can't find the script file for some reason, as I mentioned above.
-
09-20-2007, 03:52 AM #8017Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
yes it would it would be quite simple
Zitat von KleptoOne
e.g.
Code:make a menu say the third option was a form if pad:cross() and current == 3 then whichever form = true end if whichever form == true then -->form code<-- end

-= Double Post =-
yes it would it would be quite simple
Zitat von KleptoOne
e.g.
Code:make a menu say the third option was a form if pad:cross() and current == 3 then whichever form = true end if whichever form == true then -->form code<-- end
Geändert von FaT3oYCG (09-20-2007 um 04:00 AM Uhr) Grund: Automerged Doublepost
------ 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).
-
09-20-2007, 05:07 AM #8018QJ Gamer Green
- Registriert seit
- Jul 2006
- Ort
- Middle Europe
- Beiträge
- 1.281
- Points
- 11.800
- Level
- 71
- Downloads
- 0
- Uploads
- 0
why
do
you
type
your
code
like
this?[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]
-
09-20-2007, 09:55 AM #8019Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
because
i
find
it
easier
to
understand
in
this
format
is
that
ok
with
you
???------ 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).
-
09-20-2007, 10:33 AM #8020QJ Gamer Green
- Registriert seit
- Jul 2006
- Ort
- Middle Europe
- Beiträge
- 1.281
- Points
- 11.800
- Level
- 71
- Downloads
- 0
- Uploads
- 0
proof that number of lines doesnt mean anything
[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]
-
09-20-2007, 10:46 AM #8021Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
i agree with that but i have not once bragged about how many lines of code anything i have made has
Zitat von myschoo
------ 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).
-
09-20-2007, 04:43 PM #8022Developer

- Registriert seit
- Oct 2006
- Ort
- San Diego
- Beiträge
- 177
- Points
- 4.205
- Level
- 41
- Downloads
- 0
- Uploads
- 0
Using a state system defeats the purpose of creating a vba like form (for my purpose). I'm trying to generalize the process and not make it specific to my application, so that I can load a userform library into whatever application I am working on and have it function the same way each time.
Zitat von FaT3oYCG
Edit
if you've ever worked with vba, it would be the same as creating a dialog window, specifying what type of form you are creating and where you would like it to display within the window. But all of this is irrelevent, all I wanted to know was if there was a quick way to transfer the front buffer to the back buffer, nothing else.
-
09-21-2007, 02:43 PM #8023Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
OK i have a question what i want to do is load a file e.g. a txt file a lua file and put the text on the screen nothing else no movement i can do that myself
basically i can get it to put the text on the screen on different lines but i want it to follow on a line instead of going off the screen
e.g.
if i had a really long line like this one then it would go off the edge of the psp's screen
what i am asking is how would i make it do something
like this does by going onto the next line automatically
but not chopping off bits of words
also
on a different note does anyone know how i would backup the entire flash of my psp by coding it in lua i have used many different ways and none of them seem to workGeändert von FaT3oYCG (09-21-2007 um 03:40 PM Uhr)
------ 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).
-
09-21-2007, 07:53 PM #8024QJ Gamer Bronze

- Registriert seit
- Jul 2006
- Beiträge
- 90
- Points
- 4.912
- Level
- 44
- Downloads
- 0
- Uploads
- 0
Uh...yes you have >_> :
Zitat von FaT3oYCG
Zitat von FaT3oYCG
-
09-21-2007, 08:09 PM #8025lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
lol
PWN'd!
-
09-22-2007, 05:26 AM #8026Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
ok i take that back lol
Zitat von nataku92
anyway
OK i have a question what i want to do is load a file e.g. a txt file a lua file and put the text on the screen nothing else no movement i can do that myself
basically i can get it to put the text on the screen on different lines but i want it to follow on a line instead of going off the screen
e.g.
if i had a really long line like this one then it would go off the edge of the psp's screen
what i am asking is how would i make it do something
like this does by going onto the next line automatically
but not chopping off bits of words
also
on a different note does anyone know how i would backup the entire flash of my psp by coding it in lua i have used many different ways and none of them seem to work
could someone help me with that------ 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).
-
09-22-2007, 07:12 AM #8027lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
Print the text and if the text is going to reach the end of the screen start printing it on the next line.
Simple, or will it take a month to code it? lol
-
09-22-2007, 07:45 AM #8028
You have to figure out how many characters can be put on a line. Then, when the number of characters you are printing gets close to the max number, find the nearest space, and break it off, and start printing on the next line.
-
09-22-2007, 10:49 AM #8029QJ Gamer Green
- Registriert seit
- Jul 2006
- Ort
- Middle Europe
- Beiträge
- 1.281
- Points
- 11.800
- Level
- 71
- Downloads
- 0
- Uploads
- 0
is there function to replace character?
ie. i have string = "hello" and i want to replace all "o" characters wth "0" so it would look like "hell0"
anyone?
edit. nvm got it:
string = string.gsub(string, "o", "0")[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]
-
09-22-2007, 02:39 PM #8030
Does anyone know if you can use switch loops in Lua?
-
09-23-2007, 12:52 AM #8031Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
easily said not so easily done
Zitat von Judas
or does someone want to post some code and completeley rip me again------ 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).
-
09-23-2007, 04:51 AM #8032
Easily said, and easily done. The font is 8 pixels wide, so the screen can hold 60 characters across. Seek to the 60th character in the file. Check to see if it's a space. If it is, print on a new line. If it's not, start seeking backwards checking for spaces. When you find one, break it off there, and print on a new line. If for some reason, you don't find a space, because you have a 61 character long word, insert a hyphen after character 59, and then print on the next line.
Zitat von FaT3oYCG
-
09-23-2007, 06:31 AM #8033QJ Gamer Bronze
- Registriert seit
- Mar 2007
- Beiträge
- 758
- Points
- 8.665
- Level
- 62
- Downloads
- 0
- Uploads
- 0
You mean like switch case statements in C/C++? If that's what you mean, then no.
Zitat von Judas
-
09-23-2007, 08:32 AM #8034QJ Gamer Green
- Registriert seit
- Jul 2006
- Ort
- Middle Europe
- Beiträge
- 1.281
- Points
- 11.800
- Level
- 71
- Downloads
- 0
- Uploads
- 0
hmm when i use function file:read(), it only reads 1st line from the file.. is that ok? o_O
[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]
-
09-23-2007, 09:03 AM #8035lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
But the problem is he dont know how to do that.
Zitat von Judas
-
09-23-2007, 09:55 AM #8036QJ Gamer Green
- Registriert seit
- Jul 2006
- Ort
- Middle Europe
- Beiträge
- 1.281
- Points
- 11.800
- Level
- 71
- Downloads
- 0
- Uploads
- 0
yeah lol exactly...
but it just takes few string manipulations...[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]
-
09-23-2007, 04:28 PM #8037
Then he's not a very good coder. That's fairly simple to do.
Zitat von Anti-QuickJay
Anyway, I found the answer to my other question on switch-case loops. Here's the documentation in case anyone else wants it.
http://lua-users.org/wiki/SwitchStatement
-
09-23-2007, 06:54 PM #8038
Lua doesn't have switch/select case, but you can rig an approximation using a table of functions (pseudocode):
Zitat von Judas
*edit*Code:select = {} function select.case1() code... end function select.case2() code... end function select.case3() code... end case = "case1" select[case]()
lol, you beat me to it..
myschoo, file:read("*a") will put the entire text of the file into a single variable.
alternately, you can use this to read each line from the file into a table:
note: io.lines will automatically open the file for reading and then close it once the entire file has been readCode:data = {} for line in io.lines(filename) do table.insert(data, line) end
file:lines() will do the same thing for an already opened file, and will keep the file open after it's been read
-
09-24-2007, 08:56 AM #8039QJ Gamer Green
- Registriert seit
- Jul 2006
- Ort
- Middle Europe
- Beiträge
- 1.281
- Points
- 11.800
- Level
- 71
- Downloads
- 0
- Uploads
- 0
merick: i know io.lines but i didnt want to use it. thx 4 answer
[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]
-
09-25-2007, 06:40 AM #8040QJ Gamer Green
- Registriert seit
- Jul 2006
- Ort
- Middle Europe
- Beiträge
- 1.281
- Points
- 11.800
- Level
- 71
- Downloads
- 0
- Uploads
- 0
merick: umm ... *a doesnt work... tried a and a+ and that didnt help
[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]


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