Keeps showing Train path / fake entity mouseover

Place to get help with not working mods / modding interface.
Post Reply
danyg
Burner Inserter
Burner Inserter
Posts: 12
Joined: Thu Nov 10, 2016 10:38 pm
Contact:

Keeps showing Train path / fake entity mouseover

Post 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
);

User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2915
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: Keeps showing Train path / fake entity mouseover

Post by Optera »

I don't think the api exposes this (yet).

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

danyg
Burner Inserter
Burner Inserter
Posts: 12
Joined: Thu Nov 10, 2016 10:38 pm
Contact:

Re: Keeps showing Train path / fake entity mouseover

Post 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!

Post Reply

Return to “Modding help”