3.3.3-alpha.8912801426 • Published 12 hours ago

@casual-simulation/aux-runtime v3.3.3-alpha.8912801426

Weekly downloads
-
License
MIT
Repository
github
Last release
12 hours ago

AUX Common

npm (scoped)

A library that contains common operations needed to modify and understand AUX files.

Installation

$ npm install @casual-simulation/aux-common

Usage

Calculate a formula for some bots

import {
    createBot,
    createCalculationContext,
    calculateFormulaValue,
} from '@casual-simulation/aux-common';

const file1 = createBot('test1', {
    quantity: 10,
});
const file2 = createBot('test2', {
    quantity: 5,
});
const file3 = createBot('test3', {
    quantity: 5,
});

const context = createCalculationContext([file1, file2, file3]);

const formula = '=math.sum(getBotTagValues("#quantity"))';
const result = calculateFormulaValue(context, formula);

console.log(result);

// Outputs:
// 20

Calculate events for an action script

import {
    createBot,
    createCalculationContext,
    calculateFormulaEvents,
} from '@casual-simulation/aux-common';

const state = {
    test1: createBot('test1', {
        quantity: 10,
    }),
    test2: createBot('test2', {
        quantity: 5,
    }),
    test3: createBot('test3', {
        quantity: 5,
    }),
};

const formula = `
    let total = math.sum(getBotTagValues("#quantity"));
    player.toast("The total is " + total);
`;
const events = calculateFormulaEvents(state, formula);

for (let event of events) {
    if (event.type === 'local') {
        if (event.name === 'show_toast') {
            console.log('[Toast]', event.message);
        }
    }
}

// Outputs:
// [Toast] The total is 5
3.3.2

2 days ago

3.3.1

5 days ago

3.3.0

16 days ago

3.2.19

1 month ago

3.2.18

1 month ago

3.2.17

2 months ago

3.2.16

2 months ago

3.2.15

2 months ago

3.2.14

2 months ago

3.2.13

3 months ago

3.2.12

3 months ago

3.2.11

3 months ago

3.2.10

4 months ago

3.2.9

4 months ago

3.2.8

4 months ago

3.2.7

4 months ago