6 posts
Posted 17 August 2012 - 09:21 PM
I did the code but when i reboot it says bios:206: [string "startup"]:28: unfinished string
I'm using a height:4 width:2 monitor with mining turtle
code:
function counter()
local i = 0
return function() i = i + 1 return i end
end
function modStr(num)
if num < 10 then
return "0" .. num
else
return num
end
end
while true do
if turtle.detect() then
turtle.dig()
term.clear()
term.setCursorPos(1,1)
local total = 0
for i=1,9,1 do
total = total + turtle.getItemCount(i)
end
for i=1,9,1 do
print("Row " .. i .. ": " .. turtle.getItemCount(i) .. " (" .. math.floor((turtle.getItemCount(i)/total)*100) .. "%)")
end
print("Total: " .. total)
print("—————–")
local iterator = counter()
print(" ___ ___ ___ ")
print("|" .. modStr(turtle.getItemCount(iterator())) .. " |" .. modStr(turtle.getItemCount(iterator())) .. " |" .. modStr(turtle.getItemCount(iterator())) .. " |")
print("|___|___|___|")
print("|" .. modStr(turtle.getItemCount(iterator())) .. " |" .. modStr(turtle.getItemCount(iterator())) .. " |" .. modStr(turtle.getItemCount(iterator())) .. " |")
print("|—|—|—|")
print("|" .. modStr(turtle.getItemCount(iterator())) .. " |" .. modStr(turtle.getItemCount(iterator())) .. " |" .. modStr(turtle.getItemCount(iterator())) .. " |")
print("|___|___|___|")
print(" ")
print("—————–")
print("Cobble Farmer")
end
totalcount = turtle.getItemCount(9)
if totalcount == 64 then
term.clear()
term.setCursorPos(1,1)
print("Dropping Stacks")
print("…Please wait.")
sleep(1)
for i=1,9 do
turtle.select(i)
turtle.drop()
end
turtle.select(1)
end
end
3790 posts
Location
Lincoln, Nebraska
Posted 17 August 2012 - 09:34 PM
print("Row " .. i .. ": " .. turtle.getItemCount(i) .. " (" .. math.floor((turtle.getItemCount(i)/total)*100) .. "%)")
This is the line that's throwing the error, but I don't know why it says unfinished string…
Try defining math.floor((turtle.getItemCount(i)/total)*100) as a variable, then calling back to it. Like this:
local b = math.floor((turtle.getItemCount(i)/total)*100)
print("Row " .. i .. ": " .. turtle.getItemCount(i) .. " (" .. b .. "%)")
Other than that, I don't know…
6 posts
Posted 17 August 2012 - 09:35 PM
it will work?
3790 posts
Location
Lincoln, Nebraska
Posted 17 August 2012 - 09:36 PM
Yeah. You can define a variable almost any way you want. As long as the result is not nil, you should be fine.]
EDIT: Just make sure you put the local variable within the for/do statement.
6 posts
Posted 17 August 2012 - 09:37 PM
well im new to this so thanks ill go try now
839 posts
Location
England
Posted 17 August 2012 - 09:41 PM
print("Row " .. i .. ": " .. turtle.getItemCount(i) .. " (" .. math.floor((turtle.getItemCount(i)/total)*100) .. "%)")
This is the line that's throwing the error, but I don't know why it says unfinished string…
Try defining math.floor((turtle.getItemCount(i)/total)*100) as a variable, then calling back to it. Like this:
local b = math.floor((turtle.getItemCount(i)/total)*100)
print("Row " .. i .. ": " .. turtle.getItemCount(i) .. " (" .. b .. "%)")
Other than that, I don't know…
I think you miscounted. I counted the lines, then pasted the code into notepad++ and both times I got
print("|" .. modStr(turtle.getItemCount(iterator())) .. " |" .. modStr(turtle.getItemCount(iterator())) .. " |" .. modStr(turtle.getItemCount(iterator())) .. " |")
So unless there are spaces before the start of counter(), this is the line with the issue.
Though I must admit I tried it in 1.4 and aside from the slot numbers being different, it seemed to work fine.
3790 posts
Location
Lincoln, Nebraska
Posted 17 August 2012 - 09:44 PM
HAHA, yeah, you're right! I miscounted COMPLETELY…. Sorry, ericpwnz. My bad.
839 posts
Location
England
Posted 17 August 2012 - 09:47 PM
HAHA, yeah, you're right! I miscounted COMPLETELY…. Sorry, ericpwnz. My bad.
This is why notepad++ counts lines for you lol
6 posts
Posted 17 August 2012 - 09:53 PM
it doesn't work um i need help
839 posts
Location
England
Posted 17 August 2012 - 09:55 PM
it doesn't work um i need help
Are you using CC version 1.3? And tekkit?
What isn't working about it?
6 posts
Posted 17 August 2012 - 10:03 PM
im using tekkit
6 posts
Posted 17 August 2012 - 10:14 PM
can anyone some in my server and help me i am really bad at fixing this
ip: 5.240.173.193
839 posts
Location
England
Posted 17 August 2012 - 10:14 PM
im using tekkit
Ok, that's one question answered (and I'm guessing you could count it as two since tekkit has yet to update CC)
As for the problem. What part isn't working? I ran the code you have there on a turtle in 1.4, and even ran it on a monitor and it counted all the blocks I placed in front of it. It didn't move ofc, but aside from that it ran fine.