@name endless_road_test
@inputs
@outputs DT Speed
@persist Entity:entity Count Stack:array Length DT Time
@trigger none


interval(60)

if (!Count) {

    Entity = entity()
    Length = 299.709*2

    for (I = 0, 2) {
        local Y = -Length*I - Length/2

        Count++
        holoCreate(Count)
        holoModel(Count, "models/props_phx/huge/road_short.mdl")
        holoPos(Count, Entity:toWorld(vec(0, Y, 0)))
        holoClipEnabled(Count, 1, 1)
        holoClipEnabled(Count, 2, 1)
        holoParent(Count, Entity)

        Stack[Count, number] = Y
    }

    Time = curtime()

}
else {

    DT = curtime() - Time
    Time = curtime()

    UnitsPerSecond = 100
    Speed = DT*UnitsPerSecond
    local ClipD = Entity:toWorldAxis(vec(0, Speed, 0))

    for (I = 1, Count) {
        Stack[I, number] = Stack[I, number] + Speed - (Stack[I, number] >= Length)*(Length*Count)

        holoPos(I, Entity:toWorld(vec(0, Stack[I, number], 0)))
       # holoClip(I, 1, Entity:toWorld(vec(0, 0, 0)), -ClipD, 1)
       # holoClip(I, 2, Entity:toWorld(vec(0, -Length, 0)), ClipD, 1)
    }

}
