LuaGuiElement{type="camera",entity=<follow this>}

Things that already exist in the current mod API
Post Reply
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5092
Joined: Tue Jul 12, 2016 9:03 am
Contact:

LuaGuiElement{type="camera",entity=<follow this>}

Post by eradicator »

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.
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.

Xorimuth
Filter Inserter
Filter Inserter
Posts: 299
Joined: Sat Mar 02, 2019 9:39 pm
Contact:

Re: LuaGuiElement{type="camera",entity=<follow this>}

Post by Xorimuth »

+1. Also for type = "minimap", which is how base game train GUI works.

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 4901
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: LuaGuiElement{type="camera",entity=<follow this>}

Post by Klonan »

Already exists: https://lua-api.factorio.com/latest/Lua ... ent.entity

You can write the entity to follow after creating the element

Xorimuth
Filter Inserter
Filter Inserter
Posts: 299
Joined: Sat Mar 02, 2019 9:39 pm
Contact:

Re: LuaGuiElement{type="camera",entity=<follow this>}

Post by Xorimuth »

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
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{} .

User avatar
Therenas
Fast Inserter
Fast Inserter
Posts: 204
Joined: Tue Dec 11, 2018 2:10 pm
Contact:

Re: LuaGuiElement{type="camera",entity=<follow this>}

Post by Therenas »

I added a note hinting at this functionality to the docs for the next release.

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 4901
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: LuaGuiElement{type="camera",entity=<follow this>}

Post by Klonan »

Xorimuth wrote:
Wed Apr 28, 2021 9:42 am
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{} .
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

Xorimuth
Filter Inserter
Filter Inserter
Posts: 299
Joined: Sat Mar 02, 2019 9:39 pm
Contact:

Re: LuaGuiElement{type="camera",entity=<follow this>}

Post by Xorimuth »

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}},
:D

Post Reply

Return to “Already exists”