143 posts
Location
still looking....
Posted 24 January 2015 - 10:42 PM
Right now I have a disk connected via network cable and about 20 computers boot off of it. Here is what it contains:
shell.setPath("/os")
On the computer there is /os
and on the computer I have:
/os
/os/rom
/os/rom/programs
and apparently shell.programs does not recognize my 'programs' folder, so I have to set an alias for every program. Is there any way around this?
7083 posts
Location
Tasmania (AU)
Posted 24 January 2015 - 11:14 PM
Looking at the shell source, it appears that aliases are indeed geared for use as shortcuts to files, not folders.
I suppose you could override shell.programs() in startup. Define a new version of the function - one that calls the original,
adds the files from your extra programs folder to the output, then returns the result.
local oldPrograms = shell.programs
function shell.programs(_bIncludeHidden)
local tItemList = oldPrograms(_bIncludeHidden)
-- Get the list from /os/rom/programs, add it to tItemList, return it
143 posts
Location
still looking....
Posted 24 January 2015 - 11:50 PM
Looking at the shell source, it appears that aliases are indeed geared for use as shortcuts to files, not folders.
I suppose you could override shell.programs() in startup. Define a new version of the function - one that calls the original,
adds the files from your extra programs folder to the output, then returns the result.
local oldPrograms = shell.programs
function shell.programs(_bIncludeHidden)
local tItemList = oldPrograms(_bIncludeHidden)
-- Get the list from /os/rom/programs, add it to tItemList, return it
I commented out all my aliases for my programs and added:
function shell.programs()
local tbl = {}
local programList = fs.list("/os/.rom/programs/")
for _, program in ipairs(programList) do
table.insert(tbl, program)
end
return tbl
end
textutils.pagedTabulate(shell.programs())
but this returns nothing
113 posts
Location
This page
Posted 25 January 2015 - 12:29 AM
I don't really ever overwrite functions, but I believe it should be
shell.programs= function ()
instead of
function shell.programs()
If you are wanting to replace the original shell.programs() with your new code.
However I am not sure, I think the original should work since var=function () is equivalent to function var()
Edit: 2 things:
1. You have a '.', I assume that is on purpose so it is a hidden file, but just in case it was not intended and you did not notice.
2. Just for fun try pairs instead of ipairs, should not make a difference but you never know.
Edited on 24 January 2015 - 11:41 PM
7083 posts
Location
Tasmania (AU)
Posted 25 January 2015 - 01:20 AM
However I am not sure, I think the original should work since var=function () is equivalent to function var()
They're not exactly the same (under certain circumstances: see
this guide), but in this case it doesn't matter.
Likewise, ipairs should be suitable here. I reckon you hit the nail with the ".rom" thing.
143 posts
Location
still looking....
Posted 25 January 2015 - 01:46 AM
However I am not sure, I think the original should work since var=function () is equivalent to function var()
They're not exactly the same (under certain circumstances: see
this guide), but in this case it doesn't matter.
Likewise, ipairs should be suitable here. I reckon you hit the nail with the ".rom" thing.
.rom was intentional because I did not want the client of the computer seeing it
7083 posts
Location
Tasmania (AU)
Posted 25 January 2015 - 01:55 AM
How about we simplify things?:
function shell.programs()
return fs.list("/os/.rom/programs/")
end
textutils.pagedTabulate(shell.programs())
143 posts
Location
still looking....
Posted 25 January 2015 - 01:59 AM
However I am not sure, I think the original should work since var=function () is equivalent to function var()
They're not exactly the same (under certain circumstances: see
this guide), but in this case it doesn't matter.
Likewise, ipairs should be suitable here. I reckon you hit the nail with the ".rom" thing.
.rom was intentional because I did not want the client of the computer seeing it
Now say if I have a program with the directory of: /os/.rom/programs/test
and I type: test
I get: No such program, how would I make it so when I type: test
it goes to: /os/.rom/programs/test
7083 posts
Location
Tasmania (AU)
Posted 25 January 2015 - 02:38 AM
Looks like you really want to make use of shell.setPath():
shell.setPath(shell.getPath()..":/os/.rom/programs")
Edited on 25 January 2015 - 01:42 AM