Triggers.AddOnLeaveHandler

Declaration

Triggers.AddOnLeaveHandler(Vector2 Position, number Layer, function Handler)

Description

Creates a special Call Function Script trigger action, that calls the Handler function and then adds it to the TriggerZone or Button tile's OnLeave at Position on Layer. This causes the aforementioned tile types to run the Handler function upon being left or otherwise triggered.

function GiveBomb(Tile, Player)
    --The Tile parameter is the Tile object for the tile that ran this function
    --So either the Button or TriggerZone tile.

    --The Player parameter is the Player object, if applicable, of the player that triggered the above tiles
    --So for example the player that walked onto the button

    --Its possible for the Player variable to be nil

    if Player ~= nil then
        local container = Powerups();
        container.Bombs = 1;

        Players.SetPowerups(Player, container, Operation.Add);
    end
end

--Adds a handler to the Button which causes it to run the GiveBomb function
--What's important is that the GiveBomb function will be ran on this ScriptTile, and will have access to its variables
local buttonPos = V2(7, 7);
local buttonLayer = 1;
Triggers.AddOnLeaveHandler(buttonPos, buttonLayer, GiveBomb);

Declaration

Triggers.AddOnLeaveHandler(Vector2 Position, number Layer, bool Relative, Vector2 Origin, function Handler)

Description

Creates a special Call Function Script trigger action, that calls the Handler function and then adds it to the TriggerZone or Button tile's OnLeave at Position on Layer. This causes the aforementioned tile types to run the Handler function upon being left or otherwise triggered. Position can be relative to Origin if Relative parameter is true.

function GiveBomb(Tile, Player)
    --The Tile parameter is the Tile object for the tile that ran this function
    --So either the Button or TriggerZone tile.

    --The Player parameter is the Player object, if applicable, of the player that triggered the above tiles
    --So for example the player that walked onto the button

    --Its possible for the Player variable to be nil

    if Player ~= nil then
        local container = Powerups();
        container.Bombs = 1;

        Players.SetPowerups(Player, container, Operation.Add);
    end
end

--Adds a handler to the Button which causes it to run the GiveBomb function
--What's important is that the GiveBomb function will be ran on this ScriptTile, and will have access to its variables
local buttonRelativePos = V2(2, 2);
local buttonLayer = 1;
local origin = V2(5, 5);
Triggers.AddOnLeaveHandler(buttonRelativePos, buttonLayer, true, origin, GiveBomb);

Declaration

Triggers.AddOnLeaveHandler(Dictionary<Vector2> Positions, number Layer, function Handler)

Description

Creates a special Call Function Script trigger action, that calls the Handler function and then adds it to the TriggerZone or Button tiles OnLeave at Positions on Layer. This causes the aforementioned tile types to run the Handler function upon being left or otherwise triggered. Position can be relative to Origin if Relative parameter is true.

function GiveBomb(Tile, Player)
    --The Tile parameter is the Tile object for the tile that ran this function
    --So either the Button or TriggerZone tile.

    --The Player parameter is the Player object, if applicable, of the player that triggered the above tiles
    --So for example the player that walked onto the button

    --Its possible for the Player variable to be nil

    if Player ~= nil then
        local container = Powerups();
        container.Bombs = 1;

        Players.SetPowerups(Player, container, Operation.Add);
    end
end

--Adds a handler to the Buttons which causes it to run the GiveBomb function
--What's important is that the GiveBomb function will be ran on this ScriptTile, and will have access to its variables
local buttons = {V2(7, 7), V2(7, 5), V2(9, 7), V2(9, 5)};
local buttonLayer = 1;
Triggers.AddOnLeaveHandler(buttons, buttonLayer, GiveBomb);

Declaration

Triggers.AddOnLeaveHandler(Dictionary<Vector2> Positions, number Layer, bool Relative, Vector2 Origin, function Handler)

Description

Creates a special Call Function Script trigger action, that calls the Handler function and then adds it to the TriggerZone or Button tiles OnLeave at Positions on Layer. This causes the aforementioned tile types to run the Handler function upon being left or otherwise triggered. Positions can be relative to Origin if Relative parameter is true.

function GiveBomb(Tile, Player)
    --The Tile parameter is the Tile object for the tile that ran this function
    --So either the Button or TriggerZone tile.

    --The Player parameter is the Player object, if applicable, of the player that triggered the above tiles
    --So for example the player that walked onto the button

    --Its possible for the Player variable to be nil

    if Player ~= nil then
        local container = Powerups();
        container.Bombs = 1;

        Players.SetPowerups(Player, container, Operation.Add);
    end
end

--Adds a handler to the Buttons which causes it to run the GiveBomb function
--What's important is that the GiveBomb function will be ran on this ScriptTile, and will have access to its variables
local relativeButtons = {V2(-1, 1), V2(1, 1), V2(-1, -1), V2(1, -1)};
local buttonLayer = 1;
local origin = V2(8, 6);
Triggers.AddOnLeaveHandler(relativeButtons, buttonLayer, true, origin, GiveBomb);