ifdef::env-github[]
:tip-caption: :bulb:
:note-caption: :information_source:
:important-caption: :heavy_exclamation_mark:
:caution-caption: :fire:
:warning-caption: :warning:
endif::[]
:toc: left
:toclevels: 5

= Transformer

This module adds transformers.

* it's a generic system to transform (generate, process, convert) items/money/etc to items/money/etc in a specific area
* each transformer can take things to generate other things, using a unit of work
* units are regenerated periodically at a specific rate
* reagents => products (ex: reagents can be nothing to create an harvest transformer)

== Extension

=== Transformer

[source,lua]
----
self.id
self.cfg
self.units
self.users -- map of user => recipe name

Transformer:unbindUser(user)

Transformer:bindUser(user, recipe_name)

Transformer:unbindAll()
----

=== Server

[source,lua]
----
self.cfg
self.transformers -- map of id => transformer
self.processors -- registered processors, map of id => {on_display, on_check, on_process}

-- register a transformer processor
-- on_display(user, reagents, products): should return r_info, p_info (two html strings to display info about the reagents and products)
-- on_check(user, reagents, products): should return true if the processing can occur
-- on_process(user, reagents, products): should process the transformation
-- for the three callbacks:
--- reagents: reagents data, can be nil
--- products: products data, can be nil
Transformer:registerProcessor(id, on_display, on_check, on_process)

-- add a transformer
-- id: transformer identitifer (string)
-- cfg: transformer config
--- title
--- color {r,g,b} (255)
--- max_units
--- units_per_minute
--- pos {x,y,z}
--- radius,height (area properties)
--- permissions: (optional)
--- recipes: map of recipe name => recipe {}
---- description (html)
---- reagents: map of processor id => data, see modules transformer processors
---- products: map of processor id => data, see modules transformer processors
---- permissions: (optional) recipe permissions
---- onstart(transformer, user, recipe_name): (optional) called when the recipe starts
---- onstep(transformer, user, recipe_name): (optional) called at each recipe step
---- onstop(transformer, user, recipe_name): (optional) called when the recipe stops
Transformer:set(id, cfg)

-- remove a transformer
Transformer:remove(id)
----

== Menu

=== transformer

Transformer menu.

.data
[horizontal]
transformer:: transformer instance
