-
Notifications
You must be signed in to change notification settings - Fork 0
Recipes
89pleasure edited this page Jul 16, 2026
·
2 revisions
These examples combine the focused API methods into common mod workflows.
local content = pleasureLib:read_text_file(config_path)
local ini = pleasureLib:parse_ini(content)
local enabled = pleasureLib:parse_bool(ini.ENABLED, true)
local item_names = pleasureLib:split_list(ini.ITEMS or "")local ok = pleasureLib:update_ini_value(
config_path,
"ShowExtraInfo",
tostring(config.ShowExtraInfo == true)
)
if not ok then
pleasureLib:log("Could not update config")
endlocal object = pleasureLib:find_object("/Game/Some/Object.Path")
if pleasureLib:is_valid(object) then
pleasureLib:log(pleasureLib:full_name(object))
else
pleasureLib:debug_log("object is not loaded")
endlocal scheduled = pleasureLib:delay_game_thread(100, function()
local player = pleasureLib:find_object("/Game/Some/Player.Path")
if pleasureLib:is_valid(player) then
-- Interact with the object here.
end
end)
if not scheduled then
pleasureLib:log("Could not schedule callback")
endlocal function noop() end
pleasureLib:register_hook(
"/Script/SomeClass:SomeNativeFunction",
noop,
function(context)
pleasureLib:debug_log("native function completed")
end
)For native /Script/ functions, passing the callback as the third argument is
what makes it a true post-handler.
Start capture immediately before the player action or code path that creates the object:
local capture = pleasureLib:capture_new_objects({
filter = function(object)
return string.find(
pleasureLib:full_name(object),
"W_Inventory",
1,
true
) ~= nil
end,
sample_delays_ms = { 50, 150, 300, 600 },
}, function(results)
pleasureLib:log("captured " .. tostring(#results) .. " object(s)")
for _, entry in ipairs(results) do
pleasureLib:log(entry.key)
end
end)Keep the returned handle if another event should cancel the observation:
if capture then capture.cancel() endSee the complete example and lifecycle notes on Native Game Settings.