Page 3 of 3

Re: Road decoration

Posted: 22 Mar 2021, 23:24
by THEMAX
ian` wrote: 05 Feb 2021, 05:06
Yes, but it's not easy to make. :?
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.

Re: Road decoration

Posted: 25 Mar 2021, 05:18
by ian`
The code looks like this :

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
Interactive Lua editor
Run

Re: Road decoration

Posted: 31 Mar 2021, 18:16
by THEMAX
How can i add night animations to a road animation (for example, to a lamp post)

Re: Road decoration

Posted: 31 Mar 2021, 18:25
by CommanderABab
Add

Code: Select all

"light": true,
"light switching":true
to the lit at night part.

Re: Road decoration

Posted: 31 Mar 2021, 23:21
by THEMAX
Does someone have the json + the textures of the lamp post & the night animation of the lamp post so i can see how those are made ?

Re: Road decoration

Posted: 18 Nov 2021, 11:25
by THEMAX
With the diagonal road update, have diagonal road decorations become possible or will it be something for later ? @Lobby @JustAnyone

Re: Road decoration

Posted: 24 Dec 2021, 06:06
by Yakka
Lobby wrote: 14 May 2018, 16:21

Code: Select all

"exclusive":true
Is value true enabled and value false is disabled?

Re: Road decoration

Posted: 09 Apr 2022, 17:54
by Patchouli Knowledge
How to add lights to road decorations?

Re: Road decoration

Posted: 09 Apr 2022, 22:58
by Yakka
Patchouli Knowledge wrote: 09 Apr 2022, 17:54 How to add lights to road decorations?
Ask @Pederont for that.

Re: Road decoration

Posted: 15 Jan 2023, 04:20
by burgernamn
what does the ones and zeros mean

关于:道路装饰

Posted: 29 Mar 2023, 13:07
by 黑色高级市长
@Lobby How to make a road decoration that can rotate on all sides? I want make a vehicle trim parked on one side on road and that looks to be in the right position from all four directions.

Re: 关于:道路装饰

Posted: 04 Jun 2023, 20:59
by Lakan Haraya
黑色高级市长 wrote: 29 Mar 2023, 13:07 How to make a road decoration that can rotate on all sides?
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],[],
	[],[],[],[]
]
The 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.
As you can see, four 16 arrays are grouped together, each 16-group is for each rotations
:teachTake note that rotationally aware road decos are only applicable for one-way roads

Re: Road decoration

Posted: 30 Jul 2023, 17:10
by 黑色高级市长
:fire
Lakan Haraya wrote: 04 Jun 2023, 20:59
黑色高级市长 wrote: 29 Mar 2023, 13:07 How to make a road decoration that can rotate on all sides?
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],[],
	[],[],[],[]
]
The 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.
As you can see, four 16 arrays are grouped together, each 16-group is for each rotations
:teachTake note that rotationally aware road decos are only applicable for one-way roads
thank you!