Jump to content




Anyone have a code for their own read function that has identical or even better features than io.read()?


  • You cannot reply to this topic
5 replies to this topic

#1 augustas656

  • Members
  • 158 posts

Posted 29 April 2014 - 08:39 PM

Regards
Augustas

#2 MKlegoman357

  • Members
  • 1,170 posts
  • LocationKaunas, Lithuania

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 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

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 augustas656

  • Members
  • 158 posts

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

Edited by augustas656, 29 April 2014 - 09:37 PM.


#5 CometWolf

  • Members
  • 1,283 posts

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 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 by CometWolf, 29 April 2014 - 10:00 PM.


#6 electrodude512

  • Members
  • 167 posts
  • LocationEastern USA

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.





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users