i think it only has basic encryption in lua so i think it might have problems with that
Printable View
i think it only has basic encryption in lua so i think it might have problems with that
I believe it doesn't work with WPA. Because I was able to use WLAN on lua player .20.
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
you mean a text file meant for the user to change settings on the comp? yea you can do that.Zitat:
Zitat von sony psp player
Change on computer and from PSP so it can save the current state of the app.Zitat:
Zitat von EminentJonFrost
Yes, you can use config files normally. I use'em all the time.
Just incluide your config file to you script.
cheers
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.
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:
Zitat von sony psp player
I don't have code samples here, but I can send'em to you later today.
Cheers
No, I need to set the variables, too.Zitat:
Zitat von placo23
So it's easy. Just set whatever you need to set, and read'em :PC:Zitat:
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
Here is a detailed description of my problems:Zitat:
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
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
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
or you can use dofile
That will do too, but it ain't let him append to the file.Zitat:
Zitat von myschoo
Cheers
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:
Zitat von placo23
That's weird, 'cause I just tested here, and it returns me the whole file.Zitat:
Zitat von sony psp player
Well glad that you found out a way around to that.
Cheers
How would i go about pausing my main loop when start is pressed ?
Generally, you should check for error, rather than success. It makes for neater, and easier to read code.Zitat:
Zitat von placo23
Zitat:
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
thats lovely thank you.Zitat:
Zitat von sony psp player
I'd rather do it like this:Zitat:
Zitat von eldiablov
That way you don't need to check with the IF every timeCode:while not Controls.read():start() do
screen:flip()
screen.waitVblankStart()
end
Cheers
sony_psp_player the pausing function works fine but it wont unpause :p
oh wait ill try placos way
-= Double Post =-
ok the pause function is working but how would i release a script from the memory ?
that wont work. you used a while loop, so he'll have to press start to update each frame. use an if statement instead:Zitat:
Zitat von placo23
or better yet, make a state system.Code:if not pad:start() then
screen:flip()
screen.waitVblankStart()
end
Course it works. I use it all the time. Anyways.. that's just another way to do it.Zitat:
Zitat von Grimfate126
Cheers
HHHHHHEEEEELLLPPPPPPPP
ok im no noob to lua but i cant get the keyboard intergration to work properly it chucks out an error every time i try to run it and i have just used sg57's example
here is the code
it is slightly modded but not so that it wouldnt work
any ideas maybee the example has an old function or something anyway
thanks in advance if you can helpCode:White = Color.new(255, 255, 255)
Controls.IRkeyboardInit()
string = ""
shift = 0
oldpad = Controls.read()
while true do
pad = Controls.read()
screen:clear()
string = string .. Controls.IRKeyboardGetKey(shift)
screen:print(10, 10, string, White)
if
Controls.read():start()
then
break
end
screen.waitVblankStart()
screen.flip()
end
I have no experience with IR keyboards, but wouldn't Controls.IRKeyboardGetKey (shift) be a boolean(true or false) value?
i'm guessing so Nielkie, seems logical
but i dont know reallyZitat:
if pad:start() then
end
if Controls.IRKeyboardGetKey (shift) then
end
please help
i need delete folder with some files but
dont work :(Code:System.removeDirectory("ms0:/tmp")
or delete all files from this folder - something like this:
Code:System.removeFile("ms0:/tmp/*.*")
this would take quite a while to code something that operates in this way and would involve useing lots more cod than you are useing your best bet is to name each file that you want deleted r wait for about a month while i code it for youZitat:
Zitat von lps
Or something like this:Zitat:
Zitat von FaT3oYCG
Code:local files = System.listDirectory("ms0:/tmp")
for i = 3, table.getn(files) do -- 3 to avoid "." and ".."
System.removeFile("ms0:/tmp/" .. files[i].name)
end
System.removeDirectory("ms0:/tmp")
Zitat:
Zitat von FaT3oYCG
I lol'd.Zitat:
Zitat von Nielkie
That was quick mate :ROFL:
Er, '.' and '..' come first, so doing that would just skip the last two files in the directory instead of not including '.' and '..', no?Zitat:
Zitat von Nielkie
i was just writing up a thing about how you are wrong when i realized you were right lol.
the correct loop would read:
the - 2 you had subtracts two from the loops limit, not from how many times the loop loops.Code:for i = 3, table.getn(files)
nice catch dysfunctional
Actually, I lied, his loop started at 3. His is correct.
yea but you still wouldn't need that -2 in there would you?
Yeah, you would, because if you didn't have it you would be going two items past the end of the array.
Incorrect, table.getn will give you the max array index, so by subtracting 2, you are not removing the last 2 files. by starting at 3 you are skipping the first 2 items and you want it to run to the last index of the array.Zitat:
Zitat von _dysfunctional
Oh, I see. I thought something looked wrong.
P.S. #8000!