[0.12.3] [kovarex] create_entity, position/direction issue with rails.

This subforum contains all the issues which we already resolved.
Post Reply
User avatar
MasterBuilder
Filter Inserter
Filter Inserter
Posts: 348
Joined: Sun Nov 23, 2014 1:22 am
Contact:

[0.12.3] [kovarex] create_entity, position/direction issue with rails.

Post by MasterBuilder »

I am trying to replace vanilla rails with concrete ones. (The rails are pretty much identical except for a different image.) The replacing is done by the upgrade with construction robots mod. (I've got a local copy that I'm updating to 0.12.)

Essentially, the mod is creating ghost rails in the same spot as the vanilla rail which gets marked for deconstruction. (Using a custom blueprint item, "upgrade planner", to find and replace the rails.) This allows the robots to remove the existing item and place the new item down in the same position/direction.
The LUA script, for each rail, creates a ghost entity of the new rail type in the same position as the existing rail.

('entity' here refers to the existing rail.)

Code: Select all

    local new_entity = {
        name = "entity-ghost",
        inner_name = config[index].to,
        position = entity.position,
        direction = entity.direction,
        force = entity.force
    }

    game.surfaces['nauvis'].create_entity(new_entity)
As you can see the new 'ghost' entity is set to the same position and direction of the existing entity. (This excerpt is from "mods/replacer_1.0.4/control.lua", line 648.)

The problem: Rail direction/rotation is lost.
Before
After
Half of the curved rails keep their orientation, half don't. The diagonal line of straight rails becomes a series of horizontal ones, etc. (Any straight rail that is diagonal will wind up being either vertical or horizontal afterwards.)

Save (incl. mods) is attached. Just use the 'upgrade planner' (slot '5' in the quick bar) on the rails to recreate the issue.
What's going on here? Is this something I've done or is the direction getting lost somewhere along the way?
Attachments
Save.7z
(2.09 MiB) Downloaded 122 times
Give a man fire and he'll be warm for a day. Set a man on fire and he'll be warm for the rest of his life.

kovarex
Factorio Staff
Factorio Staff
Posts: 8078
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: [0.12.3] [kovarex] create_entity, position/direction issue with rails.

Post by kovarex »

Thx for the report, the problem is the improper 8 way direction versus 4 way direction logic while building ghost entities from script.

It is now fixed for 0.12.4, so the mod upgrader works properly for all the rails in the save. (Nice idea btw).

Post Reply

Return to “Resolved Problems and Bugs”