rail-attached entity to move train

Place to get help with not working mods / modding interface.
Post Reply
_Ax_
Burner Inserter
Burner Inserter
Posts: 13
Joined: Tue Jul 23, 2019 1:26 pm
Contact:

rail-attached entity to move train

Post by _Ax_ »

Hello, I was trying to play around with trains and now I'm trying to move the train to specific places, but I found out that the train heads towards a placed entity (placed near the rail, like signals I suppose) but I'm not quite sure of it.

So my questions are, how can I select a single train and say to it "hey, move here"?
And how can I create a dummy entity to place (manually, just like a signal except it does nothing) near a rail?

So far I tried this for the dummy entity:

Code: Select all

-- shunt signal entity prototype
local shuntSignal = {
    type = "simple-entity",
    name = "shunt-signal-entity",
    icon = "__shunter-loco__/graphics/shunter-signal.png",
    icon_size = 32,
    flags = {"placeable-neutral", "player-creation"},
    picture = {
        filename = "__shunter-loco__/graphics/shunter-signal.png",
        width  = 32,
        height = 32,
    },
    minable = {
        mining_time = 3,
        result = "shunt-signal-item"
    },
}

-- shunt signal item prototype
local shuntSignalItem = {
    type = "item",
    name = "shunt-signal-item",
    icon = "__shunter-loco__/graphics/shunter-signal.png",
    icon_size = 32,
    stack_size = 100,
    subgroup = data.raw["item"]["rail-signal"].subgroup, --copy the subgroup of the rail signal
    place_result = shuntSignal.name,
}

-- shunt signal recipe prototype
local shuntSignalRecipe = {
    type = "recipe",
    name = "shunt-signal-recipe",
    enabled = true,
    subgroup = data.raw["item"]["rail-signal"].subgroup, --copy the subgroup of the rail signal
    ingredients = {
        {type="item", name="steel-plate", amount=10},
        {type="item", name="iron-stick", amount=10}
    },
    result = shuntSignalItem.name,
}
But it doesn't work, I mean I can craft and place it but I can't remove it, only bots can, and I can place it everywhere, not only on rails.
Thanks in advance :D

Kiplacon
Burner Inserter
Burner Inserter
Posts: 10
Joined: Tue Jan 16, 2018 8:14 pm
Contact:

Re: rail-attached entity to move train

Post by Kiplacon »

On the entity prototype, if you change the type from "simple-entity" to "train-stop" it will act like a train stop in that it can only be placed on rails, and it won't affect train traffic like how a train signal would. Then in control.lua when it gets built, you can set entity.operable = false so that players can't click "open" it. You also have to set a sellection_box for the entity prototype so you can actually hover and select it in game for you to pick it up

Post Reply

Return to “Modding help”