Hi there! You are currently browsing as a guest. Why not create an account? Then you get less ads, can thank creators, post feedback, keep a list of your favourites, and more!
Space Pony
Original Poster
#1 Old 16th Oct 2021 at 8:53 PM Last edited by Battery : 30th Sep 2022 at 8:25 PM.
Default C# Script Utility Overview
Mod Page:


What is the C# Script Utility ?



Please do not answer on this thread, since it is work in Progress (and unsorted at the moment)
If you Have questions or you want to discuss something about the mod:






Table of Content

Other Tutorials and References


Installation


Sims 3 Script Extender Overview (S3SE)


Auto Menu


Artificial Neural Network Application (ANNA)


Saving/loading Settings


Adding Interactions


SimTools


RemoteUtil


ListQueries
Screenshots
Attached files:
File Type: 7z  ScriptUtility serializing Objects Example.7z (16.0 KB, 19 downloads)
File Type: 7z  ScriptUtility deserializing Objects Example.7z (17.3 KB, 9 downloads)
Advertisement
Space Pony
Original Poster
#2 Old 16th Oct 2021 at 8:57 PM Last edited by Battery : 24th Oct 2021 at 5:38 PM.
Attachments:
Screenshots
Attached files:
File Type: 7z  ScriptUtility using the Auto Menu.7z (11.5 KB, 22 downloads)
File Type: 7z  ScriptUtility Serialization Menu Example.7z (6.8 KB, 12 downloads)
Space Pony
Original Poster
#3 Old 16th Oct 2021 at 9:23 PM Last edited by Battery : 22nd Oct 2021 at 8:53 PM.
Installation:

Step 1


Step 2


Step 3


Step 4
Space Pony
Original Poster
#4 Old 16th Oct 2021 at 10:40 PM Last edited by Battery : 24th Oct 2021 at 5:39 PM.
Auto Menu

Example Solution and package File

Usage: Lets Players set values which were exposed by you (similar to NRaas retuner) Does NOT require the C# Utility to be referenced (so it is optional)




Change the Assembly Name Sharp Develop:

Change the Assembly Name Visual Studio:


Example:


Note: If you expose a static field that holds an class instance you can change all the cointained settings
Space Pony
Original Poster
#5 Old 16th Oct 2021 at 10:48 PM Last edited by Battery : 27th Dec 2021 at 4:55 PM.
Anna

Battery.AI.Anna

Anna LoadFromXML(string InstanceName)



void ExportToXML(string Name)


double[] Compute(params double[] input)



To ComputeClassification<To>(IList<To> PossibleOutputs, params double[] inputs)

Space Pony
Original Poster
#6 Old 16th Oct 2021 at 10:50 PM Last edited by Battery : 24th Oct 2021 at 11:43 AM.
Export_Import
(Creating a simple menu that lets the player Load / Save your custom Objects)

Example Solution and package File

Battery.Export_Import

0 Create a method to handle the imported string

1 Create a method to export our object

2. Creating the Menu


3. Adding the Menu options


4. Opening our Menu
Space Pony
Original Poster
#7 Old 17th Oct 2021 at 5:20 PM Last edited by Battery : 23rd Oct 2021 at 9:40 PM.
Export_Import
(Serializing Objects)

Battery.Export_Import


string ToExportString<T>(this T objecttoexport)


interface ICustomSerializer
Space Pony
Original Poster
#8 Old 22nd Oct 2021 at 8:44 PM Last edited by Battery : 23rd Oct 2021 at 9:40 PM.
(Example: Serializing Objects)

Example Solution and package File

Simple Example



Simple Example(only serialize some fields)



Advanced Example(using custom Serializing instructions)
Space Pony
Original Poster
#9 Old 22nd Oct 2021 at 8:50 PM Last edited by Battery : 23rd Oct 2021 at 9:41 PM.
Export_Import
(Deserializing Saved Objects)

Battery.Export_Import


T Deserialize<T>(string ExportString)
Space Pony
Original Poster
#10 Old 23rd Oct 2021 at 9:41 PM
(Example: Deserializing Saved Objects)

Example Solution and package File

Simple Example



Advanced Example
Space Pony
Original Poster
#11 Old 1st Nov 2021 at 10:57 AM Last edited by Battery : 1st Nov 2021 at 11:14 AM.
InteractionsUtility
(Adding Interactions)

Battery.Interactions.InteractionsUtility


void AddInteraction(GameObject o, InteractionDefinition Singleton)


void AddinteractionToObjectsOfType<type>(InteractionDefinition Singleton)


void AddTerrainnteraction(InteractionDefinition Singleton)
Space Pony
Original Poster
#12 Old 20th Nov 2021 at 7:08 PM Last edited by Battery : 20th Nov 2021 at 9:23 PM.
SimTools
(Converting the Age of a sim to real world years)

Battery.SimTools

float GetAgeInRealYears(Sim s,float MaxBabyAge=1f, float MaxToddlerAge=4f, float MaxChildAge=13f, float MaxTeenAge=19f, float MaxYoungAdultAge=35f, float MaxAdultAge=60f, float NormalLifeTime=86f)


float GetPetAgeInRealYears(Sim s, float MaxChildCatAge = 1f, float MaxAdultCatAge = 7f, float MaxNormalCatLifeTime = 12f, float MaxChildDogAge = 1f, float MaxAdultDogAge = 9f, float MaxNormalDogLifeTime = 12f, float MaxChildHorseAge = 3f, float MaxAdultHorseAge = 15f, float MaxNormalHorseLifeTime = 20f)




(Modifying a sims facial/body sliders)

Battery.SimTools.Slider

float Get_Value(Sim sim, Sliders slider)


bool mod_Value(Sim sim, float ModifyBy, Sliders slider)


bool Set_Value(Sim sim, Sliders slider, float value)
Space Pony
Original Poster
#13 Old 27th Dec 2021 at 3:25 PM Last edited by Battery : 6th Jan 2022 at 7:41 PM.
RemoteUtil

Battery.RemoteUtil

List<string> GetLoadedScriptmods()


bool IsScriptModInstalled(string ModName)


object CallStaticMethod(string typeName, string methodName, Type[] ArgumentTypes, params object[] methodArgs)


object CallInstanceMethod(object Instance, string methodName, Type[] ArgumentTypes, params object[] methodArgs)


TDelegate GetStaticMethodDelegate<TDelegate>(Type t, string MethodName)


object CreateObject(string typeName, params object[] ctorArgs)



System.Collections.IList CreateListfromType(Type t)



System.Collections.IDictionary CreateDictionaryfromType(Type KeyType, Type ValueType)


InteractionDefinition GetInteractionDefinition(string FullNamespace, string InteractionClassName, string Assemblyname, string InteractionSingletonName)


InteractionDefinition GetNestedInteractionDefinition(string FullNamespace, string Assemblyname, string InteractionSingletonName, params string[] ClassNames)
Space Pony
Original Poster
#14 Old 30th Sep 2022 at 8:10 PM Last edited by Battery : 2nd Oct 2022 at 5:55 PM.
ListQueries

Battery


bool HasAny<T>(this IList<T> source, Predicate<T> condition)



int CountItems<T>(this IList<T> source, Predicate<T> condition)



List<T> WhereItems<T>(this IList<T> source, Predicate<T> condition)


List<T> Union<T>(this IList<T> IlistOne, IList<T> UnionWith)
Back to top