Lobster - An API wrapper to simplify writing OBS scripts

OBS Lua Lobster - An API wrapper to simplify writing OBS scripts 2024-01-25

The OBS API is amazing in the fact that it allows you to do pretty much everything related to the software. The downside to that is that you have so many tools that even simple tasks require multiple API calls, which can be a pain to manage. It's why I made Lobster. The goal is to simplify the API, without taking away any of the functionality.

This wrapper is not made to replace all scripting. It's made to offer a solution for those who are overwhelmed by the original API or want to make a larger project.

Here is an example. More examples can be found on the Github.
Code:
require "lobster.lobs"

function lobs.load()
    lobs.hotkey.register("turn_left", "Turn left")
    lobs.hotkey.register("turn_right", "Turn right")
    lobs.hotkey.register("move_forwards", "Move forwards")
end

local lobster

function lobs.ready(scene)
    lobster = scene:getItemByName("lobster")
    if lobster then
        lobster:setAlignment("center")
    end
end

function lobs.update(dt)
    if not lobster or not lobster:exists() then
        return
    end

    lobster:useItem(function()
        local position = lobster:getPosition()
        local rotation = lobster:getRotation()

        if lobs.hotkey.isDown("turn_left") then
            rotation = rotation - 5 * dt
        end

        if lobs.hotkey.isDown("turn_right") then
            rotation = rotation + 5 * dt
        end

        if lobs.hotkey.isDown("move_forwards") then
            position.x = position.x + math.cos(rotation) * 400 * dt
            position.y = position.y + math.sin(rotation) * 400 * dt
        end

        lobster:setPosition(position)
        lobster:setRotation(rotation)
    end)
end

lobster.gif
Author
Sheepolution
Downloads
480
Views
1,312
First release
Last update
Rating
0.00 star(s) 0 ratings
Top