mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-16 18:55:03 -04:00
added sneaky
parameter to robot.swing, as discussed in #13
This commit is contained in:
parent
c0adb97603
commit
28c504d342
@ -117,19 +117,19 @@ function robot.durability()
|
||||
end
|
||||
|
||||
|
||||
function robot.swing(side)
|
||||
function robot.swing(side, sneaky)
|
||||
checkArg(1, side, "nil", "number")
|
||||
return component.computer.swing(sides.front, side)
|
||||
return component.computer.swing(sides.front, side, sneaky ~= nil and sneaky ~= false)
|
||||
end
|
||||
|
||||
function robot.swingUp(side)
|
||||
function robot.swingUp(side, sneaky)
|
||||
checkArg(1, side, "nil", "number")
|
||||
return component.computer.swing(sides.up, side)
|
||||
return component.computer.swing(sides.up, side, sneaky ~= nil and sneaky ~= false)
|
||||
end
|
||||
|
||||
function robot.swingDown(side)
|
||||
function robot.swingDown(side, sneaky)
|
||||
checkArg(1, side, "nil", "number")
|
||||
return component.computer.swing(sides.down, side)
|
||||
return component.computer.swing(sides.down, side, sneaky ~= nil and sneaky ~= false)
|
||||
end
|
||||
|
||||
function robot.use(side, sneaky, duration)
|
||||
|
@ -324,6 +324,7 @@ class Robot(val robot: tileentity.Robot) extends Computer(robot) with RobotConte
|
||||
else {
|
||||
ForgeDirection.VALID_DIRECTIONS.filter(_ != facing.getOpposite).toIterable
|
||||
}
|
||||
val sneaky = args.isBoolean(2) && args.checkBoolean(2)
|
||||
|
||||
def triggerDelay(delay: Double = Settings.get.swingDelay) = {
|
||||
context.pause(delay)
|
||||
@ -358,6 +359,8 @@ class Robot(val robot: tileentity.Robot) extends Computer(robot) with RobotConte
|
||||
|
||||
for (side <- sides) {
|
||||
val player = robot.player(facing, side)
|
||||
player.setSneaking(sneaky)
|
||||
|
||||
val (success, what) = Option(pick(player, Settings.get.swingRange)) match {
|
||||
case Some(hit) =>
|
||||
hit.typeOfHit match {
|
||||
@ -378,6 +381,8 @@ class Robot(val robot: tileentity.Robot) extends Computer(robot) with RobotConte
|
||||
else (false, "air")
|
||||
}
|
||||
}
|
||||
|
||||
player.setSneaking(false)
|
||||
if (success) {
|
||||
return result(true, what)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user