let goto break blocks
This commit is contained in:
parent
69e7d20df1
commit
292fa13c14
3 changed files with 15 additions and 9 deletions
|
@ -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,
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
|
|
Loading…
Reference in a new issue