About This File
This mod shows how to add a custom tile (ground) type to the game, to the map and minimap.
The actual work is encapsulated in the file tile_adder.lua, which may just be plopped into your mod and modimport'ed. It exports the function AddTile(), whose usage is exemplified in modworldgenmain.lua (note, however, that the tile texture assets must be declared in modmain.lua).
As an example, a new tile type GROUND.MODTEST is added. The mod will also spawn in the player's inventory an infinite turf item which places the new tile type (to make testing easier, it does not require digging up the original turf with a pitchfork).
WARNING!
The numerical id passed as the second argument to AddTile (which becomes the value of GROUND.YOURNEWTILETYPE) must be unique, not conflicting with with game's own values (specified in vanilla's constants.lua) as well as with other mods. It must also be less than 128 (the value of GROUND.UNDERGROUND), otherwise the game assumes the new tile represents a wall type. The AddTile function checks the given numerical id for validity, raising an error if the check fails. With regard to intercompatibility between mods adding tiles, it is important to choose numerical ids not conflicting with the choice of other mods. Ideally the ids would be generated automatically and stored/restored as map savedata, but since mods run before any savedata is loaded this would add a number of pitfalls for the modder to be aware of, and generally increase the complexity of the code required for adding a new tile, so I kept the manual specification. The sample tile is added with an id of 80, while Up and Away uses consecutive ids starting from 64.
What's New in Version 1.2.1 See changelog
Released
- Accounted for mudsound (the sound played when walking on wet ground in RoG), as pointed out by @DeathDisciple.
Recommended Comments
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now