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

[solved] Program to alter craftOS

Started by CCJJSax, 11 June 2016 - 12:38 AM
CCJJSax #1
Posted 11 June 2016 - 02:38 AM
I use sublime to code and I like the colors. The colors are automatically there when you use a .lua file. If I had a file named blah.lua, I want to be able to go to a computer and run "blah" and have it search for "blah" then try "blah.lua". The 2 ways I can think of to do this are to edit craftOS in the computercraft files which I don't want to do, or run a separate program with it as an argument. ie. "run blah", which defeats the purpose.
Edited on 11 June 2016 - 01:36 AM
Bomb Bloke #2
Posted 11 June 2016 - 02:54 AM
At a glance, it looks like you may be able to do this by overriding shell.resolveProgram():

local oldShellResolve = shell.resolveProgram

shell.resolveProgram = function(program)
  return oldShellResolve(program) or oldShellResolve(program .. ".lua")
end

… though I haven't tested this.
CCJJSax #3
Posted 11 June 2016 - 03:35 AM
At a glance, it looks like you may be able to do this by overriding shell.resolveProgram():

local oldShellResolve = shell.resolveProgram

shell.resolveProgram = function(program)
  return oldShellResolve(program) or oldShellResolve(program .. ".lua")
end

… though I haven't tested this.

You sir, are a genius! Works wonders