I'm going to preface this topic with letting you know that I am a complete novice when it comes to programming. I've taken one class of C++, which thankfully translates fairly well to LUA. However, that means the extend of my knowledge with programming with turtles basically extends to loops, functions to keep things concise, and using the API's to the best of my abilities. I've learned how to use a couple of the slightly more complicated aspects (such as tArgs, if that counts as complex), but since I'm the only turtle programmer on our server, I don't use them in the name of user-friendliness.
That said, I would like to make a program that will let a turtle automatically kill mobs for me with a grinder, and to collect the EXP that drops. I know all the API functions I need to do this with, it's just a matter of getting it to work right. One thing I do know is that I've read that constant attack loops with a turtle, i.e.
while true do
turtle.attack()
end
Can cause lag or framerate issues overtime. In order to avoid that, I tried something like this
while true do
if redstone.getInput("front") then
turtle.attack()
end
end
I put a pressure plate in front of the turtle, and whenever something stands on it, the turtle will attack it. Very brute force, and not very elegant. Of course, I ran into the only natural thing; if the while loop goes too long without doing anything, the program terminates. I didn't expect anything different, this was just the starting step to make sure my thought process on this was working.
So now my only idea is to make the program temporary via a for loop, i.e.
for i=1 to ## do
if redstone.getInput("front") then
turtle.attack()
end
end
However, I'm pretty sure the same thing will happen. The only other thing I can think of is to put a sleep of a couple minutes or so after the if statement, that way mobs can accumulate, the turtle will attack them until they all die, and life continues as normal. I would use a similar program with my EXP turtles, having them collect experience every few minutes or so automatically.
Again, I'm a complete novice at programming, so anything really complex and out there is just going to be beyond me. I program turtles for fun, and I know my programs are incredibly inefficient, clumsy, and any real programmer would probably cry at my attempts. I love my turtles though, and I try to use them often, and this is just the next thing I want to use them for.
That said, I would like to make a program that will let a turtle automatically kill mobs for me with a grinder, and to collect the EXP that drops. I know all the API functions I need to do this with, it's just a matter of getting it to work right. One thing I do know is that I've read that constant attack loops with a turtle, i.e.
while true do
turtle.attack()
end
Can cause lag or framerate issues overtime. In order to avoid that, I tried something like this
while true do
if redstone.getInput("front") then
turtle.attack()
end
end
I put a pressure plate in front of the turtle, and whenever something stands on it, the turtle will attack it. Very brute force, and not very elegant. Of course, I ran into the only natural thing; if the while loop goes too long without doing anything, the program terminates. I didn't expect anything different, this was just the starting step to make sure my thought process on this was working.
So now my only idea is to make the program temporary via a for loop, i.e.
for i=1 to ## do
if redstone.getInput("front") then
turtle.attack()
end
end
However, I'm pretty sure the same thing will happen. The only other thing I can think of is to put a sleep of a couple minutes or so after the if statement, that way mobs can accumulate, the turtle will attack them until they all die, and life continues as normal. I would use a similar program with my EXP turtles, having them collect experience every few minutes or so automatically.
Again, I'm a complete novice at programming, so anything really complex and out there is just going to be beyond me. I program turtles for fun, and I know my programs are incredibly inefficient, clumsy, and any real programmer would probably cry at my attempts. I love my turtles though, and I try to use them often, and this is just the next thing I want to use them for.