This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Neuis's profile picture

Solved: [LUA][QUESTION]Show File with Scrolling (like edit)?

Started by Neuis, 31 March 2012 - 06:43 PM
Neuis #1
Posted 31 March 2012 - 08:43 PM
Hello. I programming with somebody. So, we will read a TXT-File. But, with Scrolling (If is has many Lines).
BUT: How i can do it? (Please not function-Codes.)
Advert #2
Posted 31 March 2012 - 08:51 PM
You can take a look at the code by opening the source for the edit program.


edit rom/programs/edit
or open it in your editor:
/.minecraft/mods/ComputerCraft/lua/rom/programs/edit

And, if I may ask, why don't you want functions?
Neuis #3
Posted 31 March 2012 - 09:25 PM
Advert: I tried it, but, it not works.

I have a mini-menu and i have a point "see".
if WasMachen == "s" then
--Wich Code to see the file?
end
Advert #4
Posted 31 March 2012 - 10:19 PM
You could use

shell.run("edit", "path/to/file")
Neuis #5
Posted 01 April 2012 - 01:47 PM
We have a Menu. Its Password protected. If the Password is right, then can the User see the "Admin-Panel". So, he can download a File and SEE it.
But, when wie start "edit", then close our programm. So, we want it as code to SEE it.

(Sorry for the bad english: I'm a german)
Advert #6
Posted 01 April 2012 - 02:11 PM
If you don't want the user to be able to edit the program, you can copy it (so any edits they do will be discarded), then pcall shell.run, so if they terminate, it won't exit your program, but instead exit the edit program and return to yours.


fs.delete("temporaryfile") -- we can't copy if it already exists. we can't delete after they open it, because they could do that then shutdown, then the file'd exist already.
fs.copy("path/to/program", "temporaryfile") -- copy it
pcall(shell.run, "edit", "temporaryfile") -- allow the user to see/edit the temporary file
Neuis #7
Posted 01 April 2012 - 05:41 PM
Thanks. You helped me (a lot)! :)/>/>