NML Signals: How do you replace semaphores & electric signals?

Discuss, get help with, or post new graphics for TTDPatch and OpenTTD, using the NewGRF system, here. Graphics for plain TTD also acceptable here.

Moderator: Graphics Moderators

Post Reply
User avatar
NekoMaster
Tycoon
Tycoon
Posts: 3982
Joined: 16 Aug 2008 22:26
Skype: neko-master
Location: Oshawa, Ontario, CANADA

NML Signals: How do you replace semaphores & electric signals?

Post by NekoMaster »

I think I'm "close" to getting stuff working so I can have American tyle Semaphores and Search light signals the replace the vanilla signals, but I don't know how to have them replace their respective signal types rather than say, my semaphores or searchlight signals replacing both types.

I tried to do my own "switch" stuff at the end of the code, but didn't work right, the block signals where both replaced by Searchlight block signals and the regular/two-way PBS signals where placed by my Searchlight PBS signals. The rest ended up becoming just the defualt/base graphics signals.

Code: Select all

//	#####################################################################################################################
//
//	SIGNAL GRAPHICS: 01 - SEMAPHORE & SEARCHLIGHT SIGNALS
//
//	#####################################################################################################################


//	#############################################################################
//	SEMAPHORES
//	=============================================================================

//	BLOCK SIGNAL
//	*********************************************************************************************************************

	spriteset(SPRITESET_SEMAPHORE_BLOCK_RED,				"GRAPHICS/50_SIGNAL_GRAPHICS/10_SEMAPHORE_SIGNALS/10_BLOCK_SIGNALS_SEMAPHORES.PNG") {
		tmpl_signals(00, 40)
	}

//	-----------------------------------------------------------------------------

	spriteset(SPRITESET_SEMAPHORE_BLOCK_GREEN,				"GRAPHICS/50_SIGNAL_GRAPHICS/10_SEMAPHORE_SIGNALS/10_BLOCK_SIGNALS_SEMAPHORES.PNG") {
		tmpl_signals(00, 00)
	}

//	*********************************************************************************************************************

	spriteset (SPRITESET_SEMAPHORE_ENTRY_RED,				"GRAPHICS/50_SIGNAL_GRAPHICS/10_SEMAPHORE_SIGNALS/20_ENTRY_SIGNALS_SEMAPHORES.PNG") {
		tmpl_signals(00, 40)
	}

//	-----------------------------------------------------------------------------

	spriteset (SPRITESET_SEMAPHORE_ENTRY_GREEN,				"GRAPHICS/50_SIGNAL_GRAPHICS/10_SEMAPHORE_SIGNALS/20_ENTRY_SIGNALS_SEMAPHORES.PNG") {
		tmpl_signals(00, 00)
	}

//	*********************************************************************************************************************

	spriteset (SPRITESET_SEMAPHORE_EXIT_RED,				"GRAPHICS/50_SIGNAL_GRAPHICS/10_SEMAPHORE_SIGNALS/30_EXIT_SIGNALS_SEMAPHORES.PNG") {
		tmpl_signals(00, 40)
	}

//	-----------------------------------------------------------------------------

	spriteset (SPRITESET_SEMAPHORE_EXIT_GREEN,				"GRAPHICS/50_SIGNAL_GRAPHICS/10_SEMAPHORE_SIGNALS/30_EXIT_SIGNALS_SEMAPHORES.PNG") {
		tmpl_signals(00, 00)
	}

//	*********************************************************************************************************************

	spriteset (SPRITESET_SEMAPHORE_COMBO_RED,				"GRAPHICS/50_SIGNAL_GRAPHICS/10_SEMAPHORE_SIGNALS/40_COMBO_SIGNALS_SEMAPHORES.PNG") {
		tmpl_signals(00, 40)
	}

//	-----------------------------------------------------------------------------

	spriteset (SPRITESET_SEMAPHORE_COMBO_GREEN,				"GRAPHICS/50_SIGNAL_GRAPHICS/10_SEMAPHORE_SIGNALS/40_COMBO_SIGNALS_SEMAPHORES.PNG") {
		tmpl_signals(00, 00)
	}

//	*********************************************************************************************************************

	spriteset (SPRITESET_SEMAPHORE_PBS_RED,					"GRAPHICS/50_SIGNAL_GRAPHICS/10_SEMAPHORE_SIGNALS/50_PBS_SIGNALS_SEMAPHORES.PNG") {
		tmpl_signals(00, 40)
	}

//	-----------------------------------------------------------------------------

	spriteset (SPRITESET_SEMAPHORE_PBS_GREEN,				"GRAPHICS/50_SIGNAL_GRAPHICS/10_SEMAPHORE_SIGNALS/50_PBS_SIGNALS_SEMAPHORES.PNG") {
		tmpl_signals(00, 00)
	}

//	*********************************************************************************************************************

	spriteset (SPRITESET_SEMAPHORE_PBS_ONE_WAY_RED,			"GRAPHICS/50_SIGNAL_GRAPHICS/10_SEMAPHORE_SIGNALS/60_PBS_ONE_WAY_SIGNALS_SEMAPHORES.PNG") {
		tmpl_signals(00, 40)
	}

//	-----------------------------------------------------------------------------

	spriteset (SPRITESET_SEMAPHORE_PBS_ONE_WAY_GREEN,		"GRAPHICS/50_SIGNAL_GRAPHICS/10_SEMAPHORE_SIGNALS/60_PBS_ONE_WAY_SIGNALS_SEMAPHORES.PNG") {
		tmpl_signals(00, 00)
	}

//	*********************************************************************************************************************
//	---------------------------------------------------------------------------------------------------------------------
//	*********************************************************************************************************************

	switch	(FEAT_RAILTYPES, SELF,							SEMAPHORE_SIGNALS_GREEN, getbits(extra_callback_info2, 16, 8)) {
															
														0:	SPRITESET_SEMAPHORE_BLOCK_GREEN;
														1:	SPRITESET_SEMAPHORE_ENTRY_GREEN;
														2:	SPRITESET_SEMAPHORE_EXIT_GREEN;
														3:	SPRITESET_SEMAPHORE_COMBO_GREEN;
														4:	SPRITESET_SEMAPHORE_PBS_GREEN;
														5:	SPRITESET_SEMAPHORE_PBS_ONE_WAY_GREEN;
	}

//	-----------------------------------------------------------------------------	
	
	switch	(FEAT_RAILTYPES, SELF,							SEMAPHORE_SIGNALS_RED, getbits(extra_callback_info2, 16, 8)) {
															
														0:	SPRITESET_SEMAPHORE_BLOCK_RED;
														1:	SPRITESET_SEMAPHORE_ENTRY_RED;
														2:	SPRITESET_SEMAPHORE_EXIT_RED;
														3:	SPRITESET_SEMAPHORE_COMBO_RED;
														4:	SPRITESET_SEMAPHORE_PBS_RED;
														5:	SPRITESET_SEMAPHORE_PBS_ONE_WAY_RED;
	}

//	-----------------------------------------------------------------------------	

	switch	(FEAT_RAILTYPES, SELF,							SWITCH_SEMAPHORE_SIGNALS, getbits(extra_callback_info2, 0, 8)) {
														0:	SEMAPHORE_SIGNALS_RED;
														1:	SEMAPHORE_SIGNALS_GREEN;
	}
	
//	*********************************************************************************************************************
//	---------------------------------------------------------------------------------------------------------------------
//	*********************************************************************************************************************	

//	#############################################################################
//	SEARCHLIGHT SIGNALS
//	=============================================================================

//	BLOCK SIGNAL
//	*********************************************************************************************************************
	
	spriteset(SPRITESET_SEARCHLIGHTS_BLOCK_RED,					"GRAPHICS/50_SIGNAL_GRAPHICS/20_SEARCHLIGHT_SIGNALS/10_BLOCK_SIGNALS_SEARCHLIGHTS.PNG") {
		tmpl_signals(00, 40)
	}

//	-----------------------------------------------------------------------------

	spriteset(SPRITESET_SEARCHLIGHTS_BLOCK_GREEN,				"GRAPHICS/50_SIGNAL_GRAPHICS/20_SEARCHLIGHT_SIGNALS/10_BLOCK_SIGNALS_SEARCHLIGHTS.PNG") {
		tmpl_signals(00, 00)
	}

//	*********************************************************************************************************************

	spriteset (SPRITESET_SEARCHLIGHTS_ENTRY_RED,				"GRAPHICS/50_SIGNAL_GRAPHICS/20_SEARCHLIGHT_SIGNALS/20_ENTRY_SIGNALS_SEARCHLIGHTS.PNG") {
		tmpl_signals(00, 40)
	}

//	-----------------------------------------------------------------------------

	spriteset (SPRITESET_SEARCHLIGHTS_ENTRY_GREEN,				"GRAPHICS/50_SIGNAL_GRAPHICS/20_SEARCHLIGHT_SIGNALS/20_ENTRY_SIGNALS_SEARCHLIGHTS.PNG") {
		tmpl_signals(00, 00)
	}

//	*********************************************************************************************************************

	spriteset (SPRITESET_SEARCHLIGHTS_EXIT_RED,					"GRAPHICS/50_SIGNAL_GRAPHICS/20_SEARCHLIGHT_SIGNALS/30_EXIT_SIGNALS_SEARCHLIGHTS.PNG") {
		tmpl_signals(00, 40)
	}

//	-----------------------------------------------------------------------------

	spriteset (SPRITESET_SEARCHLIGHTS_EXIT_GREEN,				"GRAPHICS/50_SIGNAL_GRAPHICS/20_SEARCHLIGHT_SIGNALS/30_EXIT_SIGNALS_SEARCHLIGHTS.PNG") {
		tmpl_signals(00, 00)
	}

//	*********************************************************************************************************************

	spriteset (SPRITESET_SEARCHLIGHTS_COMBO_RED,				"GRAPHICS/50_SIGNAL_GRAPHICS/20_SEARCHLIGHT_SIGNALS/40_COMBO_SIGNALS_SEARCHLIGHTS.PNG") {
		tmpl_signals(00, 40)
	}

//	-----------------------------------------------------------------------------

	spriteset (SPRITESET_SEARCHLIGHTS_COMBO_GREEN,				"GRAPHICS/50_SIGNAL_GRAPHICS/20_SEARCHLIGHT_SIGNALS/40_COMBO_SIGNALS_SEARCHLIGHTS.PNG") {
		tmpl_signals(00, 00)
	}

//	*********************************************************************************************************************

	spriteset (SPRITESET_SEARCHLIGHTS_PBS_RED,					"GRAPHICS/50_SIGNAL_GRAPHICS/20_SEARCHLIGHT_SIGNALS/50_PBS_SIGNALS_SEARCHLIGHTS.PNG") {
		tmpl_signals(00, 40)
	}

//	-----------------------------------------------------------------------------

	spriteset (SPRITESET_SEARCHLIGHTS_PBS_GREEN,				"GRAPHICS/50_SIGNAL_GRAPHICS/20_SEARCHLIGHT_SIGNALS/50_PBS_SIGNALS_SEARCHLIGHTS.PNG") {
		tmpl_signals(00, 00)
	}

//	*********************************************************************************************************************

	spriteset (SPRITESET_SEARCHLIGHTS_PBS_ONE_WAY_RED,			"GRAPHICS/50_SIGNAL_GRAPHICS/20_SEARCHLIGHT_SIGNALS/60_PBS_ONE_WAY_SIGNALS_SEARCHLIGHTS.PNG") {
		tmpl_signals(00, 40)
	}

//	-----------------------------------------------------------------------------

	spriteset (SPRITESET_SEARCHLIGHTS_PBS_ONE_WAY_GREEN,		"GRAPHICS/50_SIGNAL_GRAPHICS/20_SEARCHLIGHT_SIGNALS/60_PBS_ONE_WAY_SIGNALS_SEARCHLIGHTS.PNG") {
		tmpl_signals(00, 00)
	}

//	*********************************************************************************************************************
//	---------------------------------------------------------------------------------------------------------------------
//	*********************************************************************************************************************

	switch	(FEAT_RAILTYPES, SELF,							SEARCHLIGHT_SIGNALS_GREEN, getbits(extra_callback_info2, 16, 8)) {
															
														0:	SPRITESET_SEARCHLIGHTS_BLOCK_GREEN;
														1:	SPRITESET_SEARCHLIGHTS_ENTRY_GREEN;
														2:	SPRITESET_SEARCHLIGHTS_EXIT_GREEN;
														3:	SPRITESET_SEARCHLIGHTS_COMBO_GREEN;
														4:	SPRITESET_SEARCHLIGHTS_PBS_GREEN;
														5:	SPRITESET_SEARCHLIGHTS_PBS_ONE_WAY_GREEN;
	}

//	-----------------------------------------------------------------------------	
	
	switch	(FEAT_RAILTYPES, SELF,							SEARCHLIGHT_SIGNALS_RED, getbits(extra_callback_info2, 16, 8)) {
															
														0:	SPRITESET_SEARCHLIGHTS_BLOCK_RED;
														1:	SPRITESET_SEARCHLIGHTS_ENTRY_RED;
														2:	SPRITESET_SEARCHLIGHTS_EXIT_RED;
														3:	SPRITESET_SEARCHLIGHTS_COMBO_RED;
														4:	SPRITESET_SEARCHLIGHTS_PBS_RED;
														5:	SPRITESET_SEARCHLIGHTS_PBS_ONE_WAY_RED;
	}

//	-----------------------------------------------------------------------------	

	switch	(FEAT_RAILTYPES, SELF,							SWITCH_SEARCHLIGHTS_SIGNALS, getbits(extra_callback_info2, 0, 8)) {
														0:	SEARCHLIGHT_SIGNALS_RED;
														1:	SEARCHLIGHT_SIGNALS_GREEN;
	}
	
//	*********************************************************************************************************************
//	---------------------------------------------------------------------------------------------------------------------
//	*********************************************************************************************************************	

	switch	(FEAT_RAILTYPES, SELF,							SWITCH_SIGNALS_10_SEMAPHORES_AND_SEARCHLIGHTS, getbits(extra_callback_info2, 9, 9)) {

														00:	SWITCH_SEARCHLIGHTS_SIGNALS;
														01: SWITCH_SEMAPHORE_SIGNALS;
	}
P.S: I wouldn't be surprised if what I wrote is total garbage and things aren't working because I screwed up the whole thing.
Image Proud Canadian Image
Nekomasters Projects! (Downloads available on BaNaNaS!) \(>^w^<)/
# NARS ADD-ON SET 2CC | 2cc Rapid Transit For Me! (2ccRTFM) | 2cc Wagons In NML (2ccWIN)
# NML Category System (Organize your GRFS!) <- TT-Forums Exclusive Download!

Transportman
Tycoon
Tycoon
Posts: 2743
Joined: 22 Feb 2011 18:34

Re: NML Signals: How do you replace semaphores & electric signals?

Post by Transportman »

I think the error is in the getbits() of SWITCH_SIGNALS_10_SEMAPHORES_AND_SEARCHLIGHTS. According to the wiki, that should be:
getbits(extra_callback_info2, 8, 8)
You have:
getbits(extra_callback_info2, 9, 9)
Coder of the Dutch Trackset | Development support for the Dutch Trainset | Coder of the 2cc TrainsInNML

User avatar
NekoMaster
Tycoon
Tycoon
Posts: 3982
Joined: 16 Aug 2008 22:26
Skype: neko-master
Location: Oshawa, Ontario, CANADA

Re: NML Signals: How do you replace semaphores & electric signals?

Post by NekoMaster »

Transportman wrote:
04 Sep 2020 21:04
I think the error is in the getbits() of SWITCH_SIGNALS_10_SEMAPHORES_AND_SEARCHLIGHTS. According to the wiki, that should be:
getbits(extra_callback_info2, 8, 8)
You have:
getbits(extra_callback_info2, 9, 9)
YUP! Thats what it was! I can't believe I screwed that up and never noticed it :D

I'm just glad it was a simple fix! Now both my own semaphores and searchlight signals appear in game! :)

Thanks again for your help buddy!
Image Proud Canadian Image
Nekomasters Projects! (Downloads available on BaNaNaS!) \(>^w^<)/
# NARS ADD-ON SET 2CC | 2cc Rapid Transit For Me! (2ccRTFM) | 2cc Wagons In NML (2ccWIN)
# NML Category System (Organize your GRFS!) <- TT-Forums Exclusive Download!

Transportman
Tycoon
Tycoon
Posts: 2743
Joined: 22 Feb 2011 18:34

Re: NML Signals: How do you replace semaphores & electric signals?

Post by Transportman »

You're welcome, I know how easy it is to make small mistakes like that and then it helps if someone else takes a look at it, because you can become blind for mistakes in your own code.
Coder of the Dutch Trackset | Development support for the Dutch Trainset | Coder of the 2cc TrainsInNML

Post Reply

Return to “Graphics Development”

Who is online

Users browsing this forum: Bing [Bot] and 6 guests