Amator Phasma's Library

First of all: this is a resource and code library for my other mods. It self comes with extended functions for inserter: 1) make it possible that a inserter can handle the 'burnt result inventory' on all machines. 2) burner inserters can leech fuel from pickup and drop target. 3) burner inserters are capable to chain fuel through all burner type machines.
5 days ago
0.17 - 0.18


Remote interfaces in the data and control stage

Version 0.19.0 (online version:

MOD: Amator Phasma's Library

Data stage:

Define an item as radioactiv in the data stage generates the descripton for it.<br/>
*usage in any data stage type after this library's data stage with:<br/>
apm.lib.utils.item.add.radioactive_description(item_name :: string, level :: int)<br/>
level: (optional / default is 1)
- 1: low radioactive
- 2: medium radioactive
- 3: high radioactive


apm.lib.utils.item.add.radioactive_description('apm_yellowcake', 1)

Control stage:
Define an item as radioactiv in the control stage by using a remote interface to register or unregister it to give the player damge if he has one in his inventory.

Register an item:<br/>'apm_radiation', 'add_item', item_name :: string, level :: int)<br/>
level: (optional / default is 1)
- 1: low radioactive
- 2: medium radioactive
- 3: high radioactive

Unregister an items:<br/>'apm_radiation', 'remove_item', item_name :: string)

List all registered items:<br/>'apm_radiation', 'list_items') -> returns a table

Examples:'apm_radiation', 'add_item', 'uranium-ore', 1)'apm_radiation', 'remove_item', 'uranium-ore')'apm_radiation', 'list_items')

Define an equipment with the burner property.

Register an equipment:<br/>'apm_equipment', 'add_burner_equipment', string ::<br/>

Unregister an items:<br/>'apm_equipment', 'del_burner_equipment', string ::<br/>

Examples:'apm_equipment', 'add_burner_equipment', 'fusion-reactor-equipment')'apm_equipment', 'del_burner_equipment', 'fusion-reactor-equipment')

You can also register to the following events:
they return event{player = LuaPlayer, LuqEquipment = equipment}
- event_on_burner_equipment_low_fuel

script.on_event("apm_equipment", "event_on_burner_equipment_low_fuel"), function(event)
    -- your stuff here
  • event_on_burner_equipment_burnt_result_inventory_full
script.on_event("apm_equipment", "event_on_burner_equipment_burnt_result_inventory_full"), function(event)
    -- your stuff here

WARNING: this has to be done within on_init and on_load, otherwise the game will error about the

MOD: Amator Phasma's Recycling

Data stage:

You can easily add scrap metal to products in the data-updates phase with:<br/>
apm.lib.utils.recycling.scrap.add(, metal=Type/String, probability=Type/Double)<br/>
-- The probability is optional to overwrite the value from the settings


-- This results in a 10% probability for iron scrap
apm.lib.utils.recycling.scrap.add({recipe='pipe', metal='iron'})

-- This results in a 5% probability for iron scrap and 5% for copper scrap
apm.lib.utils.recycling.scrap.add({recipe='pipe', metal='iron'})
apm.lib.utils.recycling.scrap.add({recipe='pipe', metal='copper'})

-- This results in a 30% probability for iron scrap
apm.lib.utils.recycling.scrap.add({recipe='pipe', metal='iron', probability=0.3})

Delete the scrap metal output generation for a recipe with:<br/>



To define your one scrap metal you need a bit more:<br/>
name :: string -> an arbitrary name for a metal (like: iron, copper, titanium, etc..)<br/>
tint :: Color -> the color of this metal<br/>
output :: -> an prototype name of an item<br/>
output_category: -> the recipe-category for the last recycling step (Default: 'smelting' example: for angel metals: 'induction-smelting')<br/>
wight: -> int: <4 for tier 1, =4 tier 1 recycler but tier 2 technologie, <8 for tier 2, <11 for tier 3, >=11 for tier 4. In the future this will also determine the importance of this metal for a further automatic generation.<br/>
output_probability :: nil a dummy for the futere, has no impact at this moment<br/>
t_catalysts :: LuaTable -> example: {{type='fluid', name='steam', amount=100}} (only two inpute-pipe)<br/>
t_output_byproducts :: LuaTable -> example: {{type='fluid', name='water', amount=50}} (only two output-pipe)<br/>
b_own_tech :: Bool -> if true there is a own tech generated for the recipes of this metal/scrap process<br/>
t_tech_prerequisites :: LuaTable -> has only effect if b_own_tech is true, a table of technologies that are used as prerequisites for this recipe chain<br/>
* output_amount_overwrite :: int -> overwrites the default output for the last recipe in the process<br/>


apm.lib.utils.recycling.metal.add({name='iron', tint={r= 0.56, g = 0.63, b = 0.74}, output='iron-plate', wight=1})
apm.lib.utils.recycling.metal.add({name='tin', tint={r= 0.33, g = 0.49, b = 0.36}, output='liquid-molten-tin', output_category='induction-smelting', wight=2, b_own_tech=true, t_tech_prerequisites={'angels-tin-smelting-1'}})
apm.lib.utils.recycling.metal.add({name='lead', tint={r= 0.60, g = 0.75, b = 0.90}, output='lead-plate', wight=2, b_own_tech=true})

If you add an Metal thats not defines in my ./prototypes/recycling/generate_metal.lua you need to add an local string for translations:<br/>


If you want look in the code: you can it doe here...

Important: You have to create the metal type BEFORE you can add scrap metal to a recipe, this means you should prepare the load order to load your data-updates phase after this mod, to use the "defaults" defined in ./prototypes/recycling/generate.lua

MOD: Amator Phasma's Starfall

Control stage:

Register a surface:<br/>'apm_starfall', 'add_surface', surface :: LuaSurface.index)

Unregister a surface:<br/>'apm_starfall', 'remove_surface', surface :: LuaSurface.index)

List registered surfaces:<br/>'apm_starfall', 'list_surfaces') -> returns a table

Queue up an event for a surface:<br/>'apm_starfall', 'add_event', surface :: LuaSurface.index, amount :: int, ticks :: Game.Ticks, range :: LuaArea)

Examples:'apm_starfall', 'add_surface', 1)'apm_starfall', 'remove_surface', 1)'apm_starfall', 'list_surfaces')'apm_starfall', 'add_event', 1, 2, game.tick+600)'apm_starfall', 'add_event', 1, 2, game.tick+600, {max=128,min=10})