Regards
Augustas
Anyone have a code for their own read function that has identical or even better features than io.read()?
Started by augustas656, Apr 29 2014 08:39 PM
5 replies to this topic
#1
Posted 29 April 2014 - 08:39 PM
#2
Posted 29 April 2014 - 08: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.
#3
Posted 29 April 2014 - 09: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.
#4
Posted 29 April 2014 - 09: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/m...er/lua/bios.lua
term.write( string.rep(" ", w - x + 1) )
str = str:sub(1, pos - 1)..p1..str:sub(pos)
EDIT: Source: https://github.com/m...er/lua/bios.lua
Edited by augustas656, 29 April 2014 - 09:37 PM.
#5
Posted 29 April 2014 - 09: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 backspacestr = 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 by CometWolf, 29 April 2014 - 10:00 PM.
#6
Posted 30 April 2014 - 09:56 PM
I didn't write this version, and it's way more complicated, but it certainly has more features: http://www.computerc...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.
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.
2 user(s) are reading this topic
0 members, 2 guests, 0 anonymous users











