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

Mob Farm Code Error

Started by cocotoffee, 02 September 2014 - 11:34 PM
cocotoffee #1
Posted 03 September 2014 - 01:34 AM
I am trying to create a code for an advanced monitor that I can click to change the active mob in a MFR auto-spawner. I am trying to automate this with a peripheral proxy but the basic selection part of the code I can not seem to get working. I want to just click the menu at the top then the mob, but when I try to click the menu the error: mobfarm:57: attempt to compare nil with number occurs. I greatly appreciate any help that is given! Thank you!

Code (I couldn't get the paste function to work): Pastebin at BSdryL92

Picture: Pastebin at ZmZS5kqT.

Please and thank you!
KingofGamesYami #2
Posted 03 September 2014 - 02:39 AM
lua is case sensitive.

while true do
local event, button, x, y = os.pullEventRaw() --#lowercase x, y
  if slc == 0 then
    if event == "mouse_click" then
      if X >=2 and X <=8 and Y ==1 and button ==1 then --#uppercase X, Y
      drawMenu1()
      slc = 1
        else
        drawDesktop()
      end
    end
   elseif slc == 1 then
     if X >=1 and X <=11 and button ==1 and Y==3 then slc = 0 --#uppercase X, Y
       os.reboot()
       else
       slc = 0
       drawDesktop()

     end
  end
end
cocotoffee #3
Posted 03 September 2014 - 05:09 AM
Oh my gosh! Thank you so much!!! It is working perfectly now! On a side note, if I were to make all the coordinates lowercase would that work, as long as they are consistent? Or do they have to be uppercase for lua no matter what?
Bomb Bloke #4
Posted 03 September 2014 - 08:25 AM
It doesn't matter whether they're uppercase or not, so long as they're consistent.
cocotoffee #5
Posted 03 September 2014 - 10:45 PM
Thank you! I'll be sure to remember this in the future.