Skills & States API

An API for creating skills and states.

API / Library

Download (69 KB)
For Luanti 5.3 and above

How do I install this?

Skills & States 🔗

A library to create and manage skills and states. A skill can be an action like a super-high jump, a damaging aura or a passive one like a stat boost. A state is the same thing but temporary and with no need to unlock it before applying it.

Doesn't provide any base skill.

Here's the documentation.

Here some examples of how to register a skill:

skills.register_skill("example_mod:counter", {
    name = "Counter",
    description = "Counts. You can use it every 2s.",
    sounds = {
        cast = {name = "ding", pitch = 2}
    },
    cooldown = 2,
    data = {
        counter = 0
    },
    cast = function(self)
        self.data.counter = self.data.counter + 1
        print(self.pl_name .. " is counting: " .. self.data.counter)
    end
})
skills.register_skill("example_mod:heal_over_time", {
    name = "Heal Over Time",
    description = "Restores a heart every 3 seconds for 30 seconds.",
    loop_params = {
        cast_rate = 3,
        duration = 30
    },
    sounds = {
        cast = {name = "heart_added"},
        bgm = {name = "angelic_music"}
    },
    cast = function(self)
        local player = self.player
        player:set_hp(player:get_hp() + 2)
    end
})
skills.register_skill("example_mod:boost_physics", {
    name = "Boost Physics",
    description = "Multiplies the speed and the gravity x1.5 for 3 seconds.",
    loop_params = {
        duration = 3
    },
    sounds = {
        start = {name = "speed_up"},
        stop = {name = "speed_down"}
    },
    physics = {
        operation = "multiply",
        speed = 1.5,
        gravity = 1.5
    }
})
skills.register_skill("example_mod:set_speed", {
    name = "Set Speed",
    description = "Sets speed to 3.",
    passive = true,
    data = {
        original_speed = {}
    },
    on_start = function(self)
        local player = self.player
        self.data.original_speed = player:get_physics_override().speed

        player:set_physics_override({speed = 3})
    end,
    on_stop = function(self)
        self.player:set_physics_override({speed = self.data.original_speed})
    end
})

Reviews

Review

Do you recommend this mod?

  • English

    Long overdue

    I recall how much I wanted a skills library when I was working on a mod of mine last year. I also wondered back then how it was possible that no one had ever thought about creating something useful like a mod that allowed you to easily introduce skills in your game. Because it's something that basically every genre might need. RPG, FPS, MOBA, you name it. I also recall how I ended up throwing in the towel because I couldn't focus on yet another mod to maintain. So I renounced.

    ...until now! Thanks for what you're doing :)

    0 comments

Used By