Skip to content

Getting Started

89pleasure edited this page Jul 18, 2026 · 3 revisions

Getting Started

Use a local PleasureLib runtime for each consuming mod. The runtime keeps mod-specific state such as the log prefix, debug flag, and object cache scoped to that mod.

1. Add the loader

Place pleasure_lib_loader.lua next to the consuming mod's main.lua. Copy the implementation from Recommended Loader.

Example layout:

Mods/MyMod/
  enabled.txt
  Scripts/
    main.lua
    pleasure_lib_loader.lua

2. Create a runtime

At the top of the consuming mod's main.lua:

local pleasureLib = require("pleasure_lib_loader").new("MyMod")
if type(pleasureLib) ~= "table" then return end

The string passed to new becomes the log prefix:

[MyMod] loaded

Enable debug logging when needed:

local pleasureLib = require("pleasure_lib_loader").new("MyMod", {
    debug = true,
})

3. Call helpers through the runtime

pleasureLib:log("loaded")

local content = pleasureLib:read_text_file(config_path)
local config = pleasureLib:parse_ini(content)

local npc = pleasureLib:find_object("/Game/Some/Object.Path")
if pleasureLib:is_valid(npc) then
    pleasureLib:debug_log(pleasureLib:full_name(npc))
end

Register a hook without exposing the mod to an unprotected UE4SS call:

pleasureLib:register_hook(
    "/Script/Engine.PlayerController:ClientRestart",
    function()
        pleasureLib:log("ClientRestart fired")
    end
)

4. Choose the relevant API page

Instance API versus static exports

For normal mod code, prefer the local runtime shown above. PleasureLib also exposes several stateless helpers directly on _G.PleasureLib for compatibility and simple utility use. They are listed under Static exports.

Reload behavior

PleasureLib is idempotent. Loading the same version again returns the existing _G.PleasureLib table. Each call to PleasureLib.new(...) still creates a fresh runtime with its own log prefix, debug flag, and object cache.

Clone this wiki locally