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

[Lua] [Error] os.run()

Started by svdragster, 01 May 2013 - 01:02 PM
svdragster #1
Posted 01 May 2013 - 03:02 PM

function input()
  term.setBackgroundColour( colors.lightGray )
  clear(2, 18, 1, 51) -- clear(fromline, toline, fromcolumn, tocolumn)
  term.setTextColour( colors.yellow )
  term.setCursorPos(2,2)
  write("Input needed: ")
  term.setTextColour( colors.orange )
  inputtxt = read()
  return inputtxt
end


  input()
  os.run({}, "/SVOS/paint", inputtxt) -- The simple paint, just copied to a different dir

paint:40:attempt to index? (nil value)

I need os.run() or it will overwrite some functions like fs.open() I changed in the startup file for some safety.
BigSHinyToys #2
Posted 01 May 2013 - 03:12 PM
use

shell.run("/SVOS/paint", inputtxt)
nutcase84 #3
Posted 01 May 2013 - 03:16 PM
Why do you return inputtxt if it's a global variable?

Try what BigSHinyToys said.
BigSHinyToys #4
Posted 01 May 2013 - 03:24 PM
paint is a shell dependent program it requires shell.resolve witch is a pain we can work around this problem thought


function input()
    term.setBackgroundColour( colors.lightGray )
    --clear(2, 18, 1, 51) -- clear(fromline, toline, fromcolumn, tocolumn)
    term.setTextColour( colors.yellow )
    term.setCursorPos(2,2)
    write("Input needed: ")
    term.setTextColour( colors.orange )
    inputtxt = read()
    return inputtxt
end
input()
local tEnv = {
    shell = {
	    resolve = function(...)
		    local tArg = {...}
		    return unpack(tArg)
	    end,
	    }
    }
setmetatable(tEnv,{__index = _G})
os.run(tEnv,"rom/programs/color/paint", inputtxt)
svdragster #5
Posted 01 May 2013 - 03:26 PM
I've overwritten the fs api, which will be set back to normal when using shell.run(). Any other way except shell.run() or dat pain?

Why do you return inputtxt if it's a global variable?

Didn't work before, so I was trying this and it worked. Or I was an idiot, could be possible, too.
BigSHinyToys #6
Posted 01 May 2013 - 03:32 PM
I've overwritten the fs api, which will be set back to normal when using shell.run(). Any other way except shell.run() or dat pain?

Why do you return inputtxt if it's a global variable?

Didn't work before, so I was trying this and it worked. Or I was an idiot, could be possible, too.
I don't think shell.run resets fs have you tested weather it will or not ??
svdragster #7
Posted 01 May 2013 - 03:40 PM
Oh well, sometimes it does… Scary :o/>
When changing io to fs in paint on line 120 it works with shell.run().

Before, when running things with shell.run it has overwritten the function.

Thanks for the help :P/>