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

bios :206: [string "nachtschalt.lua"]:32: unexpected symbol

Started by astradragon, 06 April 2012 - 11:17 AM
astradragon #1
Posted 06 April 2012 - 01:17 PM
Hi all.
I try to program a night light get at the start but the following error:
bios :206: [string "nachtschalt.lua"]:32: unexpected symbol


while true do
term.clear()
term.setCursorPos(1,1)
local nTime = os.time()

taketime = textutils.formatTime(nTime,true)

test = string.find(taketime, ".0...")

found = "not found"
print(taketime)

while found == "not found" do
  if string.find(taketime, loopc..":..") ~=nil then
	found = loopc
	break
  else
	loopc = loopc - 1
  end
  if loopc < 0 then
	break
  end
end
   if found == 0 then
	  redstone.setOutput ("right",true)
   elseif found == 1 then
	  redstone.setOutput ("right",true)
   elseif found == 2 then
	  redstone.setOutput ("right",true)
   elseif found == 3 then
	  redstone.setOutput ("right",true)
   elseif found == 4 then
	  redstone.setOutput ("right",true)
   elseif found == 5 then
	  redstone.setOutput ("right",true)
   elseif found == 6 then
	  redstone.setOutput ("right",true)
   elseif found == 7 then
	  redstone.setOutput ("right",false)
   elseif found == 8 then
	  redstone.setOutput ("right",false)
   elseif found == 9 then
	  redstone.setOutput ("right",false)
   elseif found == 10 then
	  redstone.setOutput ("right",false)
   elseif found == 11 then
	  redstone.setOutput ("right",false)
   elseif found == 12 then
	  redstone.setOutput ("right",false)
   elseif found == 13 then
	  redstone.setOutput ("right",false)
   elseif found == 14 then
	  redstone.setOutput ("right",false)
   elseif found == 15 then
	  redstone.setOutput ("right",false)
   elseif found == 16 then
	  redstone.setOutput ("right",false)
   elseif found == 17 then
	  redstone.setOutput ("right",false)
   elseif found == 18 then
	  redstone.setOutput ("right",false)
   elseif found == 19 then
	  redstone.setOutput ("right",true)
   elseif found == 20 then
	  redstone.setOutput ("right",true)
   elseif found == 21 then
	  redstone.setOutput ("right",true)
   elseif found == 22 then
	  redstone.setOutput ("right",true)
   elseif found == 23 then
	  redstone.setOutput ("right",true)
   else
	  redstone.setOutput ("right",false)
	  redstone.setOutput ("top",true)
   end
	  print ("Timer aktiv")
   sleep(5)
end

Can somebody help please?
Mads #2
Posted 06 April 2012 - 04:43 PM
Well, I see and error at line 19:

loopc = loopc -
You don't subtract any value from loopc, so that will error. And with line 32, I can't see an error right now :)/>/>
astradragon #3
Posted 06 April 2012 - 08:08 PM
oh thanx, i didn't see that mistake
have corrected it, but now i get a new error…

nachtschalt.lua:23: attempt to concatenate nil and string
ComputerCraftFan11 #4
Posted 06 April 2012 - 08:12 PM
found is a "not found"
Your trying to do if found == #
You need to make found a number


Read the code wrong, ignore this
Hawk777 #5
Posted 07 April 2012 - 07:41 AM
On line 14 (not sure why your line numbers are so off, did you maybe leave some lines out in the copy+paste?), you try to concatenate the variable “loopc” with the string “:..”, but the variable “loopc” has never been given a value, so it contains “nil”.
astradragon #6
Posted 07 April 2012 - 08:35 AM
Oh damn… Thanx for the hint.
set loopc and it works. Thanks a lot to all your help