Skip to content

Modding: POV

ErinaSugino edited this page Jul 8, 2023 · 1 revision

Sexbound Reborn reworked the POV system - the little "Point of View" animations you may or may not have seen playing in the bottom right of the Sex UI; at least if you have been playing as a human before. It has been fully modularized so that anyone can create a new POV module to add animations in that big space in the bottom right. This way, multiple POV modules - like POV Redux and TemTem's Terato Cutscenes can safely co-exist at the same time without having to worry about breaking anything.

The Module Class

In order to add a new module, to have to create a new "class". Inside the folder /interface/sexbound/sexui/submodule/pov/modules you create a new lua script file, named like your module. Make sure you don't accidentally override an already existing module with the same name. Inside that file, you create a basic class structure. You can orient yourself either on the main.lua default module, or the following template:

SexUI.POV.Modules.<ModuleName> = {}
SexUI.POV.Modules.<ModuleName>_mt = {
    __index = SexUI.POV.Modules.<ModuleName>
}

function SexUI.POV.Modules.<ModuleName>.new(parent, config)
    local self = setmetatable({
        _parent = parent
    }, SexUI.POV.Module.<ModuleName>_mt)
    
    return self
end

Replace <ModuleName> with the name of your module - the same as the file name, but with a capital first letter. So for example, if you name your module "xray", then the filename would be "xray.lua" but the class would be named "SexUI.POV.Module.Xray". That's important.

The Main API

After creating the module class, now you just need to supply the necessary methods the UI expects for the module to work. These are the following:

isAvilable() Returns: Boolean
This method is called potentially every tick to determine if this module has anything to render in the first place. The POV manager goes through every module in the order they were added each tick to check which module needs to be rendered. If a module is disabled by the user or "isAvailable" returns false this module is skipped and the next one checked. For example, if the modules "main", "cutscenes" and "xray" are defined in this order, every tick the system checks "main" first. If it's enabled and "isAvailable" returns true, this module is rendered. If not, it checks the same for "cutscenes", then potentially "xray".

render(canvas) Returns: Nothing
This method, as the name might suggests, is called when a given module passed all checks and is going to be rendered. It receives a reference to the render canvas as parameter, on which you can then use all vanilla Starbound functions for canvas rendering do draw shapes and images on. You do not need to clear the canvas' content before drawing your own, it will be cleared automatically!

update(dt) Returns: Nothing
This method is called every single tick and receives the current delta time - the time in seconds since the last update - as parameter. It's really straightforward.

triggerUpdate(actors) Returns: Nothing
This method is called every time the UI syncs with the sexnode and receives new data. It gets the list of all current actors in the sexnode alongside their data, in sorted order (means actors[1] is the actor currently in role 1) as a parameter. Use this to update your module's data and setting if it relies on actor data.

Keep in mind that all of these methods must be present - even if they do nothing. As a safety measure, if any of these methods errors the module will be deactivated for the rest of the UI's lifetime so make sure to catch any non-critical errors yourself. And yes, the method not existing will cause an error and deactivate your module.

The rest is up to you - with the data given you can do whatever you want inside of your module class.

Adding Your Module To The UI

Finally, after all is done and setup, it's time to tell the UI there is a new module. Obviously I can't scan the entire folder for new files; that would require turning on "unsafeMods" and if anyone ever asks you, as a player, to do that - block them immediately. It's 99.99% guaranteed an attempt to hack your PC. So, you yourself have to make sure you tell Sexbound your module exists. Do so by patching into /interface/sexbound/sexui.config You want to add your entry to the path /config/pov/modules/- and add an object that contains two parameters: {"class": "<ModuleName>", "icon": "<IconPath>}.
"ModuleName" is, as mentioned above, the name of your module with the capital first letter. "IconPath" is the asset path to the icon displayed on the button shown to players to toggle the module on or off. The icon has to be a 11x11 transparent PNG, which will be pasted onto a round 11x11 button. The space is tiny, yes, but so is most stuff in Starbound.

You don't need anything else, when the module is patched into the config and not disabled due to an error in one of the critical methods, the button will automatically be created with the icon and added to the list besides the POV window. Now everyone can enjoy your creation!

   Home

Usage   Installation
  Configuration

   FAQ

Development   Original vs. Reborn
  Roadmap
Guides   Advanced Troubleshooting
  ——————————
  The UI explained
  Mechanics explained
  ——————————
  Modding: Basics
  Modding: Translations
  Modding: POV Module
  Modding: Sextalk
  Modding: Races
Clone this wiki locally