

function track_placer(x, y, placer, version, rotation)
    x = math.floor(x)
    y = math.floor(y)
    if not placer:owns_tile(x, y) then
        placer:fail("Must be placed on a free space")
        return
    end

    local rot = rotation % (2 + 4)

    local tile = "track/straight"
    if rot == 0 then
        tile = "track/straight"
    elseif rot == 1 then
        tile = "track/straight_h"
    else
        tile = "track/corner_" .. tostring(rot - 1)
    end

    placer:set_floor(x, y, tile)
    placer:selection_bound(x, 0.0, y, 1.0, 0.05, 1.0)

    if not placer:contains_bound(x, y, 1, 1) then
        placer:fail("Must be placed within a building")
        return
    end
    return 0
end