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

A feature for an enchanting system w/ turtle

Started by KiraGio, 01 May 2013 - 07:08 AM
KiraGio #1
Posted 01 May 2013 - 09:08 AM
Title: "A feature for an enchanting system w/ turtle"
Hello, I've got this code from Direwolf20, I've edited a bit of it.
http://pastebin.com/4mdrCL8C

What should I add for chosing in-screen the enchantment level?
QuantumGrav #2
Posted 01 May 2013 - 12:14 PM
In the "enchantBook()" function, change it to this, and simply input the number of what level you would like to enchant at.


function enchantBook()
	 turtle.select(1)
	 turtle.suckUp()
	 turtle.dropUp(turtle.getItemCount(1)-1)
	 while true do
	    term.write("How many levels should I enchant? : ")
	    nLevels = io.read()  -- Main line for getting input.  Look up a tutorial if you aren't familiar with io.read(), it's very useful!
	    if tonumber(nLevels) and tonumber(nLevels) > 0 and tonumber(nLevels) <= 30 then
		   nLevels = tonumber(nLevels)
		   break
	    end
	 end
	 m.enchant(nLevels)
	 turtle.dropUp()
end

If you want to not have to manually input a number every time, simply change the 30 in Direwolf's code to whatever level you would like. Hope that helps!
KiraGio #3
Posted 01 May 2013 - 12:39 PM
In the "enchantBook()" function, change it to this, and simply input the number of what level you would like to enchant at.


function enchantBook()
	 turtle.select(1)
	 turtle.suckUp()
	 turtle.dropUp(turtle.getItemCount(1)-1)
	 while true do
		term.write("How many levels should I enchant? : ")
		nLevels = io.read()  -- Main line for getting input.  Look up a tutorial if you aren't familiar with io.read(), it's very useful!
		if tonumber(nLevels) and tonumber(nLevels) > 0 and tonumber(nLevels) <= 30 then
		   nLevels = tonumber(nLevels)
		   break
		end
	 end
	 m.enchant(nLevels)
	 turtle.dropUp()
end

If you want to not have to manually input a number every time, simply change the 30 in Direwolf's code to whatever level you would like. Hope that helps!
Wow! That helped a lot, thanks!
If I don't bother you, How could I connect it to a touch screen monitor? Would it be too long?