This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
FuuuAInfiniteLoop(F.A.I.L)'s profile picture

test:156: attempt to concatenate nil and string

Started by FuuuAInfiniteLoop(F.A.I.L), 01 April 2013 - 04:02 AM
FuuuAInfiniteLoop(F.A.I.L) #1
Posted 01 April 2013 - 06:02 AM
pastebin: pastebin.com/U39CNRRS
when i call the program with -receive it works but when i do it with send it gives me that error

the layout is the following(if you see it from the top)
C = computer
R = redstone

RRRRRRRRR
R R
C C

the redstone is connected at the back of the computer
FuuuAInfiniteLoop(F.A.I.L) #2
Posted 01 April 2013 - 06:10 AM
I put it on pastebin
remiX #3
Posted 01 April 2013 - 06:12 AM
function toBinary(str)
	for i=1, #str do
		local a = getChar(str, i)
		local result = ""
		if a=="\n" then a = "end of line" end
		for k, v in pairs(binary) do
			if v==a then
				result = result..k
			end
		end
	end
	return result
end

Out of the whole code, that's like the only place you declare a local variable. Now this caused the error because result is nil when you return it, move the local result = "" out the for loop (above)

ANd yeah, start declaring functions/variables local :P/>