Skip to content
This repository was archived by the owner on Aug 7, 2024. It is now read-only.
glebi574 edited this page Nov 27, 2023 · 4 revisions

content/camera.lua defines pplaf.camera - Camera framework.

Overview

pewpew camera follows average position of every player, controlled by player. pewpew functions also allow you to override camera position. PPLAF uses this feature to automate camera movement and allow you to control it by changing certain parameters.
To control camera parameters you use configure(). Let's see parameters, you can configure:

  • current_* - current x/y/z camera coordinate.
  • static_* - if not nil, x/y/z camera coordinate won't be changed. If current coordinate isn't equal to static coordinate, camera will keep moving to static coordinate. Static value ignores any coordinate modifiers other than free_mode.
  • offset_* - if not nil, additional offset will be added to camera x/y/z coordinate.
  • min_* - if not nil, camera x/y/z coordinate won't get lower than this value.
  • max_* - if not nil, camera x/y/z coordinate won't get higher than this value.
  • base_z - basic z coordinate of camera. Originally it is same as in pewpew - 1000fx.
  • z_distance_ratio - camera.main() calculates biggest distance between 2 entities(that are used in average position calculation) and multiplies this value by z_distance_ratio. Then that value is added to z coordinate.
  • movement_offset - maximum camera xy offset, applied while using movement joystick.
  • movement_z_offset - maximum camera z offset, applied while using movement joystick.
  • shooting_offset - maximum camera xy offset, applied while using shooting joystick.
  • shooting_z_offset - maximum camera z offset, applied while using shooting joystick.
  • following_type - index of following type. It determines which entities will be used to calculate average camera position. While using configure(), you can input this parameter as name of the type and it will be transformed to index automatically.
  • following_param - parameters, that will be used to calculate average camera position depending on following_type.
  • ease_function - custom ease function, that will be applied on certain distance to make camera movement look smooth. Ease function is required to take fx input and output fx value.
  • ease_distance - if camera xy/z position is lower than this value, ease function will be applied.
  • velocity - maximum speed of the camera.
  • free_mode - if true, every parameter mentioned before(other than velocity) is ignored and camera is controlled by movement joystick.

following_type was mentioned before. There are multiple options for value of following_type and following_param. Type variants are stored in camera.following_types:

  • entity = 100 - single entity is followed, following_param contains id of this entity.
  • entity_list = 101 - multiple entities are followed, following_param contains ids of these entities.
  • group = 200 - every entity in the group is followed, following_param contains name of the group.
  • group_list = 201 - every entity in list of groups are followed, following_param contains names of the groups.
  • all = 300 - every entity is followed, following_param isn't used in this case.

pplaf.camera

Variables

following_types - table, containing possible options for following different groups of entities.
options - table, containing current parameters for camera position, speed, movement parameters, etc.

Functions

nil configure(table options)

Configures options of camera.

pplaf.camera.configure({
  static_x = 500fx,
  static_y = 500fx,
})

Camera callback that modifies camera position and other parameters depending on current parameters.

pplaf.camera.main()

Clone this wiki locally