API Documentation - larswijn/CardSleeves GitHub Wiki

The CardSleeves API

Using the CardSleeve API requires some knowledge of how the Steamodded API works. It might be helpful to have the Steamodded wiki open as reference.

The Sleeve class

Can be accessed as CardSleeves.Sleeve which is globally defined if CardSleeves was loaded.

The Sleeve class is an extension/subclass of steamodded's Center class. This means that most methods and properties defined on the Center class should also be available for sleeves. Some added custom methods include:

  • Sleeve:get_obj(key) -> CardSleeves.Sleeve
    • Get a Sleeve instance by key. Returns nil if not found.
  • Sleeve:apply()
    • Apply modifiers at the start of a run. Can be re-implemented. Similar to SMODS.Back:apply.
  • Sleeve:trigger_effect(args)
    • Any effects that happen during a run, like Plasma Sleeve's effect. Can be re-implemented. Similar to SMODS.Back:trigger_effect.
  • Sleeve:get_name() -> string
    • Get name of this sleeve instance. Respects locked sleeves. Use G.GAME.selected_sleeve if you need to find the key of the currently selected Sleeve.
  • Sleeve.get_current_deck_key() -> string
    • Get key of current deck (works in both the select screen and during a run).

A Sleeve instance

Note: the key will be changed on creation to "sleeve_" + your mod prefix + "_" + original key

Parameters

Required and optional parameters when creating a Sleeve.

  • Required parameters:
    • key,
    • atlas,
    • pos,
    • loc_txt or a localization entry
  • Optional parameters = defaults:
    • config = {},
    • unlocked = true,
    • unlock_condition

Methods

Optional methods that can be (re-)implemented if a more custom effect is desired.

  • Methods that are not implemented by default
    • loc_vars(self)
  • Methods that have a simple base implementation
    • apply(self)
    • trigger_effect(self, args)
    • locked_loc_vars(info_queue, card) and check_for_unlock(args)

Localization

This is required! Either:

  • A) Define a loc_txt formatted like normal
  • B) Create a localization file under localization/default.lua or localization/en-us.lua

See Examples page for some concrete localization examples.

UI

All UI elements should be taken care of by CardSleeves itself. Galdur is supported.

If there are any UI issues, please let me know so I can fix it.

Help

If you are struggling to create a new Sleeve, you can ask for help in the CardSleeves Thread on the Balatro Discord.