Collision Event Functions - Lojemiru/Loj-Hadron-Collider GitHub Wiki
Collision Event functions provide a robust toolset for behavior on collisions, allowing for simple detection of collision variables and easily controllable stopping behavior.
These functions are only for use in LHC collision event functions, as defined by lhc_add(). They will result in undefined behavior if called outside of a collision event!
lhc_colliding
Returns the current colliding instance.
Syntax:
lhc_colliding();
Returns: Real (either an instance ID value or the keyword noone)
Example:
lhc_add("IPlayer", function() {
lhc_colliding().take_damage(60);
});
lhc_collision_down
Returns whether or not the current collision is occurring on the bottom of this instance.
Syntax:
lhc_collision_down();
Returns: Boolean
Example:
lhc_add("ISolid", function() {
if (lhc_collision_down()) {
lhc_stop_y();
yVel = 0;
}
});
lhc_collision_horizontal
Returns whether or not the current collision is occurring on the left or right of this instance.
Syntax:
lhc_collision_horizontal();
Returns: Boolean
Example:
lhc_add("ISolid", function() {
if (lhc_collision_horizontal()) {
lhc_stop_x();
xVel = 0;
}
});
lhc_collision_left
Returns whether or not the current collision is occurring on the left of this instance.
Syntax:
lhc_collision_left();
Returns: Boolean
Example:
lhc_add("ISolid", function() {
if (lhc_collision_left()) {
lhc_stop_x();
xVel = 0;
}
});
lhc_collision_right
Returns whether or not the current collision is occurring on the right of this instance.
Syntax:
lhc_collision_right();
Returns: Boolean
Example:
lhc_add("ISolid", function() {
if (lhc_collision_right()) {
lhc_stop_x();
xVel = 0;
}
});
lhc_collision_static
Returns whether or not the current collision is occurring as a static collision (i.e. directionless/detected while not moving).
Syntax:
lhc_collision_static();
Returns: Boolean
Example:
lhc_add("ISolid", function() {
if (lhc_collision_static()) {
// Pretend there's code here to move the object out of the solid or something
}
});
lhc_collision_up
Returns whether or not the current collision is occurring on the top of this instance.
Syntax:
lhc_collision_up();
Returns: Boolean
Example:
lhc_add("ISolid", function() {
if (lhc_collision_up()) {
lhc_stop_y();
yVel = 0;
}
});
lhc_collision_vertical
Returns whether or not the current collision is occurring on the top or bottom of this instance.
Syntax:
lhc_collision_vertical();
Returns: Boolean
Example:
lhc_add("ISolid", function() {
if (lhc_collision_vertical()) {
lhc_stop_y();
yVel = 0;
}
});
lhc_stop
Stops all further movement during this step. Worth noting is that this function does not control your input velocity variables for lhc_move
; you must define their values yourself.
Syntax:
lhc_stop();
Returns: N/A
Example:
lhc_add("ISolid", function() {
lhc_stop();
xVel = 0;
yVel = 0;
});
lhc_stop_x
Stops all further x-axis movement during this step. Worth noting is that this function does not control your input x velocity variable for lhc_move
; you must define its value yourself.
Syntax:
lhc_stop_x();
Returns: N/A
Example:
lhc_add("ISolid", function() {
if (lhc_collision_horizontal()) {
lhc_stop_x();
xVel = 0;
}
});
lhc_stop_y
Stops all further y-axis movement during this step. Worth noting is that this function does not control your input y velocity variable for lhc_move
; you must define its value yourself.
Syntax:
lhc_stop_y();
Returns: N/A
Example:
lhc_add("ISolid", function() {
if (lhc_collision_vertical()) {
lhc_stop_y();
yVel = 0;
}
});