feat(mover): switch between moving and riding automatically for manual movement

This commit is contained in:
jay 2021-01-28 02:18:42 +05:00
parent d953bd4cf6
commit f336e3d736

View File

@ -103,6 +103,16 @@ function ride(entity) {
bot.mount(vehicle)
}
function moveOrRide(turn = false, reverse = -1, directionLabel, message_parts2) {
// bot.once("attach", state = "vehiccel")
if (bot.vehicle) {
const amount = parseInt(message_parts2[0]) || 10 * -reverse
bot.moveVehicle(turn && amount || 0, !turn && amount || 0)
} else {
command([directionLabel].concat(message_parts2))
}
}
function hit(blockOrEntity) {
bot.chat(`hitting ${entity.name || entity.type}`)
}
@ -221,19 +231,19 @@ function command(message_parts, player) {
break
case "w":
case "f":
command(["forward"].concat(message_parts.slice(1)))
moveOrRide(0, -1, "forward", message_parts2)
break
case "s":
case "b":
command(["back"].concat(message_parts.slice(1)))
moveOrRide(0, 1, "back", message_parts2)
break
case "a":
case "l":
command(["right"].concat(message_parts.slice(1)))
moveOrRide(1, -1, "right", message_parts2)
break
case "d":
case "r":
command(["left"].concat(message_parts.slice(1)))
moveOrRide(1, 1, "left", message_parts2)
break
case "back":
case "forward":