718 posts
Location
Hawaii
Posted 06 April 2012 - 08:42 PM
How can I do:
file:write("public static final Block Block"..blockclass.." = new Block"..blockclass.."("..blockid..", 0)")
To a specific line (line 6)
Then search for
public void load()
{
And write this inside
ModLoader.registerBlock(Block" ..blockclass.. ");
ModLoader.addName(Block" ..blockclass.. ", ""..blockclass.."");
378 posts
Location
In the TARDIS
Posted 07 April 2012 - 01:21 AM
You mean in a file? Or on a screen? I think you have to put it all in 1 variable and then write the whole variable to the file at the same time
31 posts
Posted 08 April 2012 - 03:35 AM
i think you'll have open the file in write mode then read line by line until you reach the lineyou want then write your line… maybe i'm wrong i'd never tested to read a line in write mode… ^^
And i think it's not possible to search in a file… again maybe i'm wrong ^^ maybe you can read each line and test them to see if it's the right one …
but i never use the file:write thing… i use only the fs api and i learn it recently so i'm not sur about what i'm saying XD…
378 posts
Location
In the TARDIS
Posted 08 April 2012 - 10:17 AM
There is an API for that purpose:
mad's fLib
1111 posts
Location
Portland OR
Posted 08 April 2012 - 10:24 AM
I've been doing it by capturing the contents of the file in a table. then using table commands to edit the table, and finally updating the file to match the new edited table.
378 posts
Location
In the TARDIS
Posted 08 April 2012 - 01:04 PM
I've been doing it by capturing the contents of the file in a table. then using table commands to edit the table, and finally updating the file to match the new edited table.
OK Great to hear you managed it
31 posts
Posted 08 April 2012 - 05:03 PM
I've been doing it by capturing the contents of the file in a table. then using table commands to edit the table, and finally updating the file to match the new edited table.
OK Great to hear you managed it
hum… it's not luanub who opened this topic^^ it's ComputerCraft11 and we didn't know if he managed it… ^^
378 posts
Location
In the TARDIS
Posted 09 April 2012 - 12:07 PM
I've been doing it by capturing the contents of the file in a table. then using table commands to edit the table, and finally updating the file to match the new edited table.
OK Great to hear you managed it
hum… it's not luanub who opened this topic^^ it's ComputerCraft11 and we didn't know if he managed it… ^^
Damn :P/>/>
1111 posts
Location
Portland OR
Posted 09 April 2012 - 12:32 PM
If he needs it I can share the code I've been working with. Right now I just using it to remove a specific line from the file but it should be easy to modify it to edit the line instead.