I have been playing arround and i overwrote some default functions.
I go a 'thing' that can't be called remote shell, but i got the colors, text and input to work from a remote computer:
Client:
rednet.open("right")
--rednet.send(31, term)
function main()
rednet.send(31, "code:getdir")
local id, dir = rednet.receive()
write(dir.."> ")
com = read()
if string.sub(com, 1, 6) == "local:" then
loc = string.sub(com, 7, #com)
shell.run(loc)
else
rednet.send(31, com)
if com == "clear" then
term.clear()
term.setCursorPos(1,1)
end
cx, cy = term.getCursorPos()
while true do
local id, resp = rednet.receive(0.4)
--print("resp:"..resp)
if resp == "code:text" then
local id, txt = rednet.receive()
tx, ty = term.getCursorPos()
if txt == " " then
term.setCursorPos(tx, ty)
end
write(txt)
elseif resp == "code:color" then
local id, col = rednet.receive()
term.setTextColor(col)
elseif resp == "code:pos" then
local id, x = rednet.receive()
local id, y = rednet.receive()
term.setCursorPos(x,y)
elseif resp == "input_request" then
inp = read()
rednet.send(id, inp)
elseif resp == ">" or resp == nil then
--term.setCursorPos(x, )
main()
end
end
end
end
main()
Server:
rednet.open("right")
local id, obj = rednet.receive()
--shell.run(obj)
term_write = term_write or term.write
term.write = function(text)
term_write(text)
rednet.send(id, "code:text")
rednet.send(id, text)
end
print = function( txt )
term.write( txt.."\n" )
end
term_setTextColor = term_setTextColor or term.setTextColor
term.setTextColor = function(color)
term_setTextColor(color)
rednet.send(id, "code:color")
rednet.send(id, color)
end
term_setCursorPos = term_setCursorPos or term.setCursorPos
term.setCursorPos = function(x, y)
term_setCursorPos(x, y)
rednet.send(id, "code:pos")
rednet.send(id, x)
rednet.send(id, y)
end
io_read = io_read or read
read = function()
rednet.send(id, "input_request")
local id, inp = rednet.receive()
term_write(inp)
return inp
end
--[[
term_clear = term_clear or term.clear
term.clear = function()
if term.isColor() then term.setBackgroundColor(colors.black) term_clear() end
end
]]--
if obj == "code:getdir" then
rednet.send(id, shell.dir())
else
shell.run(obj)
end
x, y = term.getCursorPos()
term.setCursorPos(x, y+1)
shell.run("/sv")