Define Laser

From LuaSTG Wiki
Jump to navigation Jump to search

A define laser node defines a custom laser type.

As in the Touhou series, a laser in LuaSTG is typically a long, straight and capsule or elliptical-shaped object that kills the player on contact.

A custom laser type is a LuaSTG object class (see Game Object). Laser types defined by the define laser node can be created using the create laser node. A custom laser works in very much the same way as a custom bullet does, except with a few more options for controlling laser length and on/off.


On, Half-on and Off[edit | edit source]

LuaSTG supports three laser states that a laser can be in.

  1. A custom laser is turned off by default when it is spawned. In this state the laser will not be visible, and it does not have collision box towards the player.
  2. A laser can be turned half-on. In this state the laser will appear to be half-transparent, but has no collision box.
  3. A laser can be turned on. In this state the laser will be opaque, and it will kill the player on a collision.

Switching can be done from any laser state to the others. Collisions between the laser and the player are only checked once the laser is completely turned on.


Laser Position and Rotation[edit | edit source]

A laser is always oriented in the following way: In every frame, the tip of the laser head will be automatically placed at the position (laser.x,laser.y) by the laser, assuming laser is the laser object. The rotation of the laser, in other words, the direction the head point to the tail of the laser, will be set to laser.rot.

A laser shapes like "head--body--tail".

Parameters[edit | edit source]

Define Laser Node[edit | edit source]

Here is a list of parameters for define laser node.

Parameters Function
Name (string without quotations) Name of the laser, this can be used to identify and select the laser type in a create laser node
Difficulty (string without quotations) If different difficulties of the game use the same laser type with different behaviors, this can be set to distinguish between them. Essentially this creates a brand new type of laser for each difficulty


On Init Node[edit | edit source]

A define laser node will always come with an on init node. Here is a list of parameters for this particular node.

Parameters Function
Parameter List (parameter list) A list of parameters for this laser type
Color (number) The color of the laser
Style (number) The type of the laser
Head Length (number) The length of the half-elliptical head part of the laser. This sets the l1 attribute of the laser
Body Length (number) The length of the rectangular body part of the laser. This sets the l2 attribute of the laser
Tail Length (number) The length of the half-elliptical tail part of the laser. This sets the l3 attribute of the laser
Width (number) The width of the laser.
Node size (number)
Head size (number)


On Kill[edit | edit source]

By default, a laser cannot be destroyed by the player with death cancel effect or bombs, but it is killed at the end of a spell. On a kill, the laser will be turned into a straight line of faith points and disappear.