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

table seems to be nil, after adding variables to it? [lua]

Started by Goof, 06 January 2013 - 11:27 PM
Goof #1
Posted 07 January 2013 - 12:27 AM
Hi..

i am getting an error which i cant figure out why.. i have looked through my code several times, but i cannot find the error.

Error:
parallel:22: parallel:4: bad argument: function expected, got bolean


code
http://pastebin.com/gHtscyLc


thanks in advance.



EDIT
i just updated this, instead of making a whole new post:

When doing this code, ( adding variables to a table ) then the table seems to be nil, still..



function sObj1(...) -- XCor, YCor, TxtIcon, BacColor, TxtColor --
  if obj then
	local tArgs = {...} -- x, y, Icon Msg, bacColor, txtColor
	  if #tArgs ~= nil then
		tP(tArgs[1], tArgs[2])
		tB(tArgs[4])
		tT(tArgs[5])
		tW("		 ")
		tP(tArgs[1], tArgs[2]+1)
		tW(tArgs[3])
		tP(tArgs[1], tArgs[2]+2)
		tW("		 ")
	  end
	table.insert(ChorMsg, tArgs[3])
	table.insert(ChorsX, tArgs[1])
	table.insert(ChorsY, tArgs[2])
	table.insert(ChoreX, tArgs[1]+8)
	table.insert(ChoreY, tArgs[2]+2)
  end
end

sObj1(5,5, "  Console  ", black, white) -- black and white is defined in top of my whole program --


and im getting the error, when using the mouse_ click:



function mouse()
  local event, mB1, xM1, yM1 = os.pullEvent("mouse_click")
	if event == "mouse_click" then
	  if mB1 == 2 then
		if xM1 >= ChorsX[1] and xM1 <= ChoreX[1] and yM1 >= ChorsY and yM1 <= ChoreY then -- on this.... when calling the ChorsX[1] (which is global to the program) it looks like the table has been removed, or is nil.. ehm -                                ----- why--

		else
		  sRM(xM1, yM1, black, white, 4, "   Stop   ", " Settings ", "  Reboot  ", " Shutdown ")
			if event2 == "mouse_click" then
			  if mB2 == 1 then
				if xM2 >= xM1 and xM2 <= xM1 + 8 and yM2 == yM1 + 1 then 
				  tP(xM1-5, yM1-2)
				  tB(black)
				  tT(white)
				  clear()
				  run, tRun, obj, sBor, loop, sIcon = false
				elseif xM2 >= xM1 and xM2 <= xM1 + 8 and yM2 == yM1 + 2 then
				  tRun, obj, sBor, sIcon1 = false
				  shell.run("edit "..sett2)
				  sleep(0.8)
				  tB(lightGray)
				  tT(white)
				  clear()
				  run = true
				  tRun = true
				  obj = true
				  sBor = true
				  loop = true
				  sIcon1 = true
				else
				  tB(lightGray)
				  tT(white)
				  clear()
				end
			  else
				tB(lightGray)
				tT(white)
				clear()
			  end
			end
		  end
		elseif mB1 == 1 then

		end
	end
end

Thanks in Advance
remiX #2
Posted 07 January 2013 - 12:34 AM
You're using "sIcon" as a function and a variable (boolean variable)
Goof #3
Posted 07 January 2013 - 12:37 AM
i am really so stupid…

You are my hero.

Thanks
Goof #4
Posted 07 January 2013 - 05:33 AM
Look at the OP… it has just been edited to a new error i've found, during a table.. which counts as nil :o/>

Thanks in advance
ChunLing #5
Posted 07 January 2013 - 09:53 PM
Ah…which table? Could you highlight the line where the table is nil?
remiX #6
Posted 07 January 2013 - 10:04 PM
do a debug line, just before comparing xM1 with ChorsX[1] do this:

print(ChorsX[1]) sleep(3) -- so you can read it.
Also, is ChorsY not a table?

[edit]
Yes, ChorsY is a table because you do:
table.insert(ChorsY, tArgs[2]) 
in the above code. So that should error too.
[/edit]

PS:

run, tRun, obj, sBor, loop, sIcon = false
tRun, obj, sBor, sIcon1 = false

-- Doing this will only set the first value to false and the rest will be come nil.

run, tRun, obj, sBor, loop, sIcon = false, false, false, false, false
tRun, obj, sBor, sIcon1 = false, false, false, false

-- Proper way to make them all false
Goof #7
Posted 08 January 2013 - 12:07 AM
Well okay. About the
variables and the rest Are nil then. Okay. But it still worked for me, Without the rests of the "false"
. But thanks anyway.

:D/>