The bank controller's purpose is to allow for custom currency integrations.

All functions shown below are required and the data you provide is completely up to you.

(Usually currency integrations will use Websockets or WWWRequests to be the middle-man for talking between applications)

First you have to enable the LuaScript Integration found in: Shop Editing > Currency Settings.

script_trigger_type = 'On Connect';

--the withdraw, deposit, getBalance, getRichest, fixedAdjustment 
--MUST return value(s);

function fixedAdjustment(viewerId, amount)

    --code to set the viewerId's currency to the exact amount
    return amount; --return the new balance

function getRichest(howMany)
    --this is used for extension leaderboard data. the data returned here will be displayed on the extension

    --try to grab the top howMany requested and put it into a richest array like so...
    --this array will be sorted correctly so order doesnt matter, just ensure it's the richest users.

    local richestArray = {
        { displayName = 'clonzeh', points = 1234 },
        { displayName = 'Person2', points = 442 },
        { displayName = 'Person3', points = 14532 }

    return richestArray; --return the richest users array

function getBalance(viewerId)
    --code to check lua balance of viewerId;
    return 1234; --return the balance of the viewer

function deposit(viewerId, amount)
    --code to add points to the viewerid
    local newBalance = 1234 + amount;
    --finish code
    return newBalance; --return the new balance of the viewer

function withdraw(viewerId, amount)

    local balanceFound = 1234;
    local success = false;
    if balanceFound > amount then
        --code to subtract points from the viewerId
        local newBalance = balanceFound - amount;
        --if the subtraction works then
        --set success to true...
        success = true;
        return success, newBalance;

    return success, balanceFound; --return the new balance of the user

function massDeposit(viewerIds, amounts)

    --efficiently deposit large amounts points to users...
    --this is useful if a custom bot currency system has an endpoint to adjust multiple users at once.

    --or just do it one at a time inside a loop the deposit(viewerId, amount); function
    for key, value in ipairs(viewerIds) do
        deposit(value, amounts[key]);

return function()
    setupBankController(); --adds all required events for the bank controlling system.
    --NOTE: All functions above must exist with the same parameters specificed.

Events are asynchronous coroutines.

Last updated