itb-community / ITB-ModLoader

A lua-based mod loader for the game Into the Breach
48 stars 17 forks source link

Create framework for custom environments #215

Open Lemonymous opened 1 year ago

Lemonymous commented 1 year ago

Changes

Usage

Creating an instance of an environment:

A simple example of adding and starting a custom environment:

local mission = GetCurrentMission()
local env = Env_Lightning:new()

-- We must manually start custom environments, since we can dynamically add/remove them.
-- In general 'Start' just sets up necessary tables that is required by the environment.
env:Start()

-- Add the environment to the mission using a unique identifier, so we can find our environment later,
-- and avoid collisions with other environments added by other mods.
mission.CustomEnv["unique_env_id"] = env

-- Insert a point to 'Locations'. Many (but not all) environments use this to determine marked tiles that
-- should be affected when the environment effect is being processed.
table.insert(env.Locations, Point(0,0))

Minimalistic example mod

Link to a minimalistic modded weapon that can add environment lightning tiles, using the code added by this PR: https://github.com/Lemonymous/ITB-MinimalisticExampleMods/blob/master/mods/custom_environment_weapon/scripts/env_weapon.lua