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!
Trainee Moderator
staff: trainee moderator
Original Poster
#1 Old 30th Apr 2019 at 6:43 PM
Default Adding new interactions to the game
So, I've recently been learning how to code, and also how to make a pure script mod. I'm asking here how I can make a new interaction for the game, and I asked @PuddingFace to help me out with it so I'm just creating a thread here in case anyone else wants to know, and also it'd be easier to post and such.

- When one gets inspired by the other, the one inspires another - Anything is Possible.

You can view some of my WIPs and other stuff for TS3 on my Twitter here ---> https://twitter.com/SweetSavanita
Advertisement
Scholar
#2 Old 1st May 2019 at 3:21 PM
Cool so you want to create a custom interaction? This tutorial is how I got started http://www.modthesims.info/showthread.php?t=491875 It's easy to follow. Follow the same steps to set it up as pausinator. Then copy and paste these
using System;

using System.Collections.Generic;

using System.Text;

using Sims3.Gameplay;

using Sims3.Gameplay.Actors;

using Sims3.Gameplay.Autonomy;

using Sims3.Gameplay.EventSystem;

using Sims3.Gameplay.Interactions;

using Sims3.Gameplay.Utilities;

using Sims3.SimIFace;

using Sims3.UI;

After that create a namespace and a class with the kInstantiator like in Pausinator. That class will have a constructor with this code

{

World.OnWorldLoadFinishedEventHandler += new EventHandler(OnWorldLoadFinishedHandler);

}

Once you have done this much I will give you more instructions. If there's a problem let me know

If you like my mods. Consider supporting me on Patreon
Check out my website for updates on my mods and other work PuddingFace.wixsite.com
Check out my Youtube channel for tutorials(modding tutorials) and other content Youtube

Follow me on Twitter Instagram Pinterest Tumblr
Trainee Moderator
staff: trainee moderator
Original Poster
#3 Old 1st May 2019 at 5:50 PM
Okay, I did what you told me to and I also got a bit of help from the pausinator tutorial, since I had forgotten what to do lol. Here's what my script looks like now:

using System;
using System.Collections.Generic;
using System.Text;
using Sims3.Gameplay;
using Sims3.Gameplay.Actors;
using Sims3.Gameplay.Autonomy;
using Sims3.Gameplay.EventSystem;
using Sims3.Gameplay.Interactions;
using Sims3.Gameplay.Utilities;
using Sims3.SimIFace;
using Sims3.UI;


namespace TheSweetSimmer
{
public class WaveHello
{
[Tunable]
protected static bool kInstantiator = false;

static Pausinator()
}

World.OnWorldLoadFinishedEventHandler += new EventHandler(OnWorldLoadFinishedHandler);

}
}

Also, does it matter where the statements/brackets go? Like these things ---> { }

- When one gets inspired by the other, the one inspires another - Anything is Possible.

You can view some of my WIPs and other stuff for TS3 on my Twitter here ---> https://twitter.com/SweetSavanita
Space Pony
#4 Old 1st May 2019 at 6:17 PM
Hey everyone,

since i just picked up work on my old mods again i stumbled over this thread when checking out the site again

The position of the brackets matter greatly. Think of them as position markers from where to where a statement has validity.
So if you have lets say a class MyClass the brackets would show from which line in the code to which line the class content is spread.

class MyClass
{ <- Everything from here

} <- to Here belongs to the class

static Pausinator()
} <- This one needs to be an "{" for your code to work

Same goes for methods within the class so your Constructor "static Pausinator()"
has validity between the { and the } this is why your method World.OnWorldLoadFinishedEventHandler += new EventHandler(OnWorldLoadFinishedHandler); is called IN the constructor method.

Sorry for all the edits hope this helps at least a bit
Trainee Moderator
staff: trainee moderator
Original Poster
#5 Old 1st May 2019 at 6:26 PM
Alright, thanks! I'll just post a picture of my actual script, to make sure the positions and statements look okay:



Okay, got it! It helped a lot

- When one gets inspired by the other, the one inspires another - Anything is Possible.

You can view some of my WIPs and other stuff for TS3 on my Twitter here ---> https://twitter.com/SweetSavanita
Space Pony
#6 Old 1st May 2019 at 6:34 PM
Quote: Originally posted by TheSweetToddler
Alright, thanks! I'll just post a picture of my actual script, to make sure the positions and statements look okay:


two errors
1. Replace the } in line 22 with a { since you start the constructor there
2. you have no method linked to your event on line 23 so you need to add an method to your class like this "public static void OnWorldLoadFinishedHandler(object sender, EventArgs e){}"
3. i made an mistake i sorry missed that last } put one on line 26 to close the class again sorry for the confusion

since im not as good as chatting it seems here is a picture :P


E: NOTE while the linenumbers dont match yours its still correct and you should have no problem with that bit of code
Screenshots
Trainee Moderator
staff: trainee moderator
Original Poster
#7 Old 1st May 2019 at 6:41 PM
Okay, I think I've fixed those now, but I'll send another picture just to make sure again lol



Edit: Oops, I done goofed up again on one part

- When one gets inspired by the other, the one inspires another - Anything is Possible.

You can view some of my WIPs and other stuff for TS3 on my Twitter here ---> https://twitter.com/SweetSavanita
Space Pony
#8 Old 1st May 2019 at 6:45 PM
Quote: Originally posted by TheSweetToddler
Okay, I think I've fixed those now, but I'll send another picture just to make sure again lol



looking good but you still need to make a method that gets called when the Loadfinished event gets fired. otherwise you will get an error

also while i dont use microsoft visual studio there should be an option to auto ident the brackets which makes it easier to see where the validity borders are try selecting the whole code then right click and see if there is an "ident" option which should better format your code for you
Trainee Moderator
staff: trainee moderator
Original Poster
#9 Old 1st May 2019 at 6:52 PM
I think I fixed that now, and also, I don't see any "ident" when I right click on the code



Edit: Actually I also changed the last bracket under the "public static void OnWorldLoadFinishedHandler(object sender, EventArgs e)" from "}" to "{"

- When one gets inspired by the other, the one inspires another - Anything is Possible.

You can view some of my WIPs and other stuff for TS3 on my Twitter here ---> https://twitter.com/SweetSavanita
Space Pony
#10 Old 1st May 2019 at 6:59 PM Last edited by Battery : 1st May 2019 at 7:10 PM.
Allright thought there would be an option https://stackoverflow.com/questions...ent-source-code says ctrl+k then ctrl+f would do that but only in some version of visual studio... great work microsoft.. but this would just be an cosmetic change anyway and you dont need it necessarily


ok you need one more } to close up your OnWorldLoadFinishedHandler method

like this

public static void OnWorldLoadFinishedHandler(object sender, EventArgs e)
{
//Your Advertisement here
}
Trainee Moderator
staff: trainee moderator
Original Poster
#11 Old 1st May 2019 at 7:09 PM
Hmm, I pressed those keys but nothing seemed to happen, anyways I put in what you said, hopefully it's what you said though? :


- When one gets inspired by the other, the one inspires another - Anything is Possible.

You can view some of my WIPs and other stuff for TS3 on my Twitter here ---> https://twitter.com/SweetSavanita
Space Pony
#12 Old 1st May 2019 at 7:12 PM
Quote: Originally posted by TheSweetToddler
Hmm, I pressed those keys but nothing seemed to happen, anyways I put in what you said, hopefully it's what you said though? :



Looking great now you just need to add "World." right before the "OnWorldLoadFinishedEventHandler" on the left side of the equation and you should get no complie errors

like so World.OnWorldLoadFinishedEventHandler += OnWorldLoadFinishedHandler;

i have attached a txt just in case ^^
Attached files:
File Type: 7z  TheSweetSimmerExample.7z (393 Bytes, 10 downloads) - View custom content
Trainee Moderator
staff: trainee moderator
Original Poster
#13 Old 1st May 2019 at 7:24 PM
Alrighty, I added that! One thing, do you know how I can stop this really annoying thing where I try to add something to the code, but instead of adding a new word, it tries to replace whatever's next to the line that blinks.

Btw here's what the code looks now:

using System;
using System.Collections.Generic;
using System.Text;
using Sims3.Gameplay;
using Sims3.Gameplay.Actors;
using Sims3.Gameplay.Autonomy;
using Sims3.Gameplay.EventSystem;
using Sims3.Gameplay.Interactions;
using Sims3.Gameplay.Utilities;
using Sims3.SimIFace;
using Sims3.UI;


namespace TheSweetSimmer
{
public class WaveHello
{
[Tunable]
protected static bool kInstantiator = false;

static WaveHello()
{
World.WorldLoadFinishedHandler
}
public static void OnWorldLoadFinishedHandler(object sender, EventArgs e)
{
//Yay, I made a new script!
}
}
}

Edit: I have to go now, I'll be back in a bit, thanks for all the help btw

- When one gets inspired by the other, the one inspires another - Anything is Possible.

You can view some of my WIPs and other stuff for TS3 on my Twitter here ---> https://twitter.com/SweetSavanita
Space Pony
#14 Old 1st May 2019 at 7:32 PM
Quote: Originally posted by TheSweetToddler
Alrighty, I added that! One thing, do you know how I can stop this really annoying thing where I try to add something to the code, but instead of adding a new word, it tries to replace whatever's next to the line that blinks.

Btw here's what the code looks now:

using System;
using System.Collections.Generic;
using System.Text;
using Sims3.Gameplay;
using Sims3.Gameplay.Actors;
using Sims3.Gameplay.Autonomy;
using Sims3.Gameplay.EventSystem;
using Sims3.Gameplay.Interactions;
using Sims3.Gameplay.Utilities;
using Sims3.SimIFace;
using Sims3.UI;


namespace TheSweetSimmer
{
public class WaveHello
{
[Tunable]
protected static bool kInstantiator = false;

static WaveHello()
{
World.WorldLoadFinishedHandler
}
public static void OnWorldLoadFinishedHandler(object sender, EventArgs e)
{
//Yay, I made a new script!
}
}
}

Edit: I have to go now, I'll be back in a bit, thanks for all the help btw


hmm sounds like you hit the insert key hit it once and see if the problem persists.

Ok have a good one bye (im also off for today)
Trainee Moderator
staff: trainee moderator
Original Poster
#15 Old 1st May 2019 at 8:08 PM
Thanks! I pressed it and it's fine now. And you too, I'll probably continue this tomorrow or later anyways. Thanks for the help once again, it's very much appreciated

- When one gets inspired by the other, the one inspires another - Anything is Possible.

You can view some of my WIPs and other stuff for TS3 on my Twitter here ---> https://twitter.com/SweetSavanita
Scholar
#16 Old 1st May 2019 at 11:34 PM
Quote: Originally posted by TheSweetToddler
Okay, I did what you told me to and I also got a bit of help from the pausinator tutorial, since I had forgotten what to do lol. Here's what my script looks like now:




Don't worry i also have to watch tutorials a lot.

Also good to see you again Battery. You know I was testing out your UI script in my mod. I probably will release something in the future but now other projects are getting in the way.

Anyway SweetToddler we'll start the next step tomorrow. Also if you click and put the text cursor i.e the blinking line when you type behind the curly brace it will get highlighted and the other curly brace that it is closing or opening will also get highlighted. You can also minimize/hide blocks of code using the - sign on the left of the curly bracket. It's in the left side of the text writing area. If you do that only the class name will appear and the rest of the code appears as ... and you can press the + sign to unhide the code. It's an efficient way to hide the code you are not focusing on and makes scrolling less taxing.

Edit:- Don't worry about the errors just yet. First finish the class and then we'll see the errors. Right now your code is incomplete which is why you are getting errors like that World event loader. And we're going to complete the code step by step.

If you like my mods. Consider supporting me on Patreon
Check out my website for updates on my mods and other work PuddingFace.wixsite.com
Check out my Youtube channel for tutorials(modding tutorials) and other content Youtube

Follow me on Twitter Instagram Pinterest Tumblr
Trainee Moderator
staff: trainee moderator
Original Poster
#17 Old 2nd May 2019 at 6:18 PM
Thanks @PuddingFace , that works nicely!
Okay, well I'm ready to take the next step, so you can send a message whenever you're ready!

- When one gets inspired by the other, the one inspires another - Anything is Possible.

You can view some of my WIPs and other stuff for TS3 on my Twitter here ---> https://twitter.com/SweetSavanita
Scholar
#18 Old 3rd May 2019 at 12:21 AM Last edited by PuddingFace : 3rd May 2019 at 1:51 AM.
Quote: Originally posted by TheSweetToddler
Thanks @PuddingFace , that works nicely!
Okay, well I'm ready to take the next step, so you can send a message whenever you're ready!


Now we create the interaction class.

Code:
private sealed class ShowNotification : ImmediateInteraction<Sim, Sim>

        {

            public static readonly InteractionDefinition Singleton = new Definition();

            protected override bool Run()

            {

                StyledNotification.Show(new StyledNotification.Format(base.Actor.Name + " has clicked on " + base.Target.Name,

                            StyledNotification.NotificationStyle.kGameMessagePositive));

                return true;

            }

            [DoesntRequireTuning]

            private sealed class Definition : ImmediateInteractionDefinition<Sim, Sim, ShowNotification>

            {

                protected override string GetInteractionName(Sim actor, Sim target, InteractionObjectPair interaction)

                {

                    return "Show sim names";

                }

                protected override bool Test(Sim actor, Sim target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)

                {

                    return true;

                }

            }

        }


There are different types of interactions in Sims 3. This is an immediate interaction. It can be used instantly even when the Sims is performing another interaction, is sleeping, or even inside a rabbit hole. It's perfect for making the first interaction. This will not have any talking or routing but using it will give you a notification that active sim name has clicked on target sim name.

private sealed class ShowNotification : ImmediateInteraction<Sim, Sim> This is the class of the interaction. ShowNotification is the name of the class. The name can be whatever you want just don't have 2 classes with the same name. ImmediateInteraction<Sim, Sim> here ImmediateInteraction states that this is an immediate interaction a normal interaction would just have Interaction and TerrainInteraction for if you want the interaction to appear on the ground like go here or the teleport cheat code. <Sim, Sim> is to state that the interaction happens between two Sims, here a Sim can be dog or cat or any occult but not a minor pet or any object. For interactions with object <Sim, GameObject> Or <Sim, Plant> for a more specific gameobject.

private sealed class Definition : ImmediateInteractionDefinition<Sim, Sim, ShowNotification> this is the definition of the interaction. Here you state when the interaction should be usable or who should be able to use it like only family members or only teenagers and the likes. The name of the interaction can also be stated here. If you don't then the interaction will appear as ShowNotification without any spaces. STBL files can also be used to name an interaction.

Code:
protected override string GetInteractionName(Sim actor, Sim target, InteractionObjectPair interaction)
                {
                    return "Show sim names";
                }

In this function the name goes.

Code:
protected override bool Test(Sim actor, Sim target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)

                {

                    return true;

                }

And this is where the condition like age restrictions and other conditions go. Currently there are no conditions every puppy, kitten, child, Simbot etc. can use it. We'll talk about restrictions later.

If there are any problems let me know

If you like my mods. Consider supporting me on Patreon
Check out my website for updates on my mods and other work PuddingFace.wixsite.com
Check out my Youtube channel for tutorials(modding tutorials) and other content Youtube

Follow me on Twitter Instagram Pinterest Tumblr
Virtual gardener
staff: administrator
#19 Old 4th May 2019 at 2:44 PM
I just wanna leave a small reply which is more for people seeing this really helpful thread! Because, I, too, started coding without actually knowing how to code (and we're talking about the logical part of coding, not the language).

Now, 2,5 years into doing web development and grabbing other languages with me along the way (one of them being C#), and now looking at EA's scripts, I wished someone had told me that knowing at least how to write my own programs in C#, because it makes you understand what you're writing, how to tackle the issue at hand, how important testing/debugging is, and how things are connected and how to access specific classes, if not, why the hell we'd want to use a public class that has a 'void' function inside it. Or what variables are, etc.

I didn't mean to hijack the thread, I just want to let the beginner sims 3 scripters know it takes more than a tutorial to understand what you're copy/pasting, if not, how to write your own
Space Pony
#20 Old 4th May 2019 at 6:20 PM
Quote: Originally posted by Lyralei
I just wanna leave a small reply which is more for people seeing this really helpful thread! Because, I, too, started coding without actually knowing how to code (and we're talking about the logical part of coding, not the language).

Now, 2,5 years into doing web development and grabbing other languages with me along the way (one of them being C#), and now looking at EA's scripts, I wished someone had told me that knowing at least how to write my own programs in C#, because it makes you understand what you're writing, how to tackle the issue at hand, how important testing/debugging is, and how things are connected and how to access specific classes, if not, why the hell we'd want to use a public class that has a 'void' function inside it. Or what variables are, etc.

I didn't mean to hijack the thread, I just want to let the beginner sims 3 scripters know it takes more than a tutorial to understand what you're copy/pasting, if not, how to write your own


Seconded. For a long time, I was never able to make anything decent for The Sims 3 -- I just had no idea how any of the code worked. Several years ago, though, I learned the basics of HTML, Javascript, and other languages through Codecademy. (I site I still highly recommend to anyone learning to code -- in fact, I think they have a C# course now!) On a whim, I decided to come back to Sims 3 modding, and found it surprisingly easy and fun for me. I had to learn the C# syntax, yes, but I knew from the practice I had done with other languages the basics of how classes work, how methods pass information to each other, etc.

You can read coding tutorials all day long, but the key to truly learning and being able to create something cool is hands-on practice, just like anything else in life.

And it can get frustrating at times. No matter how good you are, there will be points where something just will not work right, and you will want to tear your hair out because you don't know why. But there are people here and elsewhere who would be more than willing to take a look at your problem and give you some new insight. And when you do finally solve the problem, it will make everything all the more satisfying.

I don't mean to hijack either, just wanted to share my experience

"The Internet is the first thing that humanity has built that humanity doesn't understand, the largest experiment in anarchy that we have ever had." - Eric Schmidt

If you enjoy the mods I put out, consider supporting me on patreon: www.patreon.com/Gamefreak130
Trainee Moderator
staff: trainee moderator
Original Poster
#21 Old 5th May 2019 at 5:59 PM
@PuddingFace I'm sorry I took so long to reply and do the script, it's just I've been so busy making other things. I added this private class after the public one, I also don't know whether the brackets are in proper place or the spaces in between them are okay:


- When one gets inspired by the other, the one inspires another - Anything is Possible.

You can view some of my WIPs and other stuff for TS3 on my Twitter here ---> https://twitter.com/SweetSavanita
Scholar
#22 Old 5th May 2019 at 9:34 PM Last edited by PuddingFace : 5th May 2019 at 9:45 PM.
Good. BTW the code inside your static waveHello() should be this
Code:
World.OnWorldLoadFinishedEventHandler += new EventHandler(OnWorldLoadFinishedHandler);
This code is to mean that when the world finishes loading the OnWorldLoadFinished will run. And then you have
Code:
public static void OnWorldLoadFinishedHandler(object sender, System.EventArgs e)
        {
         }

The OnWorldLoadFinishedHandler here is the same one that you are adding inside static waveHello() and what you do inside it will happen when the game loads.

Also put the class shownotification and everything inside it's {} inside the namespace TheSweetSimmer but not inside class wavehello. Just cut paste it.

If you like my mods. Consider supporting me on Patreon
Check out my website for updates on my mods and other work PuddingFace.wixsite.com
Check out my Youtube channel for tutorials(modding tutorials) and other content Youtube

Follow me on Twitter Instagram Pinterest Tumblr
Trainee Moderator
staff: trainee moderator
Original Poster
#23 Old 5th May 2019 at 9:57 PM
Quote: Originally posted by PuddingFace
Also put the class shownotification and everything inside it's {} inside the namespace TheSweetSimmer but not inside class wavehello. Just cut paste it.


Alright, I fixed the static waveHello, but I don't understand what you mean of putting the class notification inside the namespace TheSweetSimmer? I'll talk more tomorrow, it's my bedtime now, and thanks for the help again

- When one gets inspired by the other, the one inspires another - Anything is Possible.

You can view some of my WIPs and other stuff for TS3 on my Twitter here ---> https://twitter.com/SweetSavanita
Scholar
#24 Old 6th May 2019 at 1:24 AM
I mean that inside namespace TheSweetSimmer {//Private class Shownotification{} }

And good night

If you like my mods. Consider supporting me on Patreon
Check out my website for updates on my mods and other work PuddingFace.wixsite.com
Check out my Youtube channel for tutorials(modding tutorials) and other content Youtube

Follow me on Twitter Instagram Pinterest Tumblr
Trainee Moderator
staff: trainee moderator
Original Poster
#25 Old 10th May 2019 at 6:32 PM
@PuddingFace , this is what my whole script looks like now, I think I got what you said anyways about the namespace:

Code:
 

using System;
using System.Collections.Generic;
using System.Text;
using Sims3.Gameplay;
using Sims3.Gameplay.Actors;
using Sims3.Gameplay.Autonomy;
using Sims3.Gameplay.EventSystem;
using Sims3.Gameplay.Interactions;
using Sims3.Gameplay.Utilities;
using Sims3.SimIFace;
using Sims3.UI;


namespace TheSweetSimmer
{
    public class WaveHello
    {
        [Tunable]
        protected static bool kInstantiator = false;

        static WaveHello()
        {
        World.OnWorldLoadFinishedEventHandler += new EventHandler(OnWorldLoadFinishedHandler);
        }
        public static void OnWorldLoadFinishedHandler(object sender, EventArgs e)
        {
            //Yay, I'm making a new script!
        }
    }
}
namespace TheSweetSimmer
{  
    private sealed class ShowNotification : ImmediateInteraction<Sim, Sim>
    {
    public static readonly InteractionDefinition Singleton = new Definition();

    protected override bool Run()


    {

        StyledNotification.Show(new StyledNotification.Format(base.Actor.Name + " has clicked on " + base.Target.Name,


            StyledNotification.NotificationStyle.kGameMessagePositive));

        return true;

    }

    [DoesntRequireTuning]

    private sealed class Definition : ImmediateInteractionDefinition<Sim, Sim, ShowNotification>


    {



        protected override string GetInteractionName(Sim actor, Sim target, InteractionObjectPair interaction)



        {



            return "Show sim names";



        }

        protected override bool Test(Sim actor, Sim target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)

        {

            return true;

        }
    }
}


- When one gets inspired by the other, the one inspires another - Anything is Possible.

You can view some of my WIPs and other stuff for TS3 on my Twitter here ---> https://twitter.com/SweetSavanita
Page 1 of 2
Back to top