this is code
http://pastebin.com/rR9JXSvy (This Is One i want to fix)
Github if you how to pull request.
Here
-- Checking
function check()
..
if Error == 1 then
..
recheck()
else
..
Lenght()
end
end
-- Recheck if user forget something turtle will check after 15 sec
function recheck()
..
check()
end
-- Run Command aka start up command
function run()
..
if High == Hc then
print("done")
else
Lenght()
end
end
-- Mining for length
function Lenght()
..
if Wide == Wc then
..
run()
else
wide()
end
end
-- Mining Wide
function wide()
..
if Wide == WC then
..
run()
else
Lenght()
end
end
..
check()
-- Mining Wide
function wide()
..
if Wide == WC then
..
return run()
else
return Lenght()
end
end
-- Checking
function check()
while Error == 1
..
if Error == 1 then recheck() end
end
..
while true do
while true do
if Lenght() then break end
if wide() then break end
end
if run() then break end
end
print("done")
end
-- Recheck if user forget something turtle will check after 15 sec
function recheck()
..
end
-- Run Command aka start up command
function run()
..
return High == Hc
end
-- Mining for length
function Lenght()
..
return Wide == Wc
end
-- Mining Wide
function wide()
..
return Wide == WC
end
..
check()
taking a look i think the logic that better matches OP code would beif Lenght() then break end if wide() then break end
if Lenght() and wide() then break end
while true do -- Start a loop that repeats indefinitely.
while true do -- Start another loop that repeats indefinitely.
if Lenght() then break end -- If the value returned by Lenght() is true, then jump out of the second loop.
if wide() then break end -- If the value returned by wide() is true, then jump out of the second loop.
end -- This marks the end of the second loop.
if run() then break end -- If the value returned by run() is true, then jump out of the first loop.
end -- This marks the end of the first loop.
repeat
repeat until Lenght() or wide()
until run()
is there currently a problem, or are you just giving an update on progress?i spent about 2 day rewritten the program i think i`m almost done with programs
http://pastebin.com/rR9JXSvy
local requirements = {
{func = turtle.getItemCount, args = {1}, compare = 0, success = false, trueMessage = "Turtle has fuel", failMessage = "Turtle has no fuel\nPut fuel in slot 1 and 2"};
{func = turtle.getItemCount, args = {2}, compare = 0, success = false, trueMessage = "", failMessage = "Turtle has no extra fuel\nBut if it is a short job it's okay"};
{func = turtle.getItemCount, args = {3}, compare = 0, success = false, trueMessage = "Turtle has chest", failMessage = "No chest in Turtle\nPut chest in slot 3"};
}
local function check()
local success = true
repeat
term.clear()
term.setCursorPos(1,1)
for _,condition in ipairs(requirements) do
local pass = condition.func(unpack(args)) == condition.comp
if condition.success ~= pass then
condition.success = pass
end
if condition.success and condition.trueMessage ~= "" then
print(condition.trueMessage)
elseif condition.failMessage ~= "" then
print(condition.failMessage)
success = false
end
end
if not success then
print("Missing items. Waiting...")
os.pullEventRaw("turtle_inventory")
end
until success
print("All items are present. Starting...")
end
--# other program code
check()
run()
--[[
# define a table of all the conditions to check
#
# the first key 'func' is a function to call, this can be any function you wish, even one of your own
# the second key 'args' is the arguments to give to the function when calling it, you can have any amount you wish as long as it exists
# e.g. args = {1,5,'foo'} will give 1, 5, and 'foo' to the function
# the third key 'compare' is what value should be to the right of the if statement conditional
# e.g. compare = 'foo' will check that the result returned from the function was a string 'foo' (func() == 'foo')
# the fourth key 'success' is used internally to see if it has previously passed
# the fifth key 'trueMessage' is the message if the conditional passed
# the sixth key 'failMessage' is the message if the conditional fails
#
# basic example (no args):
# {func = turtle.getFuelLevel, args = {}, compare = 0, success = false, trueMessage = "Turtle does not have fuel", failMessage = "Turtle has fuel"};
#
# example (with args):
# {func = turtle.getItemCount, args = {2}, compare = 0, success = false, trueMessage = "", failMessage = "Turtle has no extra fuel\nBut if it is a short job it's okay"};
--]]
local requirements = {
{func = turtle.getItemCount, args = {1}, compare = 0, success = false, trueMessage = "Turtle has fuel", failMessage = "Turtle has no fuel\nPut fuel in slot 1 and 2"};
{func = turtle.getItemCount, args = {2}, compare = 0, success = false, trueMessage = "", failMessage = "Turtle has no extra fuel\nBut if it is a short job it's okay"};
{func = turtle.getItemCount, args = {3}, compare = 0, success = false, trueMessage = "Turtle has chest", failMessage = "No chest in Turtle\nPut chest in slot 3"};
}
--# we define the function as local, anywhere it is called must be below this function!
local function check()
--# we use this to know when to stop checking
local success = true
repeat
--# clear the screen ready to output the latest information
term.clear()
term.setCursorPos(1,1)
--# go through the requirements
for _,condition in ipairs(requirements) do
--# run the check, call the function with all the args and make sure it returns what we're expecting
local pass = condition.func(unpack(args)) == condition.comp
--# if it has a different result to last time then update the result
if condition.success ~= pass then
condition.success = pass
end
--# output messages
--# if it has passed tests and there is a message
if condition.success and condition.trueMessage ~= "" then
--# output the message
print(condition.trueMessage)
--# it has clearly failed, if there is a failure message then
elseif condition.failMessage ~= "" then
--# output the message
print(condition.failMessage)
--# make sure the loop runs again, this test failed
success = false
end
end
--# did we get through all the checking successfully?
if not success then
print("Missing items. Waiting...")
--# wait until the user changes something in the inventory
os.pullEventRaw("turtle_inventory")
end
--# loop again if we didn't have everything we're waiting for
until success
print("All items are present. Starting...")
end
--# other program code
check()
--# start the program running here, for example like below
run()