Do you have any json / lua that can show me how this is done ? cause it could be really interesting for me since i am working on a train expansion plugin.
Do you have any json / lua that can show me how this is done ? cause it could be really interesting for me since i am working on a train expansion plugin.

Code: Select all Reset
local lastCounterRight = Array{0, 0, 0} local lastCounterLeft = Array{0, 0, 0} local timer = 0 local x,y,level local isTrainOnTheTrack = false function script:update() if City.countRoads(Draft.getDraft'$road_barrier_open00') > 0 then x,y,level = City.getRoad(1, Draft.getDraft'$road_barrier_open00') elseif City.countRoads(Draft.getDraft'$road_barrier_closed00') > 0 then x,y,level = City.getRoad(1, Draft.getDraft'$road_barrier_closed00') end if timer == 0 then lastCounterRight[1] = Tile.getRoadCarCount(x+4, y+1, level) lastCounterRight[2] = Tile.getRoadCarCount(x+3, y+1, level) lastCounterRight[3] = Tile.getRoadCarCount(x+5, y+1, level) lastCounterLeft[1] = Tile.getRoadCarCount(x-4, y+1, level) lastCounterLeft[2] = Tile.getRoadCarCount(x-3, y+1, level) lastCounterLeft[3] = Tile.getRoadCarCount(x-5, y+1, level) Builder.buildRoad(Draft.getDraft'$road_barrier_open00',x,y,x,y) isTrainOnTheTrack = false timer = 1 elseif timer > 250 then lastCounterRight[1] = Tile.getRoadCarCount(x+4, y+1, level) lastCounterRight[2] = Tile.getRoadCarCount(x+3, y+1, level) lastCounterRight[3] = Tile.getRoadCarCount(x+5, y+1, level) lastCounterLeft[1] = Tile.getRoadCarCount(x-4, y+1, level) lastCounterLeft[2] = Tile.getRoadCarCount(x-3, y+1, level) lastCounterLeft[3] = Tile.getRoadCarCount(x-5, y+1, level) Builder.buildRoad(Draft.getDraft'$road_barrier_open00',x,y,x,y) isTrainOnTheTrack = false timer = 0 elseif timer > 1 then Builder.buildRoad(Draft.getDraft'$road_barrier_closed00',x,y,x,y) end if Tile.getRoadCarCount(x+4, y+1, level) ~= lastCounterRight[1] then if isTrainOnTheTrack then isTrainOnTheTrack = false end if not isTrainOnTheTrack and Tile.getRoadCarCount(x+3, y+1, level) ~= lastCounterRight[2] then timer = timer + 1 isTrainOnTheTrack = true if isTrainOnTheTrack then if Tile.getRoadCarCount(x-3, y+1, level) ~= lastCounterLeft[2] then if Tile.getRoadCarCount(x-4, y+1, level) ~= lastCounterLeft[1] then timer = 0 end end end elseif isTrainOnTheTrack and Tile.getRoadCarCount(x+5, y+1, level) ~= lastCounterRight[3] then isTrainOnTheTrack = false timer = 0 end elseif Tile.getRoadCarCount(x-4, y+1, level) ~= lastCounterLeft[1] then if isTrainOnTheTrack then isTrainOnTheTrack = false end if not isTrainOnTheTrack and Tile.getRoadCarCount(x-3, y+1, level) ~= lastCounterLeft[2] then timer = timer + 1 isTrainOnTheTrack = true if isTrainOnTheTrack then if Tile.getRoadCarCount(x+3, y+1, level) ~= lastCounterRight[2] then if Tile.getRoadCarCount(x+4, y+1, level) ~= lastCounterRight[1] then timer = 0 end end end elseif isTrainOnTheTrack and Tile.getRoadCarCount(x-5, y+1, level) ~= lastCounterLeft[3] then isTrainOnTheTrack = false timer = 0 end end end

Code: Select all
"light": true,
"light switching":truemy avatar:


Is value true enabled and value false is disabled?
Ask @Pederont for that.
Use 64 arrays
Code: Select all
"animation":[
{"id":"$animation_A"}, //this will be your 0
{"id":"$animation_B"}, //and this is 1
{"id":"$animation_C"} //2
// 3, 4, 5, ... if you add more
],
"frame animation indices":[
[],[],[],[], //here's for rotation 0
[],[0,1],[],[],
[],[],[0,2],[],
[],[],[],[],
[],[],[],[], //for rotation 1
[],[0,3],[],[],
[],[],[0,4],[],
[],[],[],[],
[],[],[],[], //rotation 2
[],[0,5],[],[],
[],[],[0,6],[],
[],[],[],[],
[],[],[],[], //rotation 3
[],[0,7],[],[],
[],[],[0,8],[],
[],[],[],[]
]
thank you!Lakan Haraya wrote: 04 Jun 2023, 18:59Use 64 arraysThe placement of zeros are for frame 5 and frame 10 of road. You can also add more animations like how 1, 2, 3, ... are added in this example.Code: Select all
"animation":[ {"id":"$animation_A"}, //this will be your 0 {"id":"$animation_B"}, //and this is 1 {"id":"$animation_C"} //2 // 3, 4, 5, ... if you add more ], "frame animation indices":[ [],[],[],[], //here's for rotation 0 [],[0,1],[],[], [],[],[0,2],[], [],[],[],[], [],[],[],[], //for rotation 1 [],[0,3],[],[], [],[],[0,4],[], [],[],[],[], [],[],[],[], //rotation 2 [],[0,5],[],[], [],[],[0,6],[], [],[],[],[], [],[],[],[], //rotation 3 [],[0,7],[],[], [],[],[0,8],[], [],[],[],[] ]
As you can see, four 16 arrays are grouped together, each 16-group is for each rotations
Take note that rotationally aware road decos are only applicable for one-way roads
You might try asking someone if he's interested in collaborating with you, but it's probably generally more practical doing the textures yourself.Jtrendz wrote: 16 Nov 2024, 23:30 Does anyone know where I might be able to get a guild on creating simple decorations for cities. Stuff like phonebooths, padestrian seats, etc. I know I can make building but I don't really have any place for that or road decorations right now.
Add this:Ross The Mayor wrote: 26 Apr 2025, 17:13 Does anyone know the code for the cross walk road deco? How do you allow pedestrians to use it and cross the road?
Code: Select all
"allow road crossing": true