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

Bash - Run programs without creating Lua

Started by FNCPro, 14 June 2015 - 10:42 PM
FNCPro #1
Posted 15 June 2015 - 12:42 AM


________                      ___       
`MMMMMMMb.                    `MM       
 MM    `Mb                     MM       
 MM     MM    ___      ____    MM  __   
 MM    .M9  6MMMMb    6MMMMb\  MM 6MMb  
 MMMMMMM(  8M'  `Mb  MM'    `  MMM9 `Mb 
 MM    `Mb     ,oMM  YM.       MM'   MM 
 MM     MM ,6MM9'MM   YMMMMb   MM    MM 
 MM     MM MM'   MM       `Mb  MM    MM 
 MM    .M9 MM.  ,MM  L    ,MM  MM    MM 
_MMMMMMM9' `YMMM9'Yb.MYMMMM9  _MM_  _MM_



Bash is a ComputerCraft program where you can execute files that run ComputerCraft programs.
The programs you run have no valid Lua code in them.
An example file that you would create would be

# | To comment a line so that Bash doesn't interpret it,
# | put a pound/hashtag in the front of the line
# | like so!
#lists directory
ls
#deletes file "Hacks"
rm Hacks
#very fun stuff.

To download bash to your ComputerCraft computer, do

pastebin get kgixrLic bash
or go to pastebin.com/kgixrLic
Edited on 14 June 2015 - 10:45 PM
クデル #2
Posted 15 June 2015 - 06:03 AM
I personally want use this, but it will surely help out a lot of newbies.
Konlab #3
Posted 15 June 2015 - 10:56 AM
You should add some other commands like print or some basic variables
biggest yikes #4
Posted 15 June 2015 - 02:12 PM
You should add some other commands like print or some basic variables
The current interpreter simply runs commands with shell.run, you could always edit a file called "var" or "print" to do those things.
Edited on 15 June 2015 - 12:13 PM
FNCPro #5
Posted 15 June 2015 - 04:12 PM
I can edit the interpreter to have more advanced capabilities.
Will do!
Update 0.2:
+ Added different ways to comment( two dashes, one hashtag, and two slashes(//))
+ Added print command, don't edit the cmds table, it is a WIP.
+ To use print, do this

#Prints "Hello! This is a test with the print command!" to the console.
print Hello! This is a test with the print command!
Download from the pastebin in the OP!
Edited on 15 June 2015 - 02:44 PM
biggest yikes #6
Posted 15 June 2015 - 05:12 PM
why not

elseif cmds[cmd] then
  _ = table.remove(linesplit, 1)
  cmds[cmd](unpack(linesplit))
so if the command is found in the cmds table then it executes that function with the parameters given after the command
Edited on 15 June 2015 - 03:18 PM
FNCPro #7
Posted 15 June 2015 - 09:06 PM
why not

elseif cmds[cmd] then
  _ = table.remove(linesplit, 1)
  cmds[cmd](unpack(linesplit))
so if the command is found in the cmds table then it executes that function with the parameters given after the command
I've had that idea, and it bugged out to the point that if you used the wrong syntax it would break. The errorCheck function at that point failed me.
biggest yikes #8
Posted 15 June 2015 - 09:20 PM
all the arguments given to the command are just supplied as arguments to the function, it should work fine. if you want to check if one argument doesn't exist just check if it's nil