Just asking if you could help me again, theres an issue im having with trying to print messages being sent by the terminal to the same one that is sending.
local xMax, yMax = term.getSize()
yResult = yMax - 4
rednet.open("right")
i = 1
function drawSendBox(xStart, yStart)
term.setCursorPos(xStart+1, yStart)
newx = xMax - 2
o = 2
for i = 1, newx do
term.write("_")
term.setCursorPos(o, yStart + 3) -- Writing the Horizonal Lines
term.write("_")
o = o + 1
term.setCursorPos(o, yStart)
end
term.setCursorPos(xStart, yStart + 1)
for i = 1, 1 do
term.write("|")
term.setCursorPos(xMax, yStart + 1)
term.write("|")
term.setCursorPos(xStart, yStart + 2)
term.write("|")
term.setCursorPos(xMax, yStart + 2) -- Writing the Vertical lines (NEED TO FIX IF STATEMENT PRINTING!)
term.write("|")
term.setCursorPos(xStart, yStart + 3)
term.write("|")
term.setCursorPos(xMax, yStart + 3)
term.write("|")
end
term.setCursorPos(xStart + 2, yStart + 2)
end
cl.clear()
term.setCursorPos(1,1)
while true do
event, id, message = os.pullEvent()
local curline = 0
if event == "rednet_message" then
local table = textutils.unserialize(message)
if table[1] == "/w" then
print("[Whisper] from "..table[2]..": "..table[3])
curline = curline + 1
else
cl.clear()
print("Error")
break
end
elseif event == "key" then
if id == 28 then
drawSendBox(1, yResult)
inputString = read()
Myid = os.getComputerID()
command, sendid, message = string.match(inputString, "(.-) (.-) (.*)")
if command == "/w" then
term.setCursorPos(1, curline)
term.write("[Whisper] to "..sendid..": "..message)
curline = curline + 1
local table = {command, sendid, message, 2}
term.setCursorPos(1, curline)
local sTable = textutils.serialize(table)
local sid = tonumber(sendid)
rednet.send(sid, sTable)
term.setCursorPos(1, yResult)
term.clearLine()
term.setCursorPos(1, yResult + 1)
term.clearLine()
term.setCursorPos(1, yResult + 2)
term.clearLine()
term.setCursorPos(1, yResult + 3)
term.clearLine()
term.setCursorPos(1, curline)
end
else
end
else
end
end
I need to put in an if statement that checks the command given by the user to send different types of messages however it will not work wherever i put it after the input.
Any help is appreciated including bug reports (Also I know the sending my id has a bug in it. This might not be the right half of the code as Im fixing bugs as I see them on each file and not really doing both)