Jump to content




MobSpwan:19: attempt to call nil

api computer peripheral

2 replies to this topic

#1 cohen2604

  • New Members
  • 1 posts

Posted 14 August 2015 - 09:45 AM

this is my code
and i have this problem "MobSpwan:19: attempt to call nil"

os.loadAPI("Button")
m = peripheral.wrap("top")
m.clear()
local lightsOn = false

function toggleSpawners()
rednet.open("left")
if lightsOn then
print("Turning the lights ON")
rednet.broadcast("lightsON")
else
print("Turning the lights OFF")
rednet.broadcast("lightsOFF")
end
rednet.close("left")
end

function fillTable()
Button.setTable("Lights",spawnersOn,10,20,3,5)
Button.screen()
end

function getClick()
event,side,x,y = os.pullEvent("monitor_touch")
Button.checkxy(x,y)
end

function spawnersOn()
Button.toggleButton("Lights")
rednet.open("left")
lightsON = not lightsOn
toggleSpawners()
end

fillTable()
Button.heading("Mod Farm")
Button.label(1,4,"Lights")
toggleSpawners()
while true do
getClick()
end

#2 Exerro

  • Members
  • 801 posts

Posted 14 August 2015 - 08:19 PM

Button.setTable is nil. Are you defining the global 'setTable' function in the Button API? Posting the code of all relevant files (i.e. including "Button") is more likely to fix your problem, and please use the code tag ([code]) around code as it makes it so much more readable.

#3 HPWebcamAble

  • Members
  • 933 posts
  • LocationWeb Development

Posted 14 August 2015 - 08:33 PM

I assume you actually have the file "button" on the computer you are running this on.

I can't remember, but I think os.loadAPI is case sensitive, try 'button', instead of 'Button', if that's what the file is named.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users