Class engine.Faction

Factions for actors
Defines 2 factions by default: "Players", "Enemies"

Functions

engine.Faction.add (t)

Adds a new faction

engine.Faction.setInitialReaction (f1, f2, reaction, mutual)

Sets the initial reaction.

engine.Faction.get (id)

Gets the faction definition

Methods

engine.Faction:factionReaction (f1, f2)

Gets the status of faction f1 toward f2

engine.Faction:setFactionReaction (f1, f2, reaction, mutual)

Sets the status of faction f1 toward f2.

engine.Faction:copyReactions (to, from)

Copies all the reactions from/to a faction onto a new one



Functions

engine.Faction.add (t) STATIC
Adds a new faction

Parameters:

  • t the table describing the faction.
    • name string the name of the added faction
    • short_name string the internally referenced name, defaults to lowercase t.name with "-" for spaces. (optional)
    • reaction optional table table of initial reactions to other factions, where keys are short_names.

Returns:

    t.short_name see above
engine.Faction.setInitialReaction (f1, f2, reaction, mutual) STATIC
Sets the initial reaction.

Parameters:

  • f1 string the source faction short_name.
  • f2 string the target faction short_name.
  • reaction number a numerical value representing the reaction, 0 is neutral, <0 is aggressive, >0 is friendly.
  • mutual boolean if true the same status will be set for f2 toward f1.
engine.Faction.get (id) STATIC
Gets the faction definition

Parameters:

  • id

Returns:

    Faction

Methods

engine.Faction:factionReaction (f1, f2)
Gets the status of faction f1 toward f2

Parameters:

  • f1 string the source faction short_name
  • f2 string the target faction short_name

Returns:

    reaction a numerical value representing the reaction, 0 is neutral, <0 is aggressive, >0 is friendly.
engine.Faction:setFactionReaction (f1, f2, reaction, mutual)
Sets the status of faction f1 toward f2. This should only be used after the game has loaded (not in load.lua). These changes will be saved to the savefile.

Parameters:

  • f1 string the source faction short_name.
  • f2 string the target faction short_name.
  • reaction number a value representing the reaction, 0 is neutral, <0 is aggressive, >0 is friendly.
  • mutual boolean if true the same status will be set for f2 toward f1.
engine.Faction:copyReactions (to, from)
Copies all the reactions from/to a faction onto a new one

Parameters:

  • to
  • from
generated by LDoc 1.4.3