1
Attempt to compare nil with number
Started by NocturnalDanger, Jun 14 2016 04:30 AM
computer peripheral lua
5 replies to this topic
#1
Posted 14 June 2016 - 04:30 AM
So I posted this on the FTB forums and didnt get a reply, I assume Id get more help here.
If youve seen my other post, about liquid sorting from a smeltery, then you have some idea what this is.
Basically I have a smeltery I want to control VIA ComputerCraft with Redstone Signals. I have 48 tanks connected with Ender Fluid Ducts with Bundled Cabled connected to them.
My Monitor is connected with a network cable, on the bottom. Sides Left, Back, and Right all have bundled cables connected to tanks, with all 16 colors. Side Top is to the smeltery. White is for taking liquids out.
My error is Tinkers:16: Attempt to compare nil with number
My code:
http://pastebin.com/cvyyYjLH
Original post: http://forum.feed-th...ft-help.158448/
#2
Posted 14 June 2016 - 04:49 AM
line 15 should read...
Right now you're pulling all events since monitor_touch (without quotes) is a variable that is undefined and therefor nil. That's why you're getting attempt to compare nil with number because an event other than "monitor_touch" is triggering your os.pullEvent line but isn't supplying values for xPos, and/or yPos.
event, side, xPos, yPos = os.pullEvent("monitor_touch")note the quotes around monitor_touch
Right now you're pulling all events since monitor_touch (without quotes) is a variable that is undefined and therefor nil. That's why you're getting attempt to compare nil with number because an event other than "monitor_touch" is triggering your os.pullEvent line but isn't supplying values for xPos, and/or yPos.
#3
Posted 14 June 2016 - 05:01 AM
Dog, on 14 June 2016 - 04:49 AM, said:
line 15 should read...
Right now you're pulling all events since monitor_touch (without quotes) is a variable that is undefined and therefor nil. That's why you're getting attempt to compare nil with number because an event other than "monitor_touch" is triggering your os.pullEvent line but isn't supplying values for xPos, and/or yPos.
event, side, xPos, yPos = os.pullEvent("monitor_touch")note the quotes around monitor_touch
Right now you're pulling all events since monitor_touch (without quotes) is a variable that is undefined and therefor nil. That's why you're getting attempt to compare nil with number because an event other than "monitor_touch" is triggering your os.pullEvent line but isn't supplying values for xPos, and/or yPos.
Thank you, and later in the code I have
if event == monitor_touchIs that right? Because it isnt stopping the redstone signal. (Well, bundled cable-white signal, lol)
Edit: Or going back to the beginning of the main loop. ("while true do" line 14)
Edited by NocturnalDanger, 14 June 2016 - 05:49 AM.
#4
Posted 14 June 2016 - 05:49 AM
As Dog just explained, "monitor_touch" is a string (which is what you want here), and monitor_touch is a variable (which you haven't defined, so it has no content).
Edited by Bomb Bloke, 14 June 2016 - 05:49 AM.
#5
Posted 14 June 2016 - 06:46 AM
Bomb Bloke, on 14 June 2016 - 05:49 AM, said:
As Dog just explained, "monitor_touch" is a string (which is what you want here), and monitor_touch is a variable (which you haven't defined, so it has no content).
So on line 24, I need quotes around it? I've tried that. Is there a specific way to make it a string?
Sorry, I'm fairly new to thing language.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users