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

Make program global

Started by jesusthekiller, 20 April 2013 - 09:27 AM
jesusthekiller #1
Posted 20 April 2013 - 11:27 AM
Howdy, I have an problem while making my OS - How do I make programs global (if it's possible) without editing mod files (like for example "edit" is global)?


Thanks for help :)/>
Sammich Lord #2
Posted 20 April 2013 - 11:34 AM
IIRC, the shell first checks the CWD to see if the file is there then if so runs it, if it isn't in there then it checks the ROM and if it is in runs it, if not it does nothing.
jesusthekiller #3
Posted 20 April 2013 - 11:36 AM
mkay, gonna have to overwrite CC's console or fs D:
Lyqyd #4
Posted 20 April 2013 - 11:38 AM
For a single file to be available on all computers, it needs to be in /rom/ someplace, in the mod's files, on the server.
Sammich Lord #5
Posted 20 April 2013 - 11:39 AM
For a single file to be available on all computers, it needs to be in /rom/ someplace, in the mod's files, on the server.
I believe he meant on the single computer that you can access in any CWD like the scripts in ROM.
jesusthekiller #6
Posted 20 April 2013 - 11:41 AM
For a single file to be available on all computers, it needs to be in /rom/ someplace, in the mod's files, on the server.
I believe he meant on the single computer that you can access in any CWD like the scripts in ROM.

Exactly
Lyqyd #7
Posted 20 April 2013 - 11:45 AM
For a single file to be available on all computers, it needs to be in /rom/ someplace, in the mod's files, on the server.
I believe he meant on the single computer that you can access in any CWD like the scripts in ROM.

Ah. His original post was ambiguous.

OP, look into shell.path (or shell.getPath, I can never remember which it is) and shell.setPath.
jesusthekiller #8
Posted 20 April 2013 - 11:47 AM
mkay :)/>
Kingdaro #9
Posted 20 April 2013 - 11:49 AM
OP, look into shell.path (or shell.getPath, I can never remember which it is) and shell.setPath.

The shell path function always confused me. I wish it were just a combined getter and setter, so you could do something like this:

shell.path(shell.path() .. ':/bin')
jesusthekiller #10
Posted 20 April 2013 - 11:50 AM
Yeah, there is no documentation about shell.path() in wiki. Anyone has an example code?
Kingdaro #11
Posted 20 April 2013 - 12:30 PM
shell.path() returns the path, shell.setPath() sets the current path. To append "/bin" to the current path (like I did before):


shell.setPath(shell.path() .. ':/bin')

The colon is there because each individual path is separated by a colon. If you wanted to add more paths, you could make a nice function for it:

function addPath(path)
  shell.setPath(shell.path()..':'..path)
end

addPath '/bin'
addPath '/usr/home'
addPath '/usr/lib'

Or something like that.
jesusthekiller #12
Posted 20 April 2013 - 12:42 PM
Thanks! :)/>