DMV - Directional Movement Vehicles


Vehicles move like players! - W for North - A for West - S for South - D for East And so much more!

Content
5 months ago
1.1
957
Transportation

b Missing event handlers

4 months ago
(updated 4 months ago)

Hi! You only listen to on_built_entity and on_entity_died. However, you will miss entities that are placed by bots or script, or mined by the player etc. I think you should listen to the following events instead:

Build events:

  • on_built_entity
  • on_entity_cloned
  • on_robot_built_entity
  • script_raised_built
  • script_raised_revive

Removal events:

  • on_entity_destroyed
  • on_entity_died
  • on_player_mined_entity
  • on_robot_mined_entity
  • script_raised_destroy

Some of these may use different event data, so you can reuse your existing event handlers with slight adjustments. Here's an example from the handler for build-events in one of my mods:

  -- We use the same function for different events, so we must cover all different
  -- key names to get the entity!
  local vehicle = event.created_entity or -- on_built_entity/on_robot_built_entity
                  event.destination or    -- on_entity_cloned
                  event.entity            -- script_raised_*
4 months ago

Hi, Pi-C! Thank you, I've implemented the Build events for the next version. In the case of Removal events, the use-case is only if the car is actually killed by damage and leaves behind a corpse, so I think that is working as-is.

4 months ago

Hi, Pi-C! Thank you, I've implemented the Build events for the next version.

Thanks!

In the case of Removal events, the use-case is only if the car is actually killed by damage and leaves behind a corpse, so I think that is working as-is.

Yes, looks like it. I thought you'd need this to clean up your tables, but this seems to be taken care of by your metatables.

New response