Elin
Not enough ratings
TSBase — Modding framework
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
517.959 KB
Nov 8, 2024 @ 5:39am
Nov 15, 2024 @ 1:06pm
5 Change Notes ( view )

Subscribe to download
TSBase — Modding framework

Description
Library mod!

Features a UI framework and Lua API.

///////////////////////////////////////////////////////////////////////////////////////////////////////
Users may skip the below mod library info:


SImple UI reference
// Custom UI Layer public class ExampleUI : CustomUI<ExampleUI.Args> { public struct Args : ICustomUIArgs { } public override CustomUI<Args> Setup(Args args) { base.Setup(args); var window = this.AddWindow(450, 300, "Window header"); var layout = window.MakeLayout(); // elements added to layout are automatically positioned layout.AddText("Hello"); layout.AddText("World!"); // add a sub-layout which add things horizontally // the size parameter sets the sub-layout's height var sublayout = layout.Horizontal(100); sublayout.AddText("Horizontally"); sublayout.AddText("alinged"); // add a scroll layout to the layout // when the size parameter is omitted, the size becomes the layout's remaining size var scroll = layout.AddScroll(); scroll.AddButton("Buttons!", delegate(UIButton btn) { btn.mainText.SetText("Pressed!"); }); scroll.AddToggle("Toggles!", toggled => Debug.Log($"Toggled: {toggled}")); List<string> slideritems = ["item 1", "item 2", "item 3"]; scroll.AddSliderLabel( "Sliders!", // label 0, // selected index slideritems,// items delegate(int index, string item) { // action on change }, delegate(string item) { // displays the returned value when item is selected return item; } ); return this; } } // adding the layer to screen: TSUI.LoadCustomUI<ExampleUI, ExampleUI.Args>(new ExampleUI.Args() { // set args here });

Your mods can also have Lua code, which will be run on initilazation!
Just add a 'scripts' subdirectory to your mod's root, and add 'init.lua'. Your mod's PackageInfo will be passed as a global with the key 'Package'.

example init.lua:
print("Hello World from Lua! Mod path: "..Package.dirInfo.FullName) -- you can register any C# assembly from lua! -- assembly name simplified name (if needed) (defaults to assembly name if blank) -- | | RegisterAssembly("UnityEngine.CoreModule", "Unity") local vector2type = _types.Unity.Vector2 -- a handle on the type local vector2static = _static.Unity.Vector2 -- a static reference to the type -- able to retrieve static variables from the static reference (and only the static reference) local zero = vector2static.zeroVector local vector2instance = _new.Unity.Vector2{ 20, 10 } -- invoke a constructor and create an instance print("Vector2 instantiated through Lua: "..tostring(vector2instance)) -- if the assembly to load contains a period, the name should be simplified, explanation: RegisterAssembly("UnityEngine.CoreModule") -- _types.UnityEngine.CoreModule.Vector2 -- doesn't work, the period in the name splits the table, causing a nil index vector2type = _types["UnityEngine.CoreModule"].Vector2 -- would be how it works (a little awkward) RegisterAssembly("Elin") -- Elin is loaded by TSBase, so just for reference! local eclass = _static.Elin.EClass eclass.pc.bio.nameDad = "A Proud Father" -- can access any variables as if they were in a table!

Todo:
- Framework for adding rows to sources
- Mod configuration UI