QJ.NET | Videos | Forums | iPhone | MMORPG | Nintendo DS | Wii | PlayStation 3 | PSP | Xbox 360 | PC | Downloads | Contact Us
Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact

QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides

Go Back   QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides > Developers Corner > PSP Development, Hacks, and Homebrew > PSP Development Forum
The above video goes away if you are a member and logged in, so log in now!

Lua Coding Question

This is a discussion on Lua Coding Question within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; I decided to place this here as i feel its a better place than the luahelpthread. If i had a ...

Reply
 
LinkBack Thread Tools
Old 07-24-2006, 07:16 AM   #1

is not posting very often
 
Glynnder's Avatar
 
Join Date: Feb 2006
Location: omnipresent
Posts: 5,161
Trader Feedback: 0
Default Lua Coding Question

I decided to place this here as i feel its a better place than the luahelpthread.

If i had a settings.ini file, that worked fine but i wanted to make a graphical menu so they can change it on the settings how would i load a line of that code, alter it, save it on the same file, then load it again.

i basically need to know how to load and save certain lines from a text file


sorry plz delete the other one
__________________
Quote:
Originally Posted by Abe
Either way, if you don't know, don't guess. Stick to answering questions about stuff you're qualified to answer, like Pokemon questions or something along those lines.
http://forums.qj.net/501501-post26.html
Glynnder is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 07-24-2006, 07:18 AM   #2
No longer a community member.
 
Join Date: Dec 2005
Posts: 22
Trader Feedback: 0
Default

Quote:
Originally Posted by Glynnder- PSPro
sorry plz delete the other one
I did that, but I'm useless on the programming part, sorry.
Hardrive is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 07-24-2006, 07:43 AM   #3

is not posting very often
 
Glynnder's Avatar
 
Join Date: Feb 2006
Location: omnipresent
Posts: 5,161
Trader Feedback: 0
Default

well, at least you could do 15% of what i needed lol!
__________________
Quote:
Originally Posted by Abe
Either way, if you don't know, don't guess. Stick to answering questions about stuff you're qualified to answer, like Pokemon questions or something along those lines.
http://forums.qj.net/501501-post26.html
Glynnder is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 07-24-2006, 07:58 AM   #4
 
JoeDaStudd's Avatar
 
Join Date: Feb 2006
Location: Earth, UK
Posts: 457
Trader Feedback: 0
Cool

to read

Code:
file = io.open("testRead.txt", "r")
ourtext = file:read()
file:close()
*testRead.txt is your text file
*ourtext is the text from the file

to save (write) to a file

Code:
file = io.open("testRead.txt","w")
file:write("hello")
file:close()
*Again testRead.txt is the file
*"hello" is the text to write to a file

All this is from EvilMana.com (it goes into more detail aswell)
__________________
<<Put A message Here>>
<<Just made another rubbish website visit it [URL="http://www.joedastudd.co.uk/"]here[/URL].>>
JoeDaStudd is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 07-24-2006, 08:24 AM   #5

is not posting very often
 
Glynnder's Avatar
 
Join Date: Feb 2006
Location: omnipresent
Posts: 5,161
Trader Feedback: 0
Default

i know that, thats pretty basic, but i wanted just to load the whole thing but only alter certain lines

so i could have like

loadlibBase at start = ON
and if they click left/right it goes to
loadlibBase at start = OFF

and in the file its goin from
libbase=true
to
libbase=false

and the same happens with every line of that file.

i just dont wanna have to make a seperate file for each option.
__________________
Quote:
Originally Posted by Abe
Either way, if you don't know, don't guess. Stick to answering questions about stuff you're qualified to answer, like Pokemon questions or something along those lines.
http://forums.qj.net/501501-post26.html
Glynnder is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 07-24-2006, 09:29 AM   #6

total-Z
 
youresam's Avatar
 
Join Date: Jul 2005
Location: texas
Posts: 2,803
Trader Feedback: 0
Default

You load the whole thing, change the line, then save the whole thing.
__________________
牧来栠摩琠敨映汩獥
PSN: youresam
From Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
--Mike Hollingsworth
youresam is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 07-24-2006, 09:34 AM   #7

is not posting very often
 
Glynnder's Avatar
 
Join Date: Feb 2006
Location: omnipresent
Posts: 5,161
Trader Feedback: 0
Default

how do u change one line?
__________________
Quote:
Originally Posted by Abe
Either way, if you don't know, don't guess. Stick to answering questions about stuff you're qualified to answer, like Pokemon questions or something along those lines.
http://forums.qj.net/501501-post26.html
Glynnder is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 07-24-2006, 09:44 AM   #8

total-Z
 
youresam's Avatar
 
Join Date: Jul 2005
Location: texas
Posts: 2,803
Trader Feedback: 0
Default

Quote:
Originally Posted by Glynnder- PSPro
how do u change one line?
You can ready the file line by line, but there is no pre-set function to just change 1 line.
__________________
牧来栠摩琠敨映汩獥
PSN: youresam
From Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
--Mike Hollingsworth
youresam is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 07-24-2006, 09:57 AM   #9

is not posting very often
 
Glynnder's Avatar
 
Join Date: Feb 2006
Location: omnipresent
Posts: 5,161
Trader Feedback: 0
Default

yea, and i bin askin how to do that for this whole thread!
__________________
Quote:
Originally Posted by Abe
Either way, if you don't know, don't guess. Stick to answering questions about stuff you're qualified to answer, like Pokemon questions or something along those lines.
http://forums.qj.net/501501-post26.html
Glynnder is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 07-24-2006, 09:59 AM   #10
 
WraithLeader's Avatar
 
Join Date: Jul 2005
Posts: 395
Trader Feedback: 0
Default

Go here and read this tutorial by Evilmana (PSPMillionaire):

http://evilmana.com/tutorials/lua_tutorial_09.php
WraithLeader is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 07-24-2006, 10:22 AM   #11
 
Altair's Avatar
 
Join Date: Jan 2006
Posts: 506
Trader Feedback: 0
Default

I would use: file.read("*l") inside a for loop with a table or if there are only a few lines something like this:
loadlibBase = file.read("*l")
someOtherSetting=file.rea d("*l")
etc.
for every line in the settings.ini file.

Aslong as you dont change the order of the lines and the amount, it always reads the right lines (i think)
__________________
LUA manual:
[url]http://www.lua.org/manual/5.0/manual.html[/url]

LUA Wiki:
[url]http://wiki.ps2dev.org/psp:lua_player[/url]
Altair is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 07-24-2006, 12:00 PM   #12

is not posting very often
 
Glynnder's Avatar
 
Join Date: Feb 2006
Location: omnipresent
Posts: 5,161
Trader Feedback: 0
Default

^Thats what i was playing with, havnt made shed loads of progress yet tho.
__________________
Quote:
Originally Posted by Abe
Either way, if you don't know, don't guess. Stick to answering questions about stuff you're qualified to answer, like Pokemon questions or something along those lines.
http://forums.qj.net/501501-post26.html
Glynnder is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Tags
coding , lua , question

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -8. The time now is 01:49 AM.



Use of this Web site constitutes acceptance of the TERMS & CONDITIONS and PRIVACY POLICY
Copyright © 2009, QJ.NET. All Rights Reserved.
Contact Us