Keeps showing Train path / fake entity mouseover
Posted: Sat Jun 23, 2018 8:50 pm
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
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
);