Is it possible to directly generate pollution within a trigger?

Place to get help with not working mods / modding interface.
Galadedrid
Manual Inserter
Manual Inserter
Posts: 3
Joined: Tue Nov 26, 2024 1:29 pm
Contact:

Is it possible to directly generate pollution within a trigger?

Post by Galadedrid »

I'm trying to repurpose the Vulcanus "create a smoke cloud when an item is destroyed in lava" trigger for Nauvis, but while I'm aware of the pollute function I'm not actually sure how I would go about calling that within an action_delivery - or indeed how I could make sure the pollution appears at the location creating the trigger even if I did.

Is there a straightforward way to accomplish this?

To clarify, the Vulcanus function is:

Code: Select all

local destroyed_item_trigger =
{
  type = "direct",
  action_delivery =
  {
    type = "instant",
    source_effects =
    {
      type = "create-trivial-smoke",
      smoke_name = "smoke",
      offset_deviation = {{-0.1, -0.1}, {0.1, 0.1}},
      starting_frame_deviation = 5
    }
  }
}
I would like to know if it's possible instead have the action create a small puff of pollution at the location the effect is triggered.
TacticalMook
Manual Inserter
Manual Inserter
Posts: 3
Joined: Sun May 10, 2026 7:52 am
Contact:

Re: Is it possible to directly generate pollution within a trigger?

Post by TacticalMook »

Necro post, but I came across the function definition and remembered seeing this thread while looking for something else.

The code that OP linked can be found here.
This is a local table (array), so where is it used? It's used in two LuaTilePrototype declarations in the same file. Here's one of them:

Code: Select all

 ----------- "SHALLOW" LAVA
  {
    type = "tile",
    name = "lava",
 -- ...
    destroys_dropped_items = true,
    default_destroyed_dropped_item_trigger = destroyed_item_trigger,
The default_destroyed_dropped_item_trigger class member has type array[TriggerItem]
TriggerItem has a action_delivery key with type array[TriggerDelivery]
TriggerDelivery has a source_effects key with type array[TriggerEffectItem]
TriggerEffectItem has a type key that is a union (struct) defined to have these types, which are described more thoroughly here

In particular, "script" is associated with ScriptTriggerEffectItem, which will raise a on_script_trigger_effect event. Register a handler (function) for the event using LuaBootstrap::on_event(). Your handler will be passed the on_script_trigger_effect table, which has a source_position key with type MapPosition. So that's how you get the trigger location.

The first parameter of LuaSurface::pollute(), source, is of the same type: MapPosition. So that's how you set the pollution location.

source_position is flagged as optional, but surely the game will populate it when the event is raised by anything that actually has a discrete map position, like this action_delivery from a tile?
User avatar
Osmo
Filter Inserter
Filter Inserter
Posts: 287
Joined: Wed Oct 23, 2024 12:08 pm
Contact:

Re: Is it possible to directly generate pollution within a trigger?

Post by Osmo »

Pollution trigger effect will be added in 2.1 viewtopic.php?p=687450
But right now you can use script trigger effects as said above.
Post Reply

Return to “Modding help”