Introduction

Last modification: 196 days, 6 hours ago

Welcome! This site was made to help you creating mods / custom maps for Infinitode 2.

The game uses Lua (specifically, custom version of LuaJ library) for its scripting purposes so you may want to get familiar with Lua first.

Current state of modding / scripting in Infinitode 2

Join our Discord server if you want to discuss the future of modding in this game. It is the best time now to tell us your thoughts and suggest what can be changed to make modding more flexible and easy for you.

Example

As a best way to describe modding, just take a look at this piece of code - it can be put into the Script tile and the game will start it at the beginning of each run on the map.

Do not worry if some things are not familiar for you, I'll explain them later:

-- Wait for full setup of the game to make sure all of the systems are available and ready
addEventHandler("SystemPostSetup", function()
    -- Create new instance of EnemySystemListener interface that will react to events in Enemy system
    local enemySystemListener = luajava.createProxy(GNS .. "systems.EnemySystem$EnemySystemListener", {
        -- This method will be called each time any enemy dies, see Javadoc for method reference
        enemyDie = function(enemy, tower, damageType, fromAbility, projectile)
            -- Create new instance of generic explosion
            local explosion = managers.ExplosionManager:getFactory(enums.ExplosionType.GENERIC):obtain();
            -- Set up the explosion
            explosion:setup(tower, enemy:getPosition().x, enemy:getPosition().y, enemy.maxHealth * 0.05, 1.25, 0, nil)
            -- Register the explosion entity in the game
            SP.explosion:register(explosion)
            -- Make it explode right away
            explosion:explode()
        end,

        -- Notify the game that this listener is important and affects the gameplay
        affectsGameState = function() return true end,
        getConstantId = function() return 9001 end
    })

    -- Subscribe to the Enemy system and listen for its events with enemySystemListener
    SP.enemy.listeners:add(enemySystemListener)
end)

This script will make every enemy explode on death with 5% of their max HP.

Further reading


  1. Global mods will interfere with the server and may lead to different failures during validation of replays. They also require access to more dangerous methods and may do harm to accounts or the game itself. It was decided to limit official support to community maps and preserve all of the game's features