Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand Down