Jump to content




A feature for an enchanting system w/ turtle


  • You cannot reply to this topic
2 replies to this topic

#1 KiraGio

  • Members
  • 18 posts

Posted 01 May 2013 - 08: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?

#2 QuantumGrav

  • Members
  • 36 posts
  • LocationUnited States

Posted 01 May 2013 - 11:14 AM

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!

#3 KiraGio

  • Members
  • 18 posts

Posted 01 May 2013 - 11:39 AM

View PostQuantumGrav, on 01 May 2013 - 11:14 AM, said:

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?





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users