1 Screenshot

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.



User Feedback

Recommended Comments

interesting... but how do you make it so that when you dig it up, it actually digs it up instead of deleting it from existence...

Share this comment


Link to comment
Share on other sites

interesting... but how do you make it so that when you dig it up, it actually digs it up instead of deleting it from existence...

You need to create a turf prefab for it.

Share this comment


Link to comment
Share on other sites

might want to put

mudsound = "dontstarve/movement/run_mud"

into tile defaults, since ROG tries to get it when world gets wet. Doesn't influence non-rog worlds in any way as far as I can tell.

  • Like 1

Share this comment


Link to comment
Share on other sites

might want to put

mudsound = "dontstarve/movement/run_mud"
into tile defaults, since ROG tries to get it when world gets wet. Doesn't influence non-rog worlds in any way as far as I can tell.

Thanks for picking up on that! And you're right about it not influencing non-RoG worlds, since this value is only ever accessed in RoG's worldtiledefs.lua, being simply ignored in vanilla.

I hadn't revised the core functionality of this code since last August, so it certainly didn't take RoG explicitly into account :razz: (and for U&A it didn't look like anything was missing, since the cloudrealm doesn't get wet).

Your help, as always, is greatly appreciated. Glad to have you around.

Share this comment


Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now