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

MobSpwan:19: attempt to call nil

Started by cohen2604, 14 August 2015 - 08:45 AM
cohen2604 #1
Posted 14 August 2015 - 10: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
Exerro #2
Posted 14 August 2015 - 09: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 (
) around code as it makes it so much more readable.
HPWebcamAble #3
Posted 14 August 2015 - 09: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.