Rename Train Station automatically / on blueprint

This is the place to request new mods or give ideas about what could be done.
Kuristian
Burner Inserter
Burner Inserter
Posts: 5
Joined: Fri Mar 03, 2017 2:48 pm
Contact:

Rename Train Station automatically / on blueprint

Post by Kuristian »

Hello everyone,

I have been looking everywhere for the past 2 days for a mod that allow to rename via any mean (most likely circuit network) automatically, or a way to copy the name of the train stop in a blueprint.
All I have found so far is :
- NiftyManiac's Nifty's Logistic Train Network 0.9.1, which is not supported for 0.15 (or at least it seems?)
- And Stringy Train Stops: https://mods.factorio.com/mods/justaran ... train-stop, created by justarandomgeek, which from what I understand, allows to rename a trainstop with the circuit network, but I do not know if the syntax I use is wrong, the mod do not do what I understood it would do (and I blame only myself if that is the case), and since I have not seen any video/forum of anyone using it, I just could not find any clue on the matter.

It is very silly but I am using ConMan (from justarandomgeek again, pretty sweet mod! ), and with this mod, all you need to create any contraption automated, is a way to place trainstop with a set name.

Thanks in advance,

Kuristian
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Rename Train Station automatically / on blueprint

Post by darkfrei »

Can you explain what exactly must doing this mod? Which name must be used?
Kuristian
Burner Inserter
Burner Inserter
Posts: 5
Joined: Fri Mar 03, 2017 2:48 pm
Contact:

Re: Rename Train Station automatically / on blueprint

Post by Kuristian »

darkfrei wrote:Can you explain what exactly must doing this mod? Which name must be used?
I believe Nifty's Logistic Train Network 0.9.1 somehow allowed to rename train stops dynamically, from what I could see on the video. The mod page is dead, so I cannot get any actual description of the mod.
For Stringy Train Stops, my understanding is that it allow to rename a train stop from a character string, from another one of his mods:https://mods.factorio.com/mods/justaran ... nalstrings

Any name would do really, customisable would be ideal, but right now it's more so that I can place a train stop via blueprint and make it so that it can have a set name, without intervention of the player.
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Rename Train Station automatically / on blueprint

Post by darkfrei »

Kuristian wrote:For Stringy Train Stops, my understanding is that it allow to rename a train stop from a character string, from another one of his mods:https://mods.factorio.com/mods/justaran ... nalstrings.
Here:

Code: Select all

function updateStringyStation(entity)
	local net = entity.get_circuit_network(defines.wire_type.red) or entity.get_circuit_network(defines.wire_type.green)
	--TODO: fetch both and combine them? would kill performance...

	if net and net.signals and #net.signals > 0 then
		-- use *vanilla* train stop signal
		if net.get_signal({name="train-stop",type="item"}) == 1 then
			-- rename station
			local string = remote.call('signalstrings','signals_to_string',net.signals)
			if string ~= entity.backer_name then
				renameStringyStation(entity, string)
			end
			
		elseif net.get_signal({name="locomotive",type="item"}) == 1 then
			-- send train to named station
			for _,train in pairs(entity.surface.find_entities_filtered{area={{x=entity.position.x-2,y=entity.position.y-2},{x=entity.position.x+2,y=entity.position.y+2}},type='locomotive'}) do
				if train.train.state == defines.train_state.wait_station and train.train.station == entity then
					local string = remote.call('signalstrings','signals_to_string',net.signals)
					train.train.manual_mode = true
					train.train.schedule = { current = 1, records = {{station=string}}}
					train.train.manual_mode = false
				end
			end
		end
	end
end
This mod can rename stations on input signals with signal "train-stop" and send train to named station with signal "locomotive".
I think it's enough for automatic logistic train network.
Last edited by darkfrei on Fri Jun 09, 2017 3:32 pm, edited 2 times in total.
Kuristian
Burner Inserter
Burner Inserter
Posts: 5
Joined: Fri Mar 03, 2017 2:48 pm
Contact:

Re: Rename Train Station automatically / on blueprint

Post by Kuristian »

Thanks a lot for your reply!

Glad I understood what the mod should do, unfortunately I have tried quite a few things but never got to rename a train stop at all. I experimented a bit following this method, from the Signal Strings Library description:
"Strings are expressed as a bitmask of where each letter appears, LSB on the left. "FOOBAR" = {signal-F=1,signal-O=6,signal-B=8,signal-A=16,signal-R=32}"

What I understand is outputting let's say, A =1, B = 2, C = 4, trainstop = 1 from a constant combinator wired to a stop should rename it "ABC". And A =1, B = 2, C = 4, dieselocomotive = 1 send the train to the stop "ABC". But no results.
From the bit of code you sent me, I understand that it is pretty straightforward to rename the stations, I am probably just forgetting one simple silly step.
Kuristian
Burner Inserter
Burner Inserter
Posts: 5
Joined: Fri Mar 03, 2017 2:48 pm
Contact:

Re: Rename Train Station automatically / on blueprint

Post by Kuristian »

Oh my nevermind, I am just an airhead, and forgot to check the research tree. In Stringy Train Stops you have to research the special train stop. Then you place it and that's the one that you can rename with the circuit network, each letter position being determined in binary. It then works flawlessly. I believed the special train stop was for signal only and not an actual building --'
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Rename Train Station automatically / on blueprint

Post by darkfrei »

Kuristian wrote:Oh my nevermind, I am just an airhead, and forgot to check the research tree. In Stringy Train Stops you have to research the special train stop.
I haven't played this mod, can you add some pictures? :)
Post Reply

Return to “Ideas and Requests For Mods”