Page 1 of 1

[0.11.10] setblueprintentities and diagonal rails

Posted: Wed Jan 07, 2015 5:44 am
by DaveMcW
setblueprintentities() messes up all diagonal straight rails.

If you input direction=1, the blueprint has direction=7.
If you input direction=3, the blueprint has direction=5.
If you input direction=5, the blueprint has direction=7.
If you input direction=7, the blueprint has direction=5.


Steps to reproduce:
1. Put a working blueprint in the first slot of your toolbar.
2. Run this command:

Code: Select all

/c game.player.getinventory(1).getitemstack(1).setblueprintentities({{direction=1,position={y=1,x=-3},name="straight-rail",entitynumber=1},{direction=7,position={y=1,x=3},name="straight-rail",entitynumber=2},{direction=5,position={y=1,x=-1},name="straight-rail",entitynumber=3},{direction=3,position={y=1,x=1},name="straight-rail",entitynumber=4}})
It should look like this:
rail-good.jpg
rail-good.jpg (77.54 KiB) Viewed 1363 times
But it ends up like this:
rail-bad.jpg
rail-bad.jpg (72.44 KiB) Viewed 1363 times

Re: [0.11.10] setblueprintentities and diagonal rails

Posted: Wed Jan 07, 2015 8:37 am
by Choumiko
After reading that report i remembered this (from the rail layer mod):

Code: Select all

-- fix for 0.10.12 as direction of diagonal track different for placed entity and direction asked in createentity
        if railDirection % 2 == 1 then
            railDirection = (railDirection + 2 * (railDirection % 2)) % 8
        end
    local canplace = game.canplaceentity{name = railType, position = {X, Y}, direction = railDirection}
    if canplace then
        game.createentity{name = railType, position = {X, Y}, direction = railDirection, force = game.forces.player}
Seems like this has been around for a while but unreported.

Re: [0.11.10] setblueprintentities and diagonal rails

Posted: Tue Jan 13, 2015 9:55 am
by kovarex
Thanks for the report, it is now fixed for 0.11.11
0.11.11 changelog wrote: Fixed that the rail direction were messed up when building rails from script.
The mechanism, that changes the rail direction based on the position is still used for manual building, to allow the user to build diagonal rails without having to switch direction after every piece.