diff --git a/src/main/java/com/simibubi/create/compat/computercraft/implementation/peripherals/StationPeripheral.java b/src/main/java/com/simibubi/create/compat/computercraft/implementation/peripherals/StationPeripheral.java index 3f40a9f210..bbf29d063d 100644 --- a/src/main/java/com/simibubi/create/compat/computercraft/implementation/peripherals/StationPeripheral.java +++ b/src/main/java/com/simibubi/create/compat/computercraft/implementation/peripherals/StationPeripheral.java @@ -4,6 +4,8 @@ import javax.annotation.Nullable; +import com.simibubi.create.content.trains.graph.DimensionPalette; + import org.jetbrains.annotations.NotNull; import com.simibubi.create.AllPackets; @@ -102,6 +104,19 @@ public final boolean isTrainPresent() throws LuaException { return station.getPresentTrain() != null; } + @LuaFunction + public final CreateLuaTable getPresentTrain() throws LuaException { + GlobalStation station = blockEntity.getStation(); + if (station == null) + throw new LuaException("station is not connected to a track"); + + if (station.getPresentTrain() == null) + return null; + + DimensionPalette dimensions = new DimensionPalette(); + return fromCompoundTag(station.getPresentTrain().write(dimensions)); + } + @LuaFunction public final boolean isTrainImminent() throws LuaException { GlobalStation station = blockEntity.getStation(); @@ -111,6 +126,19 @@ public final boolean isTrainImminent() throws LuaException { return station.getImminentTrain() != null; } + @LuaFunction + public final CreateLuaTable getImminentTrain() throws LuaException { + GlobalStation station = blockEntity.getStation(); + if (station == null) + throw new LuaException("station is not connected to a track"); + + if (station.getImminentTrain() == null) + return null; + + DimensionPalette dimensions = new DimensionPalette(); + return fromCompoundTag(station.getImminentTrain().write(dimensions)); + } + @LuaFunction public final boolean isTrainEnroute() throws LuaException { GlobalStation station = blockEntity.getStation(); @@ -120,6 +148,19 @@ public final boolean isTrainEnroute() throws LuaException { return station.getNearestTrain() != null; } + @LuaFunction + public final CreateLuaTable getEnrouteTrain() throws LuaException { + GlobalStation station = blockEntity.getStation(); + if (station == null) + throw new LuaException("station is not connected to a track"); + + if (station.getNearestTrain() == null) + return null; + + DimensionPalette dimensions = new DimensionPalette(); + return fromCompoundTag(station.getNearestTrain().write(dimensions)); + } + @LuaFunction public final String getTrainName() throws LuaException { Train train = getTrainOrThrow();