Jump to content




[Lua] [Error] os.run()


  • You cannot reply to this topic
6 replies to this topic

#1 svdragster

  • Members
  • 222 posts
  • LocationGermany

Posted 01 May 2013 - 02: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.

#2 BigSHinyToys

  • Members
  • 1,001 posts

Posted 01 May 2013 - 02:12 PM

use
shell.run("/SVOS/paint", inputtxt)


#3 nutcase84

  • Members
  • 711 posts
  • LocationIn My Lonely Little Computer Corner

Posted 01 May 2013 - 02:16 PM

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

Try what BigSHinyToys said.

#4 BigSHinyToys

  • Members
  • 1,001 posts

Posted 01 May 2013 - 02: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)


#5 svdragster

  • Members
  • 222 posts
  • LocationGermany

Posted 01 May 2013 - 02: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?

View Postnutcase84, on 01 May 2013 - 02:16 PM, said:

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.

#6 BigSHinyToys

  • Members
  • 1,001 posts

Posted 01 May 2013 - 02:32 PM

View Postsvdragster, on 01 May 2013 - 02:26 PM, said:

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?

View Postnutcase84, on 01 May 2013 - 02:16 PM, said:

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 ??

#7 svdragster

  • Members
  • 222 posts
  • LocationGermany

Posted 01 May 2013 - 02: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





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users