Minecraft Transit Railway (Automated trains, planes, and more!)

Minecraft Transit Railway (Automated trains, planes, and more!)

1M Downloads

CC Tweaked (ComputerCraft) intergration

ajh123 opened this issue ยท 0 comments

commented

Suggestion Type

Other

Suggestion

I suggest that ComputerCraft peripherals can be added for these blocks:

  • Announcer: support computer controled anouncements. This means you can have different anouncements at different times of day.
  • Schedule Sensor: allow computers to find information about any train. This means someone could create an ingame trasnit app that even sends you notifactions when your train arrives.

Announcer

For the Announcer I propose the following Lua methods:

  • setMessage(message: string): Sets the message of the anouncement (the same one as the UI has)
  • setSoundFile(file: string>): Sets the sound file of the anouncement (the same one as the UI has)
  • active(): Bypasses the vehicle filters and plays the anouncement to all players in range. This will allow us to play generic anouncements throughout our stations instead of inside trains.

Schedule Sensor

For the Schedule Sensor I propose the following Lua methods:

  • getTrain(): Returns the ID of the train that has passed over the sensor.
  • getTrainSchedule(id): Returns a table containing the train's (with a matching id) schedule.

A train schedule table could look like:

{
    name = "Blue Line",
    color = { r = 0, g = 0, b = 255 }, -- Blue in RGB format
    stations = {
        { name = "Central Station", color = { r = 255, g = 255, b = 255 } }, -- White
        { name = "East Station", color = { r = 128, g = 0, b = 128 } }, -- Purple
        { name = "West Station", color = { r = 255, g = 165, b = 0 } }, -- Orange
        { name = "North Station", color = { r = 0, g = 255, b = 0 } }, -- Green
        { name = "South Station", color = { r = 255, g = 0, b = 0 } } -- Red
    }
}

I would also like the following information (somehow):

  • the ammount and type of carriages that make a trian
  • when a train arrived at a station, including if it was early or late, just like the Transport System Map does.

I belive that making these features would be simple as server side MTR already has this functionality (as proven by the Transport System Map), ComputerCraft intergration would provide another interface that allows people to have access to the existing information.

If you have any other ideas related to ComputerCraft intergration, please post them here.

Assets

No response

Implementation Details and References

All you need to do is add CC Tweaked as a Gradle dependencey and register an IPeripheral on your block entities.

To expose functions from your IPeripheral to Lua just annotate regular Java methods with @LuaFunction.

You can see how other mods (like Create Crafts and Additions) [does it](https://github.com/mrh0/createaddition/tree/fabric-1.20.1/src/main/java/com/mrh0/createaddition/compat/computercraft.