Page 1 of 1

Keeps showing Train path / fake entity mouseover

Posted: Sat Jun 23, 2018 8:50 pm
by danyg
Hi

I'm trying to create a mod that keeps showing a train path/route (like when hovering a train) when you open its GUI interface. The idea is to be able to see its path using the map as the hovering the train with the mouse only allows you to see one screen of it, as you cannot hover the train when it is offscreen.

But I'm failing miserably, for the moment I was only able to find a way to detect that the train has a path, but I can't find any reference to this path/route
Does anyone know where it might be?
I tried to find it as part of the Train, or check if there is some GUI prototype or something like that but not sure.

Also thought that could be possible to keep seeing it if I could fake a "mouseover" on the train / or locomotive entity but not sure either how.

this is the code I have so far (not much...) just learning how to code on LUA, but my question is related more to how the game is structured, and where this GUI helpers might reside, and if they are accessible through the mod API

Code: Select all

-- control.lua
script.on_event({defines.events.on_gui_opened},
	function(e)
		game.print("GUI OPENED: " .. e.gui_type .. " == " .. defines.gui_type.trains)
		if (e.gui_type == defines.gui_type.entity and e.entity ~= nil and e.entity.type == 'locomotive') then
			game.print("Train opened ID: " .. e.entity.train.id)
			if e.entity.train.has_path then
				game.print("\tHAS PATH!")
				-- probably here enable the path visualizer
			end
		end
	end
);

Re: Keeps showing Train path / fake entity mouseover

Posted: Sun Jun 24, 2018 5:47 am
by Optera
I don't think the api exposes this (yet).

You can enable the debug option to show train paths by pressing F4.

Re: Keeps showing Train path / fake entity mouseover

Posted: Sun Jun 24, 2018 8:53 am
by danyg
Optera wrote:I don't think the api exposes this (yet).

You can enable the debug option to show train paths by pressing F4.
Thanks for the reply.
Indeed, but it shows several trains path at the same time, so when you try to see why where one, in particular, get stuck you cannot see it well.

Thanks!