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

LUAU - Lua Upgraded v0.1 (Enhanced Lua shell)

Started by Tinyboss, 15 January 2013 - 03:35 PM
Tinyboss #1
Posted 15 January 2013 - 04:35 PM
LUAU - Lua Upgraded, version 0.1 (initial release)

Luau is a replacement for the standard Lua shell on computers, advanced computers, or turtles.

Features:
  • Color support: It looks nice on advanced computers.
  • Online help. The "/help" and "/commands" …erm…commands give descriptions of all the features.
  • Enhanced command history: You can access the n-th line you typed as in_[n], and if it had an output, you can get it by out_[n]. You can repeat the (say) 23rd command by typing "!23". There's also a command to search the command history for a particular string or pattern.
  • Substitution operator: If you mess up and type os.loadApi('my_api'), just type "s/Api/API/" on the next line and it'll make the substitution ("API" for "Api") and re-run the fixed command for you. Can be way faster than manual editing, and you can use all of Lua's pattern-matching features.
  • "?foo" is short for "print(foo)", with the added benefit that if foo is a table, you'll see its key/value pairs instead of something like "table: 10cc67a".
  • That annoying "1" that shows up when you print anything has been suppressed.
  • Macros: You can define macros that will be expanded automatically. For instance, if you get tired of typing "os.loadAPI('my_api')", you could type "/macro %la=os.loadAPI('%1')", and after that you can just type "%la[my-api]". Macros can have any number of parameters, or none (simple text expansions).
  • (Somewhat) configurable. Right now the only options are whether to use color and how many blank lines to put between input/output pairs.
  • Config options and macro definitions are saved across sessions.
Usage: Just save the file as "luau" and start using it instead of "lua".

Download: http://pastebin.com/US6uMnQC

Screenshots:
Luau running on a turtle:
[attachment=922:luau-turtle.png]

Running on an advanced computer:
[attachment=921:luau-computer.png]

Known issues / upcoming features:
  • Interaction between substitution and macro expansion could be better, and will be.
  • Enhance substitution so that s17/foo/bar/ reruns the 17th entry in the history with foo's changed to bar's.
  • Option to load command history from prior sessions.
  • Got a feature you'd like to see? Post it here!
lieudusty #2
Posted 15 January 2013 - 05:16 PM
Looks nice! :D/>
Bubba #3
Posted 15 January 2013 - 06:11 PM
Well can't try this right now, but as cool as this is looking I think you may have the "program of excellence award" from yours truly. The interactive lua console that comes built in is functional, but clunky. Oh and macros? Hell yes.
CoolisTheName007 #4
Posted 20 January 2013 - 12:33 AM
Uau this looks amazing. I'll be adapting it t my multitasking framework.
EDIT: suggestion (I may do this myself): make this lua shell also perform the function of a normal shell, i.e. working directory, cd, ls, ect. One of the thigs that bugs me the most is having to switch from the normal shell to the lua shell back and forth.
Tinyboss #5
Posted 20 January 2013 - 05:55 PM
Uau this looks amazing. I'll be adapting it t my multitasking framework.
EDIT: suggestion (I may do this myself): make this lua shell also perform the function of a normal shell, i.e. working directory, cd, ls, ect. One of the thigs that bugs me the most is having to switch from the normal shell to the lua shell back and forth.
I thought of that, too, but I didn't decide on the right way for shell and Lua stuff to interact, e.g. what if I want a variable called "ls"? I suppose I could just treat any line beginning with a certain character as a shell command, but it would be sweet to have tighter integration, supporting something like "for fname in glob('*.txt') do rename(fname,'old_'..fname) end".

Thanks for checking it out and giving feedback!
AlktatStudios #6
Posted 16 September 2013 - 08:19 AM
PASTEBIN:
pastebin get US6uMnQC luau
jay5476 #7
Posted 16 September 2013 - 04:14 PM
Uau this looks amazing. I'll be adapting it t my multitasking framework.
EDIT: suggestion (I may do this myself): make this lua shell also perform the function of a normal shell, i.e. working directory, cd, ls, ect. One of the thigs that bugs me the most is having to switch from the normal shell to the lua shell back and forth.
you could maybe make the user do $program to run a program just sub of the '$' and do os.run or shell.run
also maybe for loading other historys you could serialize the table to a file and make a command to load and unserialize it
but good job :)/> seems like no one else has done this