@g-js-api/globed
v1.0.1
Published
An API for interacting with Globed's Lua interface using G.js
Readme
@g-js-api/globed
An API for interacting with Globed's Lua interface using G.js
Example
index.js:
import '@g-js-api/g.js';
import globed from '@g-js-api/globed';
await $.exportConfig({
type: 'live_editor',
options: {
info: true
}
});
// entry point for lua codebase (MUST BE RUN RIGHT AFTER EXPORT CONFIG!)
// this will also walk through all `require()` statements!
globed.project('main.lua');
// create a new counter called 'input'
let input = counter();
input.display(45, 45);
// fires event 123 w/o arguments (sets 'input' to a random number between 1 and 10)
globed.fireEvent(123);
// fires event 456 with 'input' as an argument (prints the value of 'input' counter)
globed.fireEvent(456, input);
// exports 'input' counter so the Lua script can reference it (event 123 in specific)
globed.exports({ input });main.lua:
globed.set_callback(123, function(accountID)
-- sets `input` counter to random num between 1 and 10
globed.set_item(accountID, exports.input.item, math.random(1, 10))
end)
globed.set_callback(456, function(accountID, input)
print(input)
end)