- Site Map >
- Modding and Creation >
- Sims 3 Creation >
- Modding Discussion >
- Script Modding In 2020
- Site Map >
- Modding and Creation >
- Sims 3 Creation >
- Modding Discussion >
- Script Modding In 2020
Posts: 562
Thanks: 3603 in 11 Posts
Now might be a good moment to explain why we do this. C# or better the .NET framework has some concrete rules. We will "exploit" one of these rules to get our script up and running in TS3. This rule goes as follows: The first time a static field, property or method of a class gets accessed, the static constructor of that class will be called. That is to make sure that everything is in decent shape before the class has to interact with the rest of the world. S3 on the other hand parses all XML resources, and assigns the tunable values it finds in there to the related variables in the related classes. |
And this means custom code can be run, because the game can find it when it is assigning the values of tunable variables that it finds in the the xml files. When the variable in the class is being accessed to be assigned the value found in the xml, the constructor of the class is called, which means the class is made and put into action, and so your code will be run.
At least that's what I understand of it, and sorry if this is actually more confusing!
So basically your tunable instantiator variable in the Instantiator class (neither actually need to be called Instantiator I'm pretty sure, but I guess the name just describes what it's doing) can be assigned a value by an xml file (because it's tunable) and so you make your xml file (in the pure scripting tutorial) which the game will read, and because the game assigns all variables found in xmls, it will access the Instantiator variable in your code, and in turn the Instantiator class will be "instantiated", running your code basically.
Basically you need two things, a variable in your code (can be any thing but for example a bool called Instantiator), and an xml file in your package file that assigns the variable some value (so like kinstantiator = true). And the tutorial tells you how to make your xml resource
Hope this makes sense, the tutorial I linked does explain how it actually works but it took me a while to get it and I think it's easier to do stuff when you actually understand what's happening, so I thought id try to explain it in more detail
Posts: 3,860
Thanks: 8559 in 67 Posts
Also make sure to add something like:
[Tunable] protected static bool kInstantiator = false;
(Or name it anything else, like Zoe mentioned but then in the XML you also need to change the kInstantiator' part: <kInstantiator value="True" /> To something you added in your C# code
Posts: 201
Thanks: 160 in 1 Posts
Hey...hey...how y'all doin'?
Long story short, I took a break from this project due to personal reasons and this project, while very loved and wanted to be seen to completion, was not helping me cope with those personal reasons. So I'm pretty stable now and ready to open it up and take it back on. I've reread this thread a few times to refresh myself and I think I'm getting somewhere now, I just need to go very, very slow. While I'm here though, I wanted to ask how I could get ILSpy working with SharpDevelop? It says to install the ILSpy Addin but I can't find that specific file anywhere; on the internet or on my computer.
Oh c'mon. There better be a point to all this stress I'm under.
Posts: 562
Thanks: 3603 in 11 Posts
IlSply just decompiles the game dlls so you can see the game code and copy paste/use as a reference etc. The you use Sharp Develop to write your code and compile it
Honestly I'm not sure what the ILSpy plugins actually do.
Posts: 201
Thanks: 160 in 1 Posts
You don't actually need to get them working together as far as I know. There is also a ILSpy addon for Visual Studio though I haven't worked out how it works :P ILSpy just decompiles the game dlls so you can see the game code and copy paste/use as a reference etc. The you use Sharp Develop to write your code and compile it Honestly I'm not sure what the ILSpy plugins actually do. |
That's why I want to get it to work with SharpDevelop!
Oh c'mon. There better be a point to all this stress I'm under.
Posts: 562
Thanks: 3603 in 11 Posts
That's why I want to get it to work with SharpDevelop! |
What exactly do you need to get it working with SharpDevelop for?
You should just be able to open the game dlls with IlSpy to see all the game code, which you can then use to write your own script in SD - I'm not sure why you would need the plugin for that to work?
Adding the references to your project is a separate thing - when I meant use as a reference, I just meant see how the game code works so you can work out what you need to do to get your own code to function how you want it. Sorry if that was what confused you
Posts: 433
Thanks: 792 in 6 Posts
To test my hypothesis just write a simple Test.
[Tunable] internal static bool kInstantiator = false;
do a right click on [Tunable] and see if you can select Go to Definition this should show you the decompiled version from the source dll
other than that im also puzzled why you dont use ilspy directly.
Posts: 3,860
Thanks: 8559 in 67 Posts
Im not completely sure since my setup dates back some time by now but as far as i know SD already has the ilspy functionality included by default. To test my hypothesis just write a simple Test.
Code:
[Tunable] internal static bool kInstantiator = false; do a right click on [Tunable] and see if you can select Go to Definition this should show you the decompiled version from the source dll other than that im also puzzled why you dont use ilspy directly. |
Posts: 201
Thanks: 160 in 1 Posts
I'm confused. What exactly do you need to get it working with SharpDevelop for? You should just be able to open the game dlls with IlSpy to see all the game code, which you can then use to write your own script in SD - I'm not sure why you would need the plugin for that to work? Adding the references to your project is a separate thing - when I meant use as a reference, I just meant see how the game code works so you can work out what you need to do to get your own code to function how you want it. Sorry if that was what confused you. |
Nope! I understood what you meant perfectly. ILSpy works separately, but I wanted to have it in SharpDevelop as a plugin as it would save me some time. But hey, If I can't use it as a plugin that's fine! Water off a ducks back, honestly.
Im not completely sure since my setup dates back some time by now but as far as i know SD already has the ilspy functionality included by default. To test my hypothesis just write a simple Test.
Code:
[Tunable] internal static bool kInstantiator = false; do a right click on [Tunable] and see if you can select Go to Definition this should show you the decompiled version from the source dll. other than that im also puzzled why you dont use ilspy directly. |
That actually doesn't work for me, unfortunately. We might be using different versions of SharpDevelop! I wanted to use ILSpy from the plugin in SharpDevelop to save time and space, but using it directly is fine as well and that's what I'm going to start doing from this point onwards.
I'll come back here if I need help with anything else or want to ask more questions!
Oh c'mon. There better be a point to all this stress I'm under.
Posts: 201
Thanks: 160 in 1 Posts
Quick question @Lyralei
Does the Object Modding (Interactions) tutorial also apply to adding interactions to terrains like grass, sand, and the ocean, instead of objects? Are there any differences at all that I should know of?
Oh c'mon. There better be a point to all this stress I'm under.
Posts: 3,860
Thanks: 8559 in 67 Posts
*coughs* Quick question @Lyralei Does the Object Modding (Interactions) tutorial also apply to adding interactions to terrains like grass, sand, and the ocean, instead of objects? Are there any differences at all that I should know of? |
The tutorial you linked though is if you make your own object and want it to do particular things Now, if you were to want to do stuff for water/sand or anything terrain like, it's actually good practise to first see what the existing interactions link to, or even do for that matter . EA made a TON of different interaction variations (think, immediate interaction, actorless interaction, etc), and half of them are really just used for 5 interactions or so.
Let me know though if you need some more help with that though! Since the first few reads it tends to be a bit overwhelming to fully understand all of that
Posts: 562
Thanks: 3603 in 11 Posts
Posts: 10
My experiences about getting simple hello world to run:
1. Project configurations seem to be in .csproj -file. I took advantage of the csproj-files of other sims mods and didn't bother to find all the right settings from visual studio 2019 user interface. My project file could probably use some fine tuning. For example, I don't know if you need all the sims sources, unless you use them.
2. I skipped the part with reflector and took sims dlls from Nraas github. They had some differences to the original version, but they seem to be working... at least for Hello World -purposes.
3. The hello world was written without Reflector or IlSpy, but I installed IlSpy after making it. I couldn't get IlSpy Visual Studio add-on working out of the box. Standalone version seems to be fine. I would be nice to find smarter workflow to view the code, though.
4. Visual studio is either clunky or I can't use it. Next step might be looking for nicer IDE.
Posts: 201
Thanks: 160 in 1 Posts
There are mods out there that would be very helpful to me if I could like, see their code and see how they Do The Thing, but every time I run them through S3PE all I see is gibberish!
Oh c'mon. There better be a point to all this stress I'm under.
Posts: 201
Thanks: 160 in 1 Posts
Oh c'mon. There better be a point to all this stress I'm under.
Posts: 433
Thanks: 792 in 6 Posts
The sole purpose of the sealed keyword is to prevent Inheiretance (there is a "funny" statement that says that people who use the sealed keyword should be sealed away themselfs because its just stupid in most cases )
Posts: 201
Thanks: 160 in 1 Posts
Oh c'mon. There better be a point to all this stress I'm under.
Posts: 1,500
Thanks: 4283 in 41 Posts
Posts: 201
Thanks: 160 in 1 Posts
The interaction I want to modify is indeed a SocialInteractionA interaction; it's the Pet Fight interaction and I want to have it to where it has a chance of killing the target. I also want this action to be autonomous for pets with specific traits, and for the Sims being attacked to have a chance of surviving depending on traits, athletic skill, or both.
Oh c'mon. There better be a point to all this stress I'm under.
Posts: 1,500
Thanks: 4283 in 41 Posts
I will instead recommend that you disable this interaction with an ITUN and create a new fight interaction for pets. And then you can do what you want with this new interaction.
Posts: 201
Thanks: 160 in 1 Posts
Although, creating a new interaction? That sounds excellent, I would love to do that except...I don't know how. I'm just barely grasping how to use existing interactions and code to cobble together an interaction by going off these tutorials:
https://modthesims.info/wiki.php?ti...Depth_Scripting
https://modthesims.info/showthread.php?t=491875
Also, disabling the Fight Pet interaction with an ITUN? I don't want to replace the Fight Pet interaction with my own.
Oh c'mon. There better be a point to all this stress I'm under.
Posts: 3,860
Thanks: 8559 in 67 Posts
Hook into the custom buff code that is used for store buffs, got it. I understand that. As for having an instantiator xml, I actually don't think I have that? I have an instantiator, "Cheshirefrown", but not an instantiator xml I don't think. How do I get that? I looked around and the links to the example instantiator class and instantiator xml to import into S3PE are dead. |
So:
(C# code snippet:
[Tunable] protected static bool Cheshirefrown = false;
<?xml version="1.0" encoding="utf-8"?> <base> <Current_Tuning> <Cheshirefrown value="True"> <!-- Scripting Mod Instantiator, value does not matter, only its existence --> </Cheshirefrown> </Current_Tuning> </base>
Else, which is a super rare thing to happen, it's really just the website's encoding that notepad (or notepad++, whatever text editor you're using) that isn't compatible with the sims 3. And therefore it wouldn't read it. At least I had that happen to me after I copied it from another file I downloaded... But I doubt it's that. Just a heads up that it COULD be that.
Hope this helps!
Posts: 1,500
Thanks: 4283 in 41 Posts
Well let's see, lookin' through S3PE I can see the ITUN file for the interaction and lookin' through ILSpy I can see the interaction's code. So going of your words I can modify the interaction into a custom one. Although, creating a new interaction? That sounds excellent, I would love to do that except...I don't know how. I'm just barely grasping how to use existing interactions and code to cobble together an interaction by going off these tutorials: https://modthesims.info/wiki.php?ti...Depth_Scripting https://modthesims.info/showthread.php?t=491875 Also, disabling the Fight Pet interaction with an ITUN? I don't want to replace the Fight Pet interaction with my own. |
Oh you will have to create a new interaction anyway if you want to change an EA interaction with script. You will have to replace the EA interaction with yours using script. If the interaction didn't have ITUN or code then you will have to remove the interaction with tuning and add your custom interaction in.
It's not too hard to create your own interaction.
Posts: 201
Thanks: 160 in 1 Posts
It's not too hard to create a custom interaction? So does this mean I'm on the right track of following this tutorial?
Oh c'mon. There better be a point to all this stress I'm under.
Posts: 1,500
Thanks: 4283 in 41 Posts
Who Posted
|