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

Add program to global programs list

Started by EveryOS, 18 March 2016 - 05:33 PM
EveryOS #1
Posted 18 March 2016 - 06:33 PM
I am making a program and it needs to be accessable no matter what dir you are in. Here's what I tried:

shell.setAlias('lastDir',self)
Edited on 18 March 2016 - 05:36 PM
TYKUHN2 #2
Posted 18 March 2016 - 06:44 PM
The command you tried works (apart from the self which in this instance can be replaced with fs.getRunningProgram() )
valithor #3
Posted 18 March 2016 - 07:19 PM
The command you tried works (apart from the self which in this instance can be replaced with fs.getRunningProgram() )

shell.getRunningProgram()*
Lignum #4
Posted 18 March 2016 - 09:47 PM
A much more conventional way to do it would be to modify the path:

local programDir = "/dir/containing/the/program"
shell.setPath(shell.path() .. ":" .. programDir)
TYKUHN2 #5
Posted 18 March 2016 - 10:29 PM
A much more conventional way to do it would be to modify the path:

local programDir = "/dir/containing/the/program"
shell.setPath(shell.path() .. ":" .. programDir)

That defeats the point of being inside any directory. Especially since it has to be run programatically then
Lignum #6
Posted 19 March 2016 - 03:39 PM
That defeats the point of being inside any directory. Especially since it has to be run programatically then

My code will make the program executable from inside any directory, which is the point, no? I'm afraid I'm also not sure what you mean by having to programmatically run it.
TYKUHN2 #7
Posted 19 March 2016 - 05:18 PM
Didn't realize that functionality, although my previous point that a program would have to run it stands. Plus it is easier to read and clear aliases since they are in a table not a long string. (Although that may just be my opinion)
Lignum #8
Posted 19 March 2016 - 07:04 PM
Didn't realize that functionality, although my previous point that a program would have to run it stands. Plus it is easier to read and clear aliases since they are in a table not a long string. (Although that may just be my opinion)

Well, the alias version would still have to be run. I do agree that for a single program an alias would be sufficient, though it seems to me like a bit of a hack, since they're not meant for that sort of stuff.