- Site Map >
- Modding and Creation >
- Sims 3 Creation >
- Tutorials >
- Other - Tutorial - Using Battery's S3SE tool as a script modder
- Site Map >
- Modding and Creation >
- Sims 3 Creation >
- Tutorials >
- Other - Tutorial - Using Battery's S3SE tool as a script modder
Replies: 1 (Who?), Viewed: 5413 times.
#1
2nd Mar 2021 at 5:22 PM
Posts: 3,860
Thanks: 8548 in 67 Posts
Tutorial - Using Battery's S3SE tool as a script modder
Hey everyone!You might have seen battery's new tool called 'S3SE' (Sims 3 Script Extender), A still pretty prototype-y program that was designed to make modding easier for the script modders among us. Now, you might have looked at this download and sort of understanding what it does, but would like a more explicit manual? Well, here you go! :D
Why would I want to use S3SE?
- Testing a super simple script has now been made simple by not having to reload your game constantly when making changes!
- Import (and even export) your own text files into a nice notification.
- (soon) Adding your own audio files in a super easy way! (WAV and MP3)
- And in-game folder organization! So anywhere on your computer you can add directories, add files/remove files, Find files and such.
FOLDER ORGANISATION & CREATING/FINDING FILES RELATED OPTIONS:
1. Interaction: List Files of Type:
Add the path to the first input field, which is the folder you'd like to check what kind of files you can find in it. In the second input field, add what kind of 'file' you're looking for, this can be ANY file you want! I just used package as a demonstation. But jpeg or png or zip does it too!:
Results into:
Unfortunately, adding multiple file types to find (So .package, .pdf) won't work, however.
2. Interaction: List Files:
However, a somewhat workaround from not being able to get some files, we can use the 'List Files' instead. Which is an interaction that gets ALLLL the files that are found in that particular folder.
Note: This option seemingly seemed to crash whenever it wasn't a C:\ path, so be aware of this!
3. Interaction: List Directories:
Just like the previous interaction, this can cause some crashes (especially if the folder is seemingly over a particular size or permission isn't properly set)
Figures out which sub-folders this particular folder has, by letting it know which path you want it to check
4. Interaction: Create Directory:
Does exactly what you imagine it does :p Make a Directory!
And then check the directory and voila! It's there!
5. Interaction: Mod folder path:
Shows where your mod folder is installed:
6. Interaction: File Exist?
Another one that speaks for itself This one checks if the file exists according to the game:
Returns:
And if it doesn't exist, of course false
7. Interaction: LTF (Load Text File)
Loads the text file you made This could be great to double-check if your Unicode is correct (And readable by the game!) First, you need to show *where* the file is. Now, the text file I made for this purpose is called 'Lyra.txt' which I saved as an UTF-8 file.
It might show a popup that says '!Openwrite()' but just ignore that Sometimes, if you screwed up the pathing by not adding a .txt at the end, it could sometimes show this popup, with the size of the file and the path. just not the content inside it
7. Interaction: STF (Save Text File)
Let's you create a text file that you made inside the game:
You can also replace files this way! say, we want to write a whole different message inside my 'Lyra2.txt' file, then we simply do:
Path: C:\Users\USER\Documents\TestFolder\Lyra2.txt
Text: I was replaced by the game!
And when we would check this, it actually is!
8. Interaction: STF (Save Text File)
Information coming soon
Assembly-related cool stuff!
This is where the magic happens for script modders and where this tool is super helpful to have! You can load in any of your .dll files on runtime That way, we don't need to re-start the game (Although recommended when testing it for your end-users though). But in cases where we're debugging whether a particular variable is working correctly, or even the start of our scripting adventures, we can use these create options.
For these purposes, I'll try a few different methods. One is more on global levels and the others on a sim and object level.
WARNING: Despite the fact we can load in our .dlls, it is curial to still follow the regular ways of creating a game-compatible .dll file. For that, see: https://modthesims.info/wiki.php?ti..._Studio_project OR https://modthesims.info/showthread.php?t=632267
Lets start with a easy print statement!
Code:
GENERAL RULE OF THUMB WHEN MAKING DLL FILES FOR S3SE: using Sims3.UI; public class Main { // This is hardcoded to be read as Initalize, so always keep this. public static void Initialize() { StyledNotification.Show(new StyledNotification.Format("Hello World!", StyledNotification.NotificationStyle.kGameMessagePositive)); } // Main here is hardcoded, so we ALWAYS need to call this main. static Main() { } }
Just like non-sim programs, we ALWAYS need a 'Main' class and a Initialize() function. Now some program languages would call it 'Init()' but in this case, it's called Initialize(). These two are a MUST HAVE In your dll, else it won't work and return a null reference!! After including those, you can of course add as many different class names and functions as you like We'll get to that in a bit!
Back to the tutorial....
Easy, right? Make sure to build this, so we have a .dll to use. This is all we need for now! Now, If you haven't open your game with S3SE.exe (so NOT TS3W.exe) or S3SE_Runtime.exe if you're using origin as your launcher.
Now, because the sims 3's input field only comes with like 200 characters to put in, I copy/pasted the .dll that we just built into the TestFolder I used as an example and called it Print.dll
After that, click on the terrain again, Battery... > Run Assm (which stands for Run assembly) and this will pop up:
Look! Our print statement! :D
Creating a global mod with this:
So, while creating a simple thing like this is cool we really want to do some cool stuff here! Now, what if we do a global mod that gives the world Rubber duckies, that is determined around the range of every sim and make the world's most useless global mod? Let's do it! Because why not...
Code:
using Sims3.Gameplay; using Sims3.Gameplay.Actors; using Sims3.Gameplay.Objects.Miscellaneous; using Sims3.SimIFace; using Sims3.UI; public class Main { // This is the Initiation function that I'd try and keep using public static void Initialize() { // 1. First, we let them know we're creating the duckies... Because we're kind evil people :p PrintStatement("Creating a Rubber ducky apocalypse..."); // 2. Call the Duckies function so it gets run by S3SE! CreateAllTheDuckies(); } // Main here is hardcoded, so we ALWAYS need to call this main. static Main() { } public static void CreateAllTheDuckies() { // 3. Get all the sims in the world... foreach (Sim sim in Sims3.Gameplay.Queries.GetObjects<Sim>()) { // 4. Get a good location depending on where the sim is. World.FindGoodLocationParams fglParams = new World.FindGoodLocationParams(sim.Position); // Whether the object needs to be created outside the room or inside. Sometimes rooms are just too small fglParams.BooleanConstraints |= FindGoodLocationBooleans.StayInRoom; // 5. Call our function that figures our how many duckies to generate... HowManyDuckies(10, fglParams); } PrintStatement("Duckies have taken over the world!!"); } public static void HowManyDuckies(int number, World.FindGoodLocationParams fglParams) { // The reason why we made fglParams an parameter in here is so that the code still knows where to put the duckies position wise int i = 0; // 6. While our number is less than 10, create another ducky till you reach 10... while (i < number) { // Create ducky at a good location around sim... RubberDucky ducky = GlobalFunctions.CreateAtGoodLocation("RubberDucky", null, fglParams) as RubberDucky; i++; } } // An easy print statement public static StyledNotification PrintStatement(string text) { return StyledNotification.Show(new StyledNotification.Format(text, StyledNotification.NotificationStyle.kGameMessagePositive)); } }
Click on Battery... > LASM, dump in the path as you did before, and click 'Run Assm' again... Let's see if the game generates duckies!
MWAHAHA!
Injecting stuff to appear as interaction on an object...
Allright! So now we got the global mod stuff covered and know that part works, let's create an object mod! Now, for this we do have to do it on a somewhat global level, since with the regular way of programming a functional object, we'd need to edit the OBJD and stuff... So we're going to do it this way: http://www.simlogical.com/ContentUp..._script_mod.pdf
But, to keep everything in an oddly-apocalyptic spirit, let's create some to-be-killer bees! :p
Code:
using Sims3.Gameplay.Actors; using Sims3.Gameplay.Autonomy; using Sims3.Gameplay.Interactions; using Sims3.Gameplay.Objects.Insect; using Sims3.SimIFace; using Sims3.UI; public class Main { // This is the Initiation function that I'd try and keep using public static void Initialize() { GiveTalkingBeesInteraction(); } // Main here is hardcoded, so we ALWAYS need to call this main. static Main() { } public static void GiveTalkingBeesInteraction() { foreach (BeekeepingBox bees in Sims3.Gameplay.Queries.GetObjects<BeekeepingBox>()) { foreach (InteractionObjectPair pair in bees.Interactions) { if (pair.InteractionDefinition.GetType() == TalkingBees.Singleton.GetType()) { return; } } bees.AddInteraction(TalkingBees.Singleton); } } // An easy print statement public static StyledNotification PrintStatement(string text) { return StyledNotification.Show(new StyledNotification.Format(text, StyledNotification.NotificationStyle.kGameMessagePositive)); } public class TalkingBees : Interaction<Sim, BeekeepingBox> { public class Definition : InteractionDefinition<Sim, BeekeepingBox, TalkingBees> { public override bool Test(Sim a, BeekeepingBox target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback) { return true; } public override string GetInteractionName(Sim actor, BeekeepingBox target, InteractionObjectPair iop) { return "Speak my bees!"; } } public static InteractionDefinition Singleton = new Definition(); public override bool Run() { base.StandardEntry(); PrintStatement("Bzzz! Bzzzbzbzbz! (Translation: We are beez! We come in peaze!"); base.StandardExit(); return true; } } }
Do the magic again... Battery... > LASM, Add path to dll, then we do Run ASSM again...
And the result... I present to you...
Speaking bees! :D
Conclusion:
So this is how you can use S3SE to your advantage Especially just testing code on the go without having to re-open the game, load the world, test, close game, repeat... etc. It's really not that fun whenever that happens, so this really is my favourite mod of the year now, just because I can just load in my dll and test my objects. Change the code again and just click literally 3 buttons to test it again!
I'll keep this post updated for any future stuff features! I really hope you guys find it easier now to understand what it does and how to use it
4 users say thanks for this.
(Who?)
Thanks
Advertisement
#2
3rd Mar 2021 at 9:40 PM
Posts: 845
Thanks: 371 in 3 Posts
I'm here for the ducks! Thanks for the tutorial Lyralei.
Who Posted
|