Finish initial API

This commit is contained in:
raymoo 2016-01-06 02:21:56 -08:00
parent 3ac4e29c8d
commit c46b7d1166

64
API.txt
View File

@ -61,3 +61,67 @@ The two values passed in are not guaranteed to be different, so plan accordingly
Effect Types
============
An effect type is a description of an effect, that can be applied later in an
individual effect.
Definition
----------
An effect type is defined with a table with the following properties (defaults
in parens):
disp_name - Display name
dynamic - A bool for whether an effect of this type can have its values
changed (false)
tags - A set of tags ({})
monoids - The set of monoids this effect type affects
hidden - A boolean for whether it should be shown to the affected (false)
cancel_on_death - A boolean for whether this effect should be removed from the
player when they die.
values - A table mapping monoid names to associated values. These are the
values that will be combined in the monoid.
icon - A texture string (if nil, no icon is shown)
Functions
=========
monoidal_effects.register_monoid("name", monoid_def)
Registers a new effect monoid. name needs to be unique across all mods, so
you should prepend your mod name, as in nodes/craftitems.
monoidal_effects.register_type("name", type_def)
Registers a new effect type. name needs to be unique.
monoidal_effects.add_child_monoid("parent_name", "child_name"[, convert])
Sets a monoid to be the child of another. When calculating the combined value
for the parent monoid, values of the child monoids will also be mixed in, to
the left of all "actual" values, in order of registration.
monoidal_effects.apply_effect("effect_type", duration, "player_name"[, values])
Applies a new effect of the specified type. duration should be a positive
integer number of seconds or the string "perm". values is an optional table
mapping monoid names to values, and is used with dynamic effect types to
initialize the effect with custom values. Has no effect on static effect types.
Returns an effect id.
monoidal_effects.cancel_effect(effect_id)
Cancels the given effect.
monoidal_effects.cancel_monoid("monoid_name"[, "player_name"])
Cancels all effects from a particular monoid on a player.
monoidal_effects.cancel_effect_type("effect_type", "player_name")
Cancels all effects from a player that are a certain effect_type. If player_name
is nil, it cancels all matching effects from all players.
monoidal_effects.cancel_tag("tag"[, "player_name"])
Cancels all effects from a player with the given tag. If player_name is nil,
it cancels all matching effects from all players.
monoidal_effects.get_remaining_time(effect_id)
Gets the remaining time of an effect, in seconds.
monoidal_effects.get_player_effects("player_name")
Gets a set of effects applied to the given player
monoidal_effects.get_monoid_value("monoid_name", "player_name")
Gets the current combined value for a monoid and player.