Kryzeth Standard Library

StdLib.Event.Force

Force storage creation. <p>All new forces will be added to the storage.forces table. <p>This modules events should be registered after any other Init functions but before any scripts needing storage.players. <p>This modules can register the following events: on_force_created, and on_forces_merging.

@usage

Methods8

function Force.additional_data(...) -> StdLib.Event.Force
function Force.get(force: string | LuaForce) -> (LuaForce, table)

Get game.forces[name] & storage.forces[name], or create storage.forces[name] if it doesn't exist.

Parameters
forcestring | LuaForce

the force to get data for

Returns
LuaForce

the force instance

table

the force's storage data @usage local Force = require('kry_stdlib/stdlib/event/force') local forcename, forcedata = Force.get("player") local forcename, forcedata = Force.get(game.forces["player"]) -- Returns data for the force named "player" from either a string or LuaForce object

function Force.add_data_all(data: table) -> nil

Merge a copy of the passed data to all forces in storage.forces.

Parameters
datatable

a table containing variables to merge @usage local data = {a = "abc", b = "def"} Force.adddataall(data)

Returns
nil
function Force.init(event: nil | string | table[opt], overwrite: nil | boolean) -> any

Init or re-init a force or forces. Passing a nil event will iterate all existing forces.

Parameters
eventnil | string | table[opt]

table or a string containing force name

overwritenil | boolean

[opt=false] the force data

Returns
any
function Force.dump_data() -> nil
function Force.merged(event) -> nil

When forces are merged, just remove the original forces data

function Force.register_init() -> StdLib.Event.Force
function Force.register_events(do_on_init) -> StdLib.Event.Force

Register Events

Fields3

Force.__class: string = "Force"
Force.__index : unknown
Force._new_force_data: table