if value() then dig() else somethingElse() end
2
75 replies to this topic
#61
Posted 14 January 2013 - 03:35 PM
ahhh ok... i suggest inverting the returns in value() then... have it return true, indicating it can mine it, and false indicating it can't... then when using value() do
#62
Posted 14 January 2013 - 03:37 PM
wait i take it back. it almost works. for some reasone it skips an ore occationaly
#63
Posted 14 January 2013 - 03:39 PM
same type of ore or random?
#64
Posted 14 January 2013 - 03:42 PM
it would have to be random. since the program only identifies slot 1 2 and 3 of its inv which has dirt stone and gravel.
im thinking its skiping a compare one one or more of its turns.
edit
it skips ores on its back and left side reletive to starting orientation.
im thinking its skiping a compare one one or more of its turns.
edit
it skips ores on its back and left side reletive to starting orientation.
#65
Posted 14 January 2013 - 03:46 PM
hmmm not too sure... I'll have a look in a minute...
also what with your random
inside your while loop, you don't need to localise that code... you can remove that do end statement...
also what with your random
do end
inside your while loop, you don't need to localise that code... you can remove that do end statement...
#66
Posted 14 January 2013 - 03:56 PM
In your walls function:
Thats a scenario I imagined that could cause this problem. There are probably plenty more.
To solve this, turn right when value() returns true and when it returns false. So you will at least always check every wall.
function walls() for j = 1,4 do print("value function") if value() then turtle.dig() rn (base, "ore collected at "..z.." ") else turtle.turnRight() end end endLets say there is an ore when j = 1, the value function will return true, you'll dig the ore, sit still, then j increments to 2. Then value will return false, you'll turn right, and j increments to 3. say there is another ore here (we're only on the second wall at this point). value will return true, you'll dig, and then j will increment to 4. Value returns false, you turn right, but now the for loop is done, walls() returns and you never actually check the back or left wall.
Thats a scenario I imagined that could cause this problem. There are probably plenty more.
To solve this, turn right when value() returns true and when it returns false. So you will at least always check every wall.
#67
Posted 14 January 2013 - 03:57 PM
TheOriginalBIT, on 14 January 2013 - 03:46 PM, said:
hmmm not too sure... I'll have a look in a minute...
also what with your random
inside your while loop, you don't need to localise that code... you can remove that do end statement...
also what with your random
do end
inside your while loop, you don't need to localise that code... you can remove that do end statement...
edit: i added a turn right command after it collects ore so that should fix that. thanks
while true do print("2") f = turtle.getFuelLevel() if f < z + 10 then rn (base , "Danger! fuel levels low.") turtle.select(16) turtle.refuel() z = turtle.getFuelLevel() if f < z + 10 then rn (base , "Insuficient Coal, Returning.") home() end
#68
Posted 14 January 2013 - 04:02 PM
detsuo04, on 14 January 2013 - 03:57 PM, said:
you meen here?
while true do print("2") f = turtle.getFuelLevel() if f < z + 10 then rn (base , "Danger! fuel levels low.") turtle.select(16) turtle.refuel() z = turtle.getFuelLevel() if f < z + 10 then rn (base , "Insuficient Coal, Returning.") home() end
#71
Posted 14 January 2013 - 04:24 PM
lol missingno attacks
it worked all opperations are good. still have to check the out of fuel operation though.
it worked all opperations are good. still have to check the out of fuel operation though.
#74
Posted 15 January 2013 - 01:55 AM
Nice job
#76
Posted 15 January 2013 - 08:32 AM
thats some cool stuff. i think i will however first i need to revuild my base deeper into the earth. thousands of spiders keep screaming at me through the roof and zombies keep knocking like sales guys....
im wrighting a program now to tunnel out a room with player imputed variabls for x y and z
edit:
and the code is done.there is a moment where lil hal mines x to the end and comes back then he goes up z and mines x again.. then oddly he skips his up z step and runs the middle x again. after that he comtinues up and finishes the program.
he re runs the x on z 2 for every y. weired. anyway here is the code.
fixed
im wrighting a program now to tunnel out a room with player imputed variabls for x y and z
edit:
and the code is done.
he re runs the x on z 2 for every y. weired. anyway here is the code.
fixed
rednet.open("right") print("Room clearing program") sleep(1) print("What is my base id: ") a = tonumber(read()) rn = rednet.send rn (a , "connection established") print ("what is the rooms length (forward)?") x = tonumber(read()) print ("ok. Now the width (right)?") y = tonumber(read()) print ("ok. And finaly the hight (up)?") z = tonumber(read()) rn (a , "the room will be "..x.." long,") rn (a , " "..y.." wide,") rn (a , "and "..z.." tall.") --======paramiters of room are set=======-- print ("Is the size right? ") b = read() if b ~= "yes" then os.shutdown() end f = turtle.getFuelLevel() rn (a , "fuel is "..f.." units.") need = (x*y*z) + x + y + z rn (a , "assignment needs "..need.." fuel") if f < need then rn (a , "incificient fuel for assignment") os.shutdown() end x2 = 1 y2 = 0 z2 = 1 done = 0 l = 0 while l == 0 do while y2 ~= y do while z2 ~= z do while x2 ~= x do turtle.dig() turtle.forward() x2 = x2 +1 end while x2 ~= 1 do turtle.back() x2 = x2 - 1 end if z2 ~= z then turtle.digUp() turtle.up() z2 = z2 + 1 end while x2 ~= x and z2 == z do turtle.dig() turtle.forward() x2 = x2 + 1 end while x2 ~= 1 and z2 == z do turtle.back() x2 = x2 - 1 end end while z2 ~= 1 do turtle.down() z2 = z2 - 1 end if y2 ~= y and l == 0 then turtle.turnRight() turtle.dig() turtle.forward() turtle.turnLeft() y2 = y2 + 1 end end l = 1 end
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users