1
Fork 0

let goto break blocks

This commit is contained in:
Andy Killorin 2023-12-20 01:29:44 -06:00
parent 69e7d20df1
commit 292fa13c14
Signed by: ank
GPG key ID: B6241CA3B552BCA4
3 changed files with 15 additions and 9 deletions

View file

@ -92,12 +92,12 @@ local commands = {
["Backward"] = cyclefn(turtle.back), ["Backward"] = cyclefn(turtle.back),
["Up"] = cyclefn(turtle.up), ["Up"] = cyclefn(turtle.up),
["Down"] = cyclefn(turtle.down), ["Down"] = cyclefn(turtle.down),
["DropFront"] = turtle.dropfront, ["DropFront"] = turtle.drop,
["DropUp"] = turtle.dropup, ["DropUp"] = turtle.dropUp,
["DropDown"] = turtle.dropdown, ["DropDown"] = turtle.dropDown,
["SuckFront"] = turtle.suckfront, ["SuckFront"] = turtle.suck,
["SuckUp"] = turtle.suckup, ["SuckUp"] = turtle.suckUp,
["SuckDown"] = turtle.suckdown, ["SuckDown"] = turtle.suckDown,
["Select"] = turtle.select, ["Select"] = turtle.select,
["Refuel"] = turtle.refuel, ["Refuel"] = turtle.refuel,
["ItemInfo"] = iteminfo, ["ItemInfo"] = iteminfo,

View file

@ -169,9 +169,11 @@ async fn dig(
Json(req): Json<Vec3>, Json(req): Json<Vec3>,
) -> &'static str { ) -> &'static str {
let turtle = state.read().await.get_turtle(id).await.unwrap(); let turtle = state.read().await.get_turtle(id).await.unwrap();
let fuel = Position::new(Vec3::new(-19, 93, 73), blocks::Direction::East);
let inventory = Position::new(Vec3::new(-19, 92, 73), blocks::Direction::East);
tokio::spawn( tokio::spawn(
async move { async move {
mine::mine_chunk(turtle.clone(), req).await mine::mine(turtle.clone(), req, fuel, inventory).await
} }
); );

View file

@ -202,7 +202,7 @@ impl TurtleCommander {
} }
// easiest way to not eventually take over all memory // easiest way to not eventually take over all memory
let routing = timeout(Duration::from_secs(1), route(recent, pos, &world)); let routing = timeout(Duration::from_secs(2), route(recent, pos, &world));
let route = routing.await.ok()??; let route = routing.await.ok()??;
let steps: Vec<TurtleCommand> = route.iter().map_windows(|[from,to]| from.difference(**to).unwrap()).collect(); let steps: Vec<TurtleCommand> = route.iter().map_windows(|[from,to]| from.difference(**to).unwrap()).collect();
@ -212,7 +212,11 @@ impl TurtleCommander {
// valid routes will explicitly tell you to break ground // valid routes will explicitly tell you to break ground
if world.occupied(next_position.pos).await { if world.occupied(next_position.pos).await {
break 'route; if world.garbage(next_position.pos).await {
self.execute(dbg!(recent.dig(next_position.pos))?).await;
} else {
break 'route;
}
} }
let state = self.execute(command).await; let state = self.execute(command).await;