callbacks

NoitaPatcher adds some callbacks to whatever Lua context imports its module.

To use OnProjectileFired and OnProjectileFiredPost you must call noitapatcher.InstallShootProjectileFiredCallbacks().

OnProjectileFired(shooter_id, projectile_id, rng, position_x, position_y, target_x, target_y, send_message, unknown1, multicast_index, unknown3)

Called when a projectile is fired.

The RNG that would be used is passed in, but at this point it can be modified by noitapatcher.SetProjectileSpreadRNG().

This callback is mostly useful if you want to change the RNG, or if you want to synchronise the RNG value to other clients.

Parameters:
  • shooter_id (integer) – Entity id of the entity that fired the projectile.

  • projectile_id (integer) – Entity id of the projectile that was fired.

  • rng (integer) – The current RNG state that will affect the velocity, direction, and other aspects of the projectile.

  • position_x (number) – X position from which the projectile will be fired.

  • position_y (number) – Y position from which the projectile will be fired.

  • target_x (number) – X position towards which the projectile is fired.

  • target_y (number) – Y position towards which the projectile is fired.

  • send_message (boolean) –

    Will a message get sent to the DamageModel, GameEffect, DebugLogMessages, and Lua systems?

    This causes things like the ‘shot’ Lua callback to be called.

  • unknown1 (integer) – 4 byte integer. Unknown what this is for. Maybe recursion_level

  • multicast_index (integer) – What number projectile is this in a multi-cast. -1 if multi-casts doesn’t make sense.

  • unknown3 (integer) – 1 byte integer, probably actually a boolean. It’s unknown what this is for.

OnProjectileFiredPost(shooter_id, projectile_id, rng, position_x, position_y, target_x, target_y, send_message, unknown1, unknown2, unknown3)

Exactly the same callback as OnProjectileFired() except that it’s called after Noita’s internal GameShootProjectile function has run. At this point changing the RNG by calling noitapatcher.SetProjectileSpreadRNG() won’t have any effect on the projectile.

This callback is mostly useful for when you want to extract the exact projectile parameters that were generated from the RNG. (e.g. velocity/direction.)

FilterLog(source, function_name, linenumber, ...)

Decide whether the log should be performed or not. Only called once enabled by calling noitapatcher.EnableLogFiltering().

Parameters:
  • source (string) – Where does the log entry come from? Special value “=[C]” means there’s no known source file.

  • function_name (string) – The function that called print.

  • linenumber (integer) – Line number of the log call.

  • ... (string) – All the arguments that are logged, passed in as separate arguments

Returns:

Whether to perform the logging (true) or not (false).

Return type:

boolean