Team036-Roulette icon

Roulette

A UI Lib. Roulette Like Apex.

By Team036
Last updated 2 weeks ago
Total downloads 127
Total rating 2 
Categories
Dependency string Team036-Roulette-1.1.0
Dependants 2 other packages depend on this package

README

///
///  This mod is still in development. You may encounter issues such as CTD/CTM. Use at your own risk.
///
///  If you have any problems (bugs, suggestions, screenshots, etc.), contact me via Discord @raintrap341. Or maybe a QQ group? Not sure…
///
///  If you like this mod, please give it a thumbs-up.
///
///  Special thanks to @justanormaluser and @uniboi

This mod is a UI library that provides modders with a roulette-style menu.

Please follow the guide below to use it.

Roulette.gif

How to use

1. Prepare a UI script

You need to have a script running on the UI VM.

2. (Optional) Set up title/desc/extra hud

The title appears above the roulette, and the description appears below.

void function SetupRoulette(string configName, string title = "", string description = "", var extraHud = null) {
    file.title = title
    file.description = description
    file.extraHud = extraHud
}

3. Register Shards

By default, the circle is divided into 8 shards. You can register only the shards you want. Note: Shard index 0 is at 225°, which is the first segment to the lower left of the x-axis.

Function: RegisterShard

Purpose: Registers and configures a single shard (sector) in the roulette UI, including its asset, name, display options, callback, color, position bias, and description.

Parameters:

  • string configName The name of your roulette config.
  • int index The index of the shard (0–7).
  • asset shardAsset The asset to display as the shard's image.
  • string shardName The display name for the shard.
  • bool shouldShowImage (default: false) Whether to show the image for this shard.
  • bool shouldShowText (default: true) Whether to show the text label for this shard.
  • bool isAssetRui (default: false) Whether the image is a RUI asset.
  • void functionref(int index, entity localPlayer, var roulette) confirmCallback (default: null) The callback function to execute when this shard is confirmed/selected.
  • vector textColorOverride (default: <255, 255, 255>) The color override for the text label.
  • vector shardNameBias (default: <0, 0, 0>) The positional bias for the text label.
  • string shardDescription (default: "") The description text for this shard.

Behavior:

  • Stores all provided parameters in the file struct for later use.
  • Finds the corresponding UI elements for the shard and its text label.
  • Applies the text color and position bias to the text label.
  • Registers the confirmation callback if provided and not already registered.
  • Outputs a debug message indicating the shard has been registered.
void function RegisterShard(string configName, int index, asset shardAsset, string shardName, bool shouldShowImage = false, bool shouldShowText = true, bool isAssetRui = false, void functionref(int index, entity localPlayer, var roulette) confirmCallback = null, vector textColorOverride = DEFAULT_SHARD_TEXT_COLOR, vector shardNameBias = <0, 0, 0>, string shardDescription = "")

// or below 
void function RegisterShardOnlyCallback(string configName, int index, void functionref(int index, entity localPlayer, var roulette) confirmCallback)

4. Open It

OpenRouletteMenu(yourConfigName)

yourConfigName is a string which you need to set in your mod.

5. (Optional) With Concommand and key binding

Check the NS mod wiki and QuickTyping | Thunderstore - The Northstar Mod Database .

Example

From my mod QuickTyping | Thunderstore - The Northstar Mod Database :

const string ROULETTE_NAME = "QuickTyping"

// OpenRouletteMenu(string) is a UI func.
void function QuickTyping_OpenRoulette()
{
	OpenRouletteMenu(ROULETTE_NAME)
}

// You should only register shards once if your shards are static. If the label/color/images changes dynamically, you should register everytime before the open.
void function QuickTyping_ModSettings_Init()
{
		for (int i = 0; i < SHARD_MAX; i++) {
			string content = GetTexts()[i]
		RegisterShard(ROULETTE_NAME,i, $"", content, false, true, false, void function (int index, entity localPlayer, var roulette) : (content) {
			// Communicate with Client VM.
			RunClientScript("CodeCallbackQuickTypingSay", content)
		}, <0, 0, 0>)
	}

	SetupRoulette( ROULETTE_NAME, Localize("#QUICKTYPING_TITLE"))

}

Warning

This mod maintains only a single instance of the Roulette menu at any given time. Make sure to avoid opening the Roulette menu simultaneously to prevent interference between mods. Now Provided with configs feature, the stack will holds every query in theory.

Hey, Can I register these shards on server?

This mod does not offer remote register from server, but you can implement it by yourself. Anyway, I guess its impossible to pass functionref to client, so you have to do some work on client still.

You should have both Server/Client scripts. And check this:

Communicating between CLIENT, UI and SERVER scripts - Northstar Documentation

Changelog

1.0.0 Upload

1.1.0

  • Feature. Config which cache data.