157 posts
Posted 29 April 2014 - 09:39 PM
Regards
Augustas
1140 posts
Location
Kaunas, Lithuania
Posted 29 April 2014 - 09:45 PM
What features do you need? There are some read implementations with more features, just search for them. You can find the default read function in bios.lua file.
8543 posts
Posted 29 April 2014 - 10:11 PM
It really depends on what you're trying to do. "More features" isn't always better, especially for something as simple as a read function. What do you need it to do? Limit line length, limit allowable characters, allow multiple lines? There are a lot of things one could do to modify read(), and trying to stuff all of them into one function would be a little absurd.
157 posts
Posted 29 April 2014 - 10:35 PM
Can you explained how this works as good as you can, because I'm kind of confused with these parts:
term.write( string.rep(" ", w - x + 1) )str = str:sub(1, pos - 1)..p1..str:sub(pos)
EDIT: Source: https://github.com/matheuscat/Computer-Craft-Programs/blob/master/lua/bios.lua
Edited on 29 April 2014 - 08:37 PM
1281 posts
Posted 29 April 2014 - 10:59 PM
term.write( string.rep(" ", w - x + 1) )
writes a string with as many empty spaces as (w - x + 1), this is probably used to clear the line for when you're eg pressing backspace
str = str:sub(1, pos - 1)..p1..str:sub(pos)
adds the string p1 to the string str, at the position of pos. Im assuming p1 is the result of a char event, so essentially this is used to add characters.
Just look up the functions yourself if you don't understand them, please.
http://lua-users.org...LibraryTutorial
Edited on 29 April 2014 - 09:00 PM
171 posts
Location
Eastern USA
Posted 30 April 2014 - 10:56 PM
I didn't write this version, and it's way more complicated, but it certainly has more features:
http://www.computercraft.info/forums2/index.php?/topic/5866-cc-145-shell-tab-completion-v22/It lets you use the tab key to autocomplete parts of paths. It works the same way it works in bash. It's very nice.