Aummary
A method to make camera guis automatically follow an entity.
Description
I've looked all through the API doc and through several mods, and it seems that currently the only method is on_tick? Which feels clunky for such a simple task.
What for?
Picture-in-Picture viewing of players, robots, biters, etcpp.
LuaGuiElement{type="camera",entity=<follow this>}
- eradicator
- Smart Inserter
- Posts: 5211
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
LuaGuiElement{type="camera",entity=<follow this>}
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: LuaGuiElement{type="camera",entity=<follow this>}
+1. Also for type = "minimap", which is how base game train GUI works.
My mods
Content: Lunar Landings | Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings
Content: Lunar Landings | Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings
Re: LuaGuiElement{type="camera",entity=<follow this>}
Already exists: https://lua-api.factorio.com/latest/Lua ... ent.entity
You can write the entity to follow after creating the element
You can write the entity to follow after creating the element
Re: LuaGuiElement{type="camera",entity=<follow this>}
Oh wow, thanks! I see for 'entity-preview' it says "The entity has to be set after the GUI element is created.", so maybe there's a technical reason why it can't be set in .add{} .Klonan wrote: ↑Wed Apr 28, 2021 9:37 am Already exists: https://lua-api.factorio.com/latest/Lua ... ent.entity
You can write the entity to follow after creating the element
My mods
Content: Lunar Landings | Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings
Content: Lunar Landings | Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings
Re: LuaGuiElement{type="camera",entity=<follow this>}
I added a note hinting at this functionality to the docs for the next release.
Re: LuaGuiElement{type="camera",entity=<follow this>}
Yea, something like, the creation is wrapped with propertyTree into creationParameters (Basically internal Lua format), which can't wrap an Entity* pointer,
But setting it afterwards, we can just pass the Entity* pointer right into the CustomCamera
Re: LuaGuiElement{type="camera",entity=<follow this>}
Using flib.gui-beta, I can just do
Code: Select all
{type = "camera", position = spidertron.position, surface_index = spidertron.surface.index, elem_mods = {entity = spidertron}},
My mods
Content: Lunar Landings | Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings
Content: Lunar Landings | Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings