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; im almost finished my little app and i fixed my problems no thanks to you guys :Argh: haha no hard ...
-
08-25-2007, 12:11 AM #7951QJ Gamer Bronze

- Registriert seit
- Aug 2007
- Ort
- Australia
- Beiträge
- 659
- Points
- 8.045
- Level
- 60
- Downloads
- 0
- Uploads
- 0
im almost finished my little app and i fixed my problems no thanks to you guys :Argh: haha no hard feelings, i know i do seem like a noob but i do have a pretty good understanding of lua. just one question. when i overwrite a file in the flash it cuts the file from the memory stick instead of copying it. anyway to make it copy instead? thanks
-
08-25-2007, 01:04 AM #7952QJ Gamer Green
- Registriert seit
- Jul 2006
- Ort
- Middle Europe
- Beiträge
- 1.281
- Points
- 11.800
- Level
- 71
- Downloads
- 0
- Uploads
- 0
Code:System.writeFile("path:/to/file","path:/to/destination", delete source file? "yes" or "no")[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]
-
08-25-2007, 01:26 AM #7953QJ Gamer Bronze

- Registriert seit
- Aug 2007
- Ort
- Australia
- Beiträge
- 659
- Points
- 8.045
- Level
- 60
- Downloads
- 0
- Uploads
- 0
haha it was write underneath my nose, i thought that meant overwrite if a file of the asme name is present. thanks myshoo
-
08-25-2007, 06:48 PM #7954lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
Depends. Some people can understand C/C++ better then Lua.
Zitat von EminentJonFrost
-
08-26-2007, 04:34 PM #7955QJ Gamer Blue
- Registriert seit
- Jan 2007
- Ort
- U.S.
- Beiträge
- 405
- Points
- 7.014
- Level
- 55
- Downloads
- 0
- Uploads
- 0
Compiling my lua script will help improve speed, correct? If so, what should I use to compile it? I've tried the XtreamLua Compiler with no luck.
EDIT: Nevermind, I got the XtreamLua Compiler to work.Geändert von andyauff (08-26-2007 um 05:19 PM Uhr)
-
08-26-2007, 06:59 PM #7956Developer

- Registriert seit
- Jul 2006
- Beiträge
- 205
- Points
- 4.318
- Level
- 41
- Downloads
- 0
- Uploads
- 0
I did not "try" to fix it for you, because that's not a good way to help people. I was pointing out what was wrong. You moved your character (Exhibit A), then you set the "old" x and y positions to the current x and y positions (Exhibit B), and then checked for collision (Exhibit C). When the objects collide, you move the current x and y back to the old x and y, which - guess what - is exactly the same, thanks to your second step. So, like I said the first time, think about the order in which you do things.
Zitat von Xsjado7
No, it doesn't improve execution speed. I think if you compile a file that you want to include with dofile or loadfile, then it speeds up the loading process, but if I recall correctly, that's the only speed benefit. Your best bet right now is to optimize your code. Once Luaplayer 0.21 is released though, the execution speed will be considerably better.
Zitat von andyauff
-
08-26-2007, 10:29 PM #7957QJ Gamer Blue
- Registriert seit
- Jan 2007
- Ort
- U.S.
- Beiträge
- 405
- Points
- 7.014
- Level
- 55
- Downloads
- 0
- Uploads
- 0
I see. Thanks.
Zitat von LMelior
-
08-27-2007, 12:26 AM #7958
Wlan
Hi guys, did anyone have any joy trying to use WLAN on Lua Player 0.20?
I've been trying to access a file on my server to get some specific data for a HB I'm developing at the moment, but it just hangs. I've found lots of workaround, but none of them seem to work.
I even thought I was doing something wrong, so I tried to run the WLAN code from the sample, which looks pretty much like what I developed, but it just hangs too.
Did anyone get this sample to work?
Cheers,
Marcos Placona
-
08-27-2007, 01:05 PM #7959Developer

- Registriert seit
- Oct 2006
- Ort
- San Diego
- Beiträge
- 177
- Points
- 4.205
- Level
- 41
- Downloads
- 0
- Uploads
- 0
Are you overclocking your psp? you have to keep the processor at default settings if you want to use wlan.
Zitat von placo23
-
08-27-2007, 01:48 PM #7960
I've changed everything, but it still doesn't work. I've changed my clock to default, changed Wlan.useConnectionConfig( 1) to Wlan.useConnectionConfig( 2), changed the hard reset to enabled and nothing.
Does WLAN hava any problem with WPA?
cheers
-
08-28-2007, 12:58 PM #7961Developer 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 think it only has basic encryption in lua so i think it might have problems 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).
-
08-28-2007, 01:18 PM #7962lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
I believe it doesn't work with WPA. Because I was able to use WLAN on lua player .20.
-
08-29-2007, 12:31 AM #7963
Configuration file (config.txt) and coroutines
Hi,
I wanted to know if you were able to use a configuration file in LUA (i know in C it works) and how I could make one. Also I need some help with coroutines, what they are and do.
-sony_psp_player
-
08-29-2007, 12:56 AM #7964QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
you mean a text file meant for the user to change settings on the comp? yea you can do that.
Zitat von sony psp player
-
08-29-2007, 01:07 AM #7965
Change on computer and from PSP so it can save the current state of the app.
Zitat von EminentJonFrost
-
08-29-2007, 01:17 AM #7966
Yes, you can use config files normally. I use'em all the time.
Just incluide your config file to you script.
cheers
-
08-29-2007, 01:24 AM #7967
I've looked on google now (may should have done before) and i found this: for line in file:lines.
They said this function will iterate all over the file but it doesn't. It returnes every second line.
-
08-29-2007, 01:46 AM #7968
Ok, what are you trying to do? You don't need to read the file. If you want a config file, you can just set your variables into that file, and read the variables normally, as if it was an include. Know, if you wanna read specific bits of this file, you'll need to read it and iterate over the lines.
Zitat von sony psp player
I don't have code samples here, but I can send'em to you later today.
Cheers
-
08-29-2007, 01:56 AM #7969
No, I need to set the variables, too.
Zitat von placo23
-
08-29-2007, 02:04 AM #7970
So it's easy. Just set whatever you need to set, and read'em
Zitat von sony psp player
I think it's pretty straight forward. Unless I'm not getting your point here.
Do you wanna send me some piece of code telling exactly what you wanna do?
Cheers
-
08-29-2007, 02:42 AM #7971
Here is a detailed description of my problems:
Zitat von placo23
I want to save some information about the user, the position... in a file called "config.txt" so here are my problems:
1. for line in file:lines doesn't iterate all over the file, it reads only every second line.
2. i don't know how to add a new line to the file
-
08-29-2007, 03:23 AM #7972
Here's an example:
That should open the file and iterate over all the lines.Code:file = io.open("myFile.txt", "r") if file then for line in file:lines() do value = string.find(line, "userStatus=") if value then return value end end else screen:print(100,100,"Error opening file!",color) end
As per the append new line thingy, you can use
Which will open the file in append mode.Code:io.open (filename, "a")
Check the Lua Manual for more information
Hope it helps you.
Cheers
-
08-29-2007, 03:32 AM #7973
Here's an example:
That should open the file and iterate over all the lines.Code:file = io.open("myFile.txt", "r") if file then for line in file:lines() do value = string.find(line, "userStatus=") if value then return value end end else screen:print(100,100,"Error opening file!",color) end
As per the append new line thingy, you can use
Which will open the file in append mode.Code:io.open (filename, "a")
Check the Lua Manual for more information
Hope it helps you.
Cheers
-
08-29-2007, 04:17 AM #7974QJ Gamer Green
- Registriert seit
- Jul 2006
- Ort
- Middle Europe
- Beiträge
- 1.281
- Points
- 11.800
- Level
- 71
- Downloads
- 0
- Uploads
- 0
or you can use dofile
[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]
-
08-29-2007, 04:35 AM #7975
That will do too, but it ain't let him append to the file.
Zitat von myschoo
Cheers
-
08-29-2007, 04:47 AM #7976
Thanks for the example! The for line in file:lines returns only every second line still, but i can leave the lines that are not returned out. Thanks!
Zitat von placo23
-
08-29-2007, 04:49 AM #7977
That's weird, 'cause I just tested here, and it returns me the whole file.
Zitat von sony psp player
Well glad that you found out a way around to that.
Cheers
-
08-29-2007, 10:22 AM #7978Banned for LIFE
- Registriert seit
- Oct 2006
- Ort
- East London, England
- Beiträge
- 2
- Points
- 18.744
- Level
- 86
- Downloads
- 0
- Uploads
- 0
How would i go about pausing my main loop when start is pressed ?
-
08-29-2007, 10:25 AM #7979QJ Gamer Blue
- Registriert seit
- Jul 2007
- Beiträge
- 296
- Points
- 3.795
- Level
- 38
- Downloads
- 0
- Uploads
- 0
Generally, you should check for error, rather than success. It makes for neater, and easier to read code.
Zitat von placo23
-
08-29-2007, 10:32 AM #7980
Zitat von eldiablov
Code:if pad:start() then oldpad = pad while true do pad = Controls.read() if pad:start() and not oldpad:start() then break end oldpad = pad end end


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