so due to a recent series of unfortunate events i was unable to work on this after all. I have some time now thought and have attempted to make something here is my code currently it only clear works and the others cause crash any ideas??
client
local function openRednet()
local listOfSides = rs.getSides()
for i = 1,6 do
if peripheral.isPresent(listOfSides[i]) and peripheral.getType(listOfSides[i]) == "modem" then
rednet.open(listOfSides[i])
return listOfSides[i]
end
end
end
modemOn = openRednet()
if not modemOn then
print("No WIFI ModemnPress any key to return to menu.")
os.pullEvent("key")
return
else
print("Opened wifi on "..modemOn.." side")
end
while true do
e1,e2,e3,e4,e5 = os.pullEvent()
if e1 == "rednet_message" then
local sTest = string.sub(e3,1,3)
if sTest == "WRT" then
write(string.sub(e3,4,#e3))
elseif sTest == "CLR" then
term.clear()
elseif sTest == "CLL" then
term.clearline()
elseif sTest == "SCB" then
local boolin = string.sub(e3,4,#e3)
if boolin == "true" then
term.setCursorBlink(true)
elseif boolin == "false" then
term.setCursorBlink(false)
end
elseif sTest == "SCP" then
local curP = textutils.unserialize(string.sub(e3,4,#e3))
term.setCursorPos(curP[1],curP[2])
elseif sTest == "GSZ" then -- work on this
rednet.broadcast("SIZ"..textutils.serialize({term.getSize()}))
elseif sTest == "GCP" then
rednet.broadcast("POS"..textutils.serialize({term.getCursorPos()}))
elseif sTest == "SCR" then
term.scroll()
end
end
if e1 == "key" or e1 == "char" then
rednet.broadcast(tostring(e1)..tostring(e2))
end
end
sever
local function openRednet()
local listOfSides = rs.getSides()
for i = 1,6 do
if peripheral.isPresent(listOfSides[i]) and peripheral.getType(listOfSides[i]) == "modem" then
rednet.open(listOfSides[i])
return listOfSides[i]
end
end
end
modemOn = openRednet()
if not modemOn then
print("No WIFI ModemnPress any key to return to menu.")
os.pullEvent("key")
return
else
print("Opened wifi on "..modemOn.." side")
end
-- Original = os.pullEventRaw
function os.pullEventRaw()
e1,e2,e3,e4,e5 = coroutine.yield()
if e1 == "rednet_message" then
if string.sub(e3,1,3) == "key" then
return string.sub(e3,1,3),tonumber(string.sub(e3,4,string.len(e3)))
elseif string.sub(e3,1,4) == "char" then
return string.sub(e3,1,4),string.sub(e3,5,string.len(e3))
end
end
return e1,e2,e3,e,e5
end
local target = {}
function target.write(s)
rednet.broadcast("WRT"..s)
end
function target.clear()
rednet.broadcast("CLR")
end
function target.clearLine()
rednet.broadcast("CLL")
end
function target.setCursorBlink(s)
rednet.broadcast("SCB"..tostring(s))
end
function target.setCursorPos(x,y)
rednet.broadcast("SCP"..textutils.serialize({x,y}))
end
function target.getSize()
rednet.broadcast("GSZ")
while true do
local w1,w2,w3 = os.pullEvent("rednet_message")
if string.sub(w3,1,3) == "SIZ" then
return textutils.unserialize(string.sub(w3,4,string.len(w3)))
end
end
end
function target.getCursorPos()
rednet.broadcast("GCP")
while true do
local w1,w2,w3 = os.pullEvent("rednet_message")
if string.sub(w3,1,3) == "POS" then
return textutils.unserialize(string.sub(w3,4,string.len(w3)))
end
end
end
function target.scroll()
rednet.broadcast("SCR")
end
-- add all the functions here (clear, scroll, etc.)
--[[ notes
write -- WRT
clear -- CLR
clearLine -- CLL
setCursorBlink -- SCB
setCursorPos -- SCP
getSize -- GSZ
getCursorPos -- GCP
scroll -- SCR
]]--
term.redirect(target)
term.clear()
local x,y = term.getSize()
term.setCursorPos(1,1)
print("hello")
-- shell.run("rom/user/BENCH1.lua")
os.pullEventRaw = Original
term.restore()
--[[
while true do
local a = {os.pullEvent()}
for i = 1,#a do
write(tostring(a[i]).." ")
end
write("n")
end
]]--