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

Text Is Printing Above Printed Text

Started by Nahuel3d, 07 November 2013 - 05:29 PM
Nahuel3d #1
Posted 07 November 2013 - 06:29 PM
Yeah i know, the title is confusing, but if you read this you will understand my problem:

i made a RedNet program, just a little test, but when i receive a message from someone when i want to type a message the text im typing prints above the message i received, here is the code:

function common()
term.clear()
term.setCursorPos(1, 1)
rednet.open("back")
while true do
mes=read()
rednet.broadcast(mes)
end
end
function receive()
while true do
local senderId, message, distance = rednet.receive()
print("PC "..senderId.." Says: "..message)
end
end
parallel.waitForAny(common, receive)
jay5476 #2
Posted 07 November 2013 - 11:38 PM
Yeah i know, the title is confusing, but if you read this you will understand my problem:

i made a RedNet program, just a little test, but when i receive a message from someone when i want to type a message the text im typing prints above the message i received, here is the code:

function common()
term.clear()
term.setCursorPos(1, 1)
rednet.open("back")
while true do
mes=read()
rednet.broadcast(mes)
end
end
function receive()
while true do
local senderId, message, distance = rednet.receive()
print("PC "..senderId.." Says: "..message)
end
end
parallel.waitForAny(common, receive)
first you will want to save the line its on eg.

local line = 1
and then you modify both functions like so

--# your common function
local function common()
  term.clear()
  while true do
	term.setCursorPos(1,line)
	local mes = read()
	line = line + 1
	rednet.broadcast(mes)
  end
end
--# your receive function
local function receive()
  while true do
	id,mes,distance = rednet.receive()
	print("Received "..mes.." From ID: "..id)
	line = line + 1
	end
  end
end
the line variable stores which line it should set to each time so say you print on line one it adds one so it sets to line 2 instead of staying on line 1