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

Auto-enchanting script help

Started by swid120, 14 July 2013 - 12:17 PM
swid120 #1
Posted 14 July 2013 - 02:17 PM
Hey,

I am using a xp turtle to auto enchant books and I want the AutoCollect option to be changable using some buttons on an advanced monitor. The variable to do so is changd but, the turle doen't change its state. Print() tells me if atc is true/false but it stays at true for the command. Buttons are created with Direwolf20 button Api

Here`s my code

os.loadAPI("button")
m = peripheral.wrap("top")
m.clear()
xp = peripheral.wrap("right")
local atc = true

function fillTable()
button.setTable("Coll", test1, 10,15,3,5)
button.setTable("Test2", test2, 10,15,7,9)
button.screen()
end

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

xp.setAutoCollect(atc)

function test1()
 button.toggleButton("Coll")
  if atc == true then
   atc = false
  else
   atc = true
  end
 xp.setAutoCollect(atc)
 end

function test2()
 button.flash("Test2")
end

fillTable()

while true do
getClick()
print(xp.getLevels())
print(atc)
end
Edited on 14 July 2013 - 12:19 PM
Lyqyd #2
Posted 15 July 2013 - 01:04 PM
Split into new topic.
swid120 #3
Posted 17 July 2013 - 10:23 AM
Any ideas?