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

[ERROR]i need help fixing a error

Started by dcleondc, 02 September 2012 - 03:17 AM
dcleondc #1
Posted 02 September 2012 - 05:17 AM
here is the code


local w,h = term.getSize()
local function printCentered(str, ypos)
  term.setCursorPos(w/2 - #str/2, ypos)
  term.write(str)
end
local function printRight(str, ypos)
  term.setCursorPos(w - #str, ypos)
  term.write(str)
end
function Clear(x,y)
	term.clear()
	term.setCursorPos(x, y)
end
function idList()
	if not fs.exists("server/ids.txt") then
		local file = io.open("/request.txt", "w")
		file:write("{ }")
		file:close()
	end

	local file = io.open("server/ids.txt", "r")
	sNames = file:read()
	file:close()
	requestList = textutils.unserialize(sNames)
end
function Clear()
term.clear()
term.setCursorPos(1, 1)
printCentered("Private Server", 1)
Pos(1, 2)
print(" #################################################")--2
print(" #											   #")--3
print(" #											   #")--4
print(" #											   #")--5 here
print(" #											   #")--6
print(" #											   #")--7
print(" #											   #")--8
print(" #											   #")--9
print(" #											   #")--10
print(" #											   #")--11
print(" #											   #")--12
print(" #											   #")--13
print(" #											   #")--14
print(" #											   #")--15
print(" #											   #")--16 here
print(" #											   #")--17
print(" #################################################")--18
--	 12345678911111111112222222222333333333344444444445
--			  01234567890123456789012345678901234567890
--Length = 50
--Hight = 18
--center = 26,9
--Pos(19,1)
--print("Private Server")
Pos(1,19)
end
Clear()
idList()
local num = table.maxn(requestList)
shell.run("clear")
Pos(3,3)
for i=1,num do
	write(requestList[i]..",")
end

here is my error

textutils:165: attempt to concatenate string and nil

idk y but it is makeing the code show up funny where all the # are
Noodle #2
Posted 02 September 2012 - 06:10 AM
1: You have 2 clear function
2: Wheres your pos(x, y) function? (I probably didn't see or it doesn't exist)
3: textutils.unserialize isn't how you do a fs.open/io.open

Tips
Use fs.open. Dan coded io.open to read from fs.open..

Here's the fix
for i = 1,num do
  write(sNames[i])
end
Lettuce #3
Posted 02 September 2012 - 06:14 AM
please put a comment on line 165, so I don't drive myself to tears staring so close at the screen, also, this is clearly not the whole program, please give us the whole thing, as the error could be somewhere completely unrelated. Most likely, you put two periods where you shouldn't, one of them a string, the other a perceived nil variable on/near line 165.