Jump to content




Attempt to compare nil with number

computer peripheral lua

5 replies to this topic

#1 NocturnalDanger

  • Members
  • 8 posts

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 Dog

  • Members
  • 1,179 posts
  • LocationEarth orbit

Posted 14 June 2016 - 04:49 AM

line 15 should read...
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 NocturnalDanger

  • Members
  • 8 posts

Posted 14 June 2016 - 05:01 AM

View PostDog, on 14 June 2016 - 04:49 AM, said:

line 15 should read...
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_touch
Is 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 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

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 NocturnalDanger

  • Members
  • 8 posts

Posted 14 June 2016 - 06:46 AM

View PostBomb 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.

#6 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 14 June 2016 - 07:18 AM

Yes, you wrap it in quotes. It'd be worth reading this tutorial.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users