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

[1.52/1.6] disk file "autorun"

Started by wilcomega, 19 March 2013 - 07:58 PM
wilcomega #1
Posted 19 March 2013 - 08:58 PM
i would suggest making in the main co-routine host a event handeler for files on disks called "autorun"
it will run it when you put it in. maybe?

maybe you can disable it by some "os" function

tell me what you think,
wilcomega
PixelToast #2
Posted 20 March 2013 - 03:07 AM
not sure what you mean
Cloudy #3
Posted 20 March 2013 - 03:09 AM
Nah. Make this yourself if you want it.
Left4Cake #4
Posted 25 March 2013 - 01:32 PM
You already have startup file. If you want a program to open a file you could just make a startup file like.


shell.run("paint", "file.ico")

or something.
theoriginalbit #5
Posted 25 March 2013 - 03:00 PM
isn't there the functionality where it will run anything in the 'autorun' folder, no matter its name, already?
BigSHinyToys #6
Posted 25 March 2013 - 03:25 PM
isn't there the functionality where it will run anything in the 'autorun' folder, no matter its name, already?
You must be playing with a custom bios that is not normal behavior. the "startup" file will be run from a disk if available or from the computers root. No other programs are run automatically at startup. (Pleases correct me if I a wrong.)
theoriginalbit #7
Posted 25 March 2013 - 03:28 PM
You must be playing with a custom bios that is not normal behavior. the "startup" file will be run from a disk if available or from the computers root. No other programs are run automatically at startup. (Pleases correct me if I a wrong.)
Nope, not playing with a custom bios, all i use is ccemu. i found the code I remembered seeing.

File >>>> rom/startup

if fs.exists( "/rom/autorun" ) and fs.isDir( "/rom/autorun" ) then
  local tFiles = fs.list( "/rom/autorun" )
  table.sort( tFiles )
  for n, sFile in ipairs( tFiles ) do
	if string.sub( sFile, 1, 1 ) ~= "." then
	  local sPath = "/rom/autorun/"..sFile
	  if not fs.isDir( sPath ) then
		shell.run( sPath )
	  end
	end
  end
end

Which is actually run even before the main startup thats on the computer

File >>>> rom/programs/shell


-- If this is the toplevel shell, run the startup programs
if parentShell == nil then
  -- Run the startup from the ROM first
  local sRomStartup = shell.resolveProgram( "/rom/startup" )
  if sRomStartup then
	shell.run( sRomStartup )
  end

  -- Then run the user created startup, from the disks or the root
  local sUserStartup = shell.resolveProgram( "/startup" )
  for n,sSide in pairs( redstone.getSides() ) do
	if disk.isPresent( sSide ) and disk.hasData( sSide ) then
	  local sDiskStartup = shell.resolveProgram( fs.combine(disk.getMountPath( sSide ), "startup") )
	  if sDiskStartup then
		sUserStartup = sDiskStartup
		break
	  end
	end
  end

  if sUserStartup then
	shell.run( sUserStartup )
  end
end
MudkipTheEpic #8
Posted 25 March 2013 - 03:29 PM
Actually, the shell loads startup. In order of what loads what, its

bios.lua{
rom/programs/shell{
rom/startup, then
(rom/autorun files if any, default none)
disk/startup(if it doesn't exist, check the next disk)\/
If there is no disks with startup, it runs /startup.
}
}

Edit: No idea why that's there, but there is no rom/autorun without editing files.
Bubba #9
Posted 25 March 2013 - 06:41 PM
-snip- Actually, there is no autorun folder anymore. I remember it being in previous versions but I guess it was removed from 1.51.
superaxander #10
Posted 25 March 2013 - 07:44 PM
-snip- Actually, there is no autorun folder anymore. I remember it being in previous versions but I guess it was removed from 1.51.
You have to place it in there yourself
theoriginalbit #11
Posted 25 March 2013 - 07:46 PM
-snip- Actually, there is no autorun folder anymore. I remember it being in previous versions but I guess it was removed from 1.51.
The folder isn't there, but 1.51 can still make use of it. the code I posted was from 1.51
Cloudy #12
Posted 25 March 2013 - 08:16 PM
That autorun has nothing to do with the suggestion…
BigSHinyToys #13
Posted 25 March 2013 - 08:17 PM
ow so "lua\bios.lua" calls "lua\rom\programs\shell" witch calls "lua\rom\startup" witch runs the files in the "rom\autorun" folder.I never knew it did that nice to know.
theoriginalbit #14
Posted 25 March 2013 - 08:24 PM
ow so "lua\bios.lua" calls "lua\rom\programs\shell" witch calls "lua\rom\startup" witch runs the files in the "rom\autorun" folder.I never knew it did that nice to know.
its actually "lua\bios.lua" —> "lua\rom\programs\shell" —> "lua\rom\startup" —> "rom\autorun" folder contents —> disk 'startup' or computer 'startup'
Sebra #15
Posted 26 March 2013 - 03:08 AM
i would suggest making in the main co-routine host a event handeler for files on disks called "autorun"
it will run it when you put it in. maybe?

maybe you can disable it by some "os" function

tell me what you think,
wilcomega
Do not add another way for viruses please! There are too many already.
Do not make CC so holed as windows.
Cloudy #16
Posted 26 March 2013 - 03:19 AM
I'm just going to close this. No more valuable conversation will come of this.