Skip to content

Class "Global Functions"⚓︎

Constructors⚓︎

Color ()⚓︎

Color Color ( float R, float G, float B, float A, int RO, int GO, int BO )⚓︎

Constructor for the "Color" class.

When using the Font class, use KColor() instead.

Colors are made of three separate components, tint, colorize and offset. Tint acts like a color multiplicator. Offset is a color which is added after the tint is applied. Colorize is complicated. See the SetColorize() function for a detailed description.

R, G, B and A accept numbers between 0 and 1.

RO, GO and BO accept numbers between -255 and 255.


Entity·Ptr ()⚓︎

EntityPtr EntityPtr ( Entity )⚓︎


Entity·Ref ()⚓︎

EntityRef EntityRef ( Entity )⚓︎


Font ()⚓︎

Font Font ( )⚓︎

Constructor for the "Font" class.

Example Code

Example usage.

1
2
3
local f = Font() -- init font object
f:Load("font/terminus.fnt") -- load a font into the font object
f:DrawString("Hello World!",60,50,KColor(1,1,1,1),0,true) -- render string with loaded font on position 60x50y


Game ()⚓︎

Game Game ( )⚓︎

Returns a Game object.

Example Code

Example usage:

1
2
Game():IsPaused()
--returns true if the game is paused


KColor ()⚓︎

KColor KColor ( float red, float green, float blue, float alpha )⚓︎

Constructor for the "KColor" class. Notes: "KColor" is only used in the Font class. For most other situations you will need to use the Color() constructor.


Music·Manager ()⚓︎

MusicManager MusicManager ( )⚓︎

Returns a MusicManager object.

Example Code

Example usage:

1
MusicManager():Disable()


Projectile·Params ()⚓︎

ProjectileParams ProjectileParams ( )⚓︎


Register·Mod ()⚓︎

Mod Reference RegisterMod ( string modName, int apiVersion )⚓︎

Method to define a mod in the game. This needs to be defined to handle callbacks and save data in your mod.

Returns a table which acts as the Mod Reference.

Example Code
1
local yourMod = RegisterMod("someMod", 1)

RNG ()⚓︎

RNG RNG ( )⚓︎


Sprite ()⚓︎

Sprite Sprite ( )⚓︎


SFXManager ()⚓︎

SFXManager SFXManager ( )⚓︎

Returns a SFXManager object.

Example Code

Example usage:

1
SFXManager():Stop(SoundEffect.SOUND_1UP)


Vector ()⚓︎

Vector Vector ( float , float )⚓︎


Functions⚓︎

Random ()⚓︎

int Random ( )⚓︎

Returns a random integer. (0 to 2^32)


Random·Vector ()⚓︎

Vector RandomVector ( )⚓︎

Returns a random vector with length 1. Multiply this vector by a number for larger random vectors.


Get·Ptr·Hash ()⚓︎

int GetPtrHash ( Objectobject )⚓︎

Returns a hash-value of the pointer given as an input value. Valid inputs are any Isaac object, including Entity, Room, RNG, Sprite, Game etc.

It can be used to easily compare two entities, making equality checks very easy.

Example:

If you spawn a certain entity, save it in a variable and then compare it to the entity parameter in MC_ENTITY_TAKE_DMG, this comparison will never be true even if both variables refer to the exact same entity in the game. GetPtrHash() turns pointer into a fixed number, which makes comparisons easier.

Example Code

Example on check if two entities saved in different variables are the same.

1
2
3
4
5
6
7
8
-- don't do it like this
if entity1 == entity2 then
    -- this will always be false, because two different references on a pointer are not equal
end
-- use GetPtrHash() to compare them
if GetPtrHash(entity1) == GetPtrHash(entity2) then
    -- this will be true, when the pointer of both variables point to the same object.
end



Last update: June 9, 2021