Blueprint trickery: advice wanted

Place to get help with not working mods / modding interface.
Post Reply
golfmiketango
Filter Inserter
Filter Inserter
Posts: 549
Joined: Fri Jan 29, 2016 2:48 am
Contact:

Blueprint trickery: advice wanted

Post by golfmiketango »

I'm looking to create a "zone" effect. User story I'm trying to implement looks like so:
  • Player selects my modded blueprint item and does setup like a normal blueprint.
  • Player orders construction of setup-up modded blueprint.
  • Items in the blueprint are placed normally, but also, some intangible user-visible entities are created which visually indicate or highlight a rectangular quasi-radius or "zone" surrounding and/or covering the blueprinted items. These intangibles have no hitbox but, ideally, would be selectable or at least, would appear to be so to the player.
  • Thenceforth, special magic stuff happens within the visually indicated zone, unless and until it is (somehow, haven't figured this out yet) deconstructed.
Where I'm struggling is ensuring those intangibles are built. Given that no particular entity is guaranteed to be in the user's blueprint, I probably cannot simply ape "compound entity" tricks that a normal item->entity mod might employ (like a train station from smart trains mod).

I wanted to just inject a bunch of simple-entity-with-owners into the blueprint, but these are apparently not blueprintable (so the API informs me when I attempt to do it). I'm assuming (but should probably confirm) that I can't just inject my my simple-entity-with-owner objects into the cursor stack as soon as they are holding my setup blueprint as I would get the same error?

OK, fine, but where there's a will there's a way, right? So far the best idea I've got is this: tracking each player's usage of my special blueprint items during on_player_cursor_stack_changed so that when I see on_built_entity for ghosts, I can deduce whether they deployed my blueprint (crucially, I must be able to know which blueprint is deployed, or at least the user's label for it).

I think it will probably work but it seems pretty awful. Anyone got a better idea? I'm open to whatever, but in particular wondering if there might be some back-door way to inject an intangible, uniquely identifiable entity of whatever kind into the blueprint, so that I don't need to be spying on cursor stacks all the time and can employ a more traditional compound-entity or fake entity (instantly swapped out on on_built_entity) approach.

321freddy
Fast Inserter
Fast Inserter
Posts: 125
Joined: Fri Sep 23, 2016 10:16 pm
Contact:

Re: Blueprint trickery: advice wanted

Post by 321freddy »

Are you sure simple-entity-with-owners are not blueprintable? AFAIK for an entity to be blueprintable it has to have an item that places the entity, so make sure these always exist. If thats not the issue just try using a different entity type like for example a constant combinator. You could then also save parameters inside it, like the bounding box of your zone or something useful.

golfmiketango
Filter Inserter
Filter Inserter
Posts: 549
Joined: Fri Jan 29, 2016 2:48 am
Contact:

Re: Blueprint trickery: advice wanted

Post by golfmiketango »

321freddy wrote:Are you sure simple-entity-with-owners are not blueprintable? AFAIK for an entity to be blueprintable it has to have an item that places the entity, so make sure these always exist.
This must be it. I don't want the user to see the item so I never created one.

The constant combinator idea had occurred to me as well; as you say, since I can stick an ID signal in there it seems perfect for uniquely identifying the blueprint, I will give that a go for sure.

Only trick to all this is, I don't want the user seeing (or, especially, deselecting) the injected entities in the blueprint configurator. Maybe I need to find some way to prevent re-configuring the custom blueprints somehow....? Anyhow, that's a different problem, one I have yet to really look into. Hopefully this bit of important information this sets me back on the path to victory, thank you!

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Blueprint trickery: advice wanted

Post by eradicator »

You should be able to use

Code: Select all

placeable_by = { item="rail", count = 4}
--from curved-rail prototype
to force your simple-entity to be blueprintable (obviouly use something else than rail). That way you don't need to define an unused item.

As for the rest it's a bit difficult to guess what you're trying to achieve. It sounds like you just need to uniquely identify a blueprint and don't actually need to put an entity into it? How about hashing the result of export_stack?
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.

Post Reply

Return to “Modding help”