Factorio-Paranoidal_mod/erm_zerg_hd_assets/update-teamcolour.sample.lua

73 lines
3.0 KiB
Lua

---
--- Generated by EmmyLua(https://github.com/EmmyLua)
--- Created by heyqule.
--- DateTime: 8/7/2022 7:42 PM
---
--- This files serve as an example on how to update team color, this required ERM core mods.
---
--- add this file with require('update-teamcolour') in your mod
---
local AnimationDB = require('__erm_zerg_hd_assets__/animation_db')
local ERM_UnitHelper = require('__enemyracemanager__/lib/rig/unit_helper')
local String = require('__stdlib__/stdlib/utils/string')
--- Grab all applicable types
local entity_types = {'unit','unit-spawner', 'turret', 'explosion', 'corpse'}
--- You can code your own team color format function
local color = ERM_UnitHelper.format_team_color(settings.startup['erm_zerg-team_color'].value)
--- Disable team mask
local disable_mask = true
if settings.startup['erm_zerg-team_color_enable'].value then
disable_mask = false
end
--- Use blend mode: additive-soft to preserve glossy look.
local preserve_gloss = false
if settings.startup['erm_zerg-team_color_preserve_gloss'].value then
preserve_gloss = true
local strength_multipler = 0.8
color.r = color.r * strength_multipler
color.g = color.g * strength_multipler
color.b = color.b * strength_multipler
else
-- Lower color strength to prevent neon colors.
local strength_multipler = 0.5
color.r = color.r * strength_multipler
color.g = color.g * strength_multipler
color.b = color.b * strength_multipler
end
--- Make sure entity match the name pattern of your entities
local name_check = function(name)
local nameToken = String.split(name, '/')
return nameToken[1] == 'erm_zerg'
end
for _, entity_type in pairs(entity_types) do
for _, entity in pairs(data.raw[entity_type]) do
if name_check(entity.name) == true then
--- You may add addition
if entity['animation'] then
entity['animations'] = AnimationDB.alter_team_color(entity['animation'], color, disable_mask, preserve_gloss)
end
if entity['animations'] then
entity['animations'] = AnimationDB.alter_team_color(entity['animations'], color, disable_mask, preserve_gloss)
end
if entity['run_animation'] then
entity['run_animation'] = AnimationDB.alter_team_color(entity['run_animation'], color, disable_mask, preserve_gloss)
end
if entity['attack_parameters'] and entity['attack_parameters']['animation'] then
entity['attack_parameters']['animation'] = AnimationDB.alter_team_color(entity['attack_parameters']['animation'], color, disable_mask, preserve_gloss)
end
if entity['folded_animation'] then
entity['folded_animation'] = AnimationDB.alter_team_color(entity['folded_animation'], color, disable_mask, preserve_gloss)
end
if entity['starting_attack_animation'] then
entity['starting_attack_animation'] = AnimationDB.alter_team_color(entity['starting_attack_animation'], color, disable_mask, preserve_gloss)
end
end
end
end