Getting started

Last modification: 196 days, 11 hours ago

This article will explain how to create your first scripted map and the lifecycle of scripts that will normally be put into Script tiles on a map.

You may want to get familiar with the architecture of the game to better understand where the game finds and how it loads Lua scripts.

Before we begin, make sure to prepare your game for modifications - this will enable developer mode and map editor for you.

Making your first map

  1. Run the modified game (double click C:/I2Mod/infinitode-2.exe or run it through the terminal)
  2. Click on the New game button, you will see a couple of default maps used for development purposes
  3. Click on a thumbnail of any map to open its regular menu. You will find a couple of new buttons in the upper right corner of the leve's menu: purple tools purple tools will open the Level configuration editor and blue pencil blue pencil with paper will open the map editor for the selected level
  4. Open the purple tools configuration editor and then click on Add level. Name your new map, for example test_map, confirm the name and hit Save

    Map name should be at least 2 characters long, use a-z0-9 and underscores

  5. Go back to the main menu and return to the list of levels, your new empty map should appear on the list

Now you can select the map from the list of levels and open the blue pencil map editor. Editing the map should be familiar for you, but this new editor has a couple of differences compared to the regular editor of custom maps:

You can create any kind of map and play on it. Keep reading to know how to make things more fun.

Adding scripts to your map

Follow these steps to add scripts to your map:

  1. Open map editor of your new map
  2. Add some roads, at least one Portal and Base tile to make your map playable. Remember that you can create any tile you need with the developer mode
  3. Open item creation menu (see dev mode usage page if you don't know how to do that), select TILE item type. In the Tile type dropdown menu, select SCRIPT and click on the Give button - new empty Script tile will be added to your inventory

    ID field is an unique identifier of your tile. If you want to create multiple different Script tiles, make sure their IDs are different. You can click on the restart reload button to generate new unique ID

  4. Find the newly created Script tile in the star Special tab of map editor and place it on any free space of your map
  5. Select the Script tile on your map - you will find the large Source code field in its menu. You can write Lua code there2 or copy it from your favorite text editor - use regular Ctrl+C / Ctrl+V keystroke or Copy / Paste buttons below the source code field. Paste this code into the Source code field:
    log("Hello world!)
  6. Hit Save button to save your code into the tile. Now each time you start playing on this map, your code will be executed
  7. Start your map by pressing the Play button / returning to the list of levels and playing it in a regular way. You should find the Script: Hello world! message in the terminal, which means your code has been successfully executed

You can place any amount of different Script tiles on your map - they will be executed in the same Lua environment in left-right, bottom-top order.

Further reading


  1. Pro tip: you are in a developer mode now, feel free to create any kind of tiles you need - they will be added to your inventory and will appear in the map editor 

  2. Pro tip: there's a small triangle button on the left side of the Source code field, use it to enlarge the field horizontally