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

Button API Error

Started by TheWhiteFang, 03 July 2013 - 12:51 PM
TheWhiteFang #1
Posted 03 July 2013 - 02:51 PM
I am making a program that looks for certain text in the chat and does different actions depending on what is said. The first idea I had was for a turtle to give you food if you say that your hungry. There is a monitor that will run a program with three different buttons asking which kind of food you want to eat and clicking any of them makes a turtle drop that kind of food, but I keep getting an error for the button API im using and I don't know how to fix it.

My code: http://pastebin.com/GxLS986E (This program is on the computer next to the chatbox). http://pastebin.com/G71N9JpB (This is on the computer with the monitor on top of it and a wireless modem on the right of it). http://pastebin.com/8LP3v0i0 (This on the same computer with the monitor on top of it). http://pastebin.com/uBXhL6NU (This is on the turtle). http://pastebin.com/AZXTp8be (This is the button API).

The error I am getting after clicking the "Steak" button: button:74: attempt to call nil

Note: I am extremely new to Lua and ComputerCraft is general and if anything seems extraneous it is most likey so I can add on to it in the future.

Thanks in advance :)/>
Edited on 05 July 2013 - 05:52 PM
Lyqyd #2
Posted 05 July 2013 - 07:52 PM
Split into new topic.
LBPHacker #3
Posted 06 July 2013 - 04:52 AM
Computer with the monitor (8LP3v0i0):
Line 11: steak is nil
Line 12: porkchop is nil
Line 13: apple is nil

I see you've declared Steak below, but…
  1. Lua is case-sensitive, steak is not the same as Steak.
  2. It's declared after declaring fillTable. [not_sure]IIRC the indexing of steak will look for the upvalue of steak, since it can't find it in the current scope.[/not_sure] What I'm sure of is that you have to declare steak before declaring fillTable.