Modding: Utilities

A collection of scripts created by other modders, which you can copy directly to your own mod, for example into your own utilities file:

Obtain the id of the player entity
This function obtains you the id of the player entity. Using it, you can extract data from components and other behaviors of the player.

Easier entity debugging
Use simply with

Add custom names in translations
This piece of code is placed in the mod's init and is used to add custom translations:

So if we were to name the entity "$item_custom" it's name in game would show up as "Custom Name"

Add a new genome (This currently Doesn't work)
The function  let's you append a new genome to the   file. Use it in your.

(THIS CURRENTLY DOESN'T WORK: Because genomes are currently loaded before mods even load)

Add a new tag to an existing entity
This function adds a tag to an existing entity without you having to overwrite existing entities:

Rotate entity depending on topology of terrain
This script makes the entity rotate depending on terrain topology:

This script is then attached to the xml entity with a lua component, example:

Shoot Projectile from Entity Towards Player
This script, made by Evaisa, lets you shoot a projectile from an entity towards an entity.

To use this function, just do

Then attach a lua component to the entity xml which utilizes this script and runs every x frames, example:

Attach entities to verlet chains
Add this to the verlet chain entity like this:

This will add one entity to each verlet chain segment! Keep in mind that it is heavy on performance.

Rotate physics object towards player
This script is then attached to the xml entity with a lua component, example:

For this to work it is important to remove any torque from the physics AI of the entity bearing the lua component by setting torque to 0 in the physics AI component.

Check if inside wall script
This function checks if you're spawning things in walls.

Player movement checking
Use these functions to obtain flags regarding the player's movement.

Obtaining and setting gold amount
These functions can be used to manipulate the amount of gold owned by the player.

Internal variable manipulation
The following functions can be used to obtain or update internal variables present o variable storage component of an entity. Both get and set functions assume the variable name you are trying to get or set already exists on the entity you are providing.

Player Health manipulation
The following functions can be used to manipulate and obtain hp from the player.

Get and set basic damage multipliers
The functions below are useful to obtain and modify damage multipliers of any creature with a valid id.

Verlet Carrion Legs Script, Made By Horscht
This script gives your entity verlet tentacles which attach to walls like in the game Carrion.

You just put this script in a lua component on the entity you want to have the tentacles like this: