CreateMod/src/main/java/com/simibubi/create/compat/computercraft/SpeedControllerPeripheral.java
caelwarner 654476d9f3
Added Rotation Speed Controller and Sequenced Gearshift as peripherals
- Rotation Speed Controller can get and set targetSpeed
- Sequenced Gearshift can rotate by a certain angle and move a certain distance
2022-10-03 20:05:25 -07:00

41 lines
953 B
Java

package com.simibubi.create.compat.computercraft;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollValueBehaviour;
import dan200.computercraft.api.lua.LuaFunction;
import dan200.computercraft.api.peripheral.IPeripheral;
public class SpeedControllerPeripheral implements IPeripheral {
private final ScrollValueBehaviour targetSpeed;
public SpeedControllerPeripheral(ScrollValueBehaviour targetSpeed) {
this.targetSpeed = targetSpeed;
}
@LuaFunction(mainThread = true)
public void setTargetSpeed(int speed) {
this.targetSpeed.setValue(speed);
}
@LuaFunction
public float getTargetSpeed() {
return this.targetSpeed.getValue();
}
@NotNull
@Override
public String getType() {
return "Create_RotationSpeedController";
}
@Override
public boolean equals(@Nullable IPeripheral other) {
return this == other;
}
}