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!
Quick Reply
Search this Thread
Senior Moderator
staff: senior moderator
#26 Old 15th May 2020 at 6:35 AM
If you look at the pure modding tutorial (Here) it explains this:
Quote:
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
Advertisement
Virtual gardener
staff: administrator
#27 Old 15th May 2020 at 9:47 AM
(Here's also a part in the tutorial, see "Writing the XML" http://www.modthesims.info/wiki.php...ripting_Modding )

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
Lab Assistant
Original Poster
#28 Old 5th Sep 2020 at 7:40 PM
*walks into this thread 3 months later, but with starbucks this time*

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.
Senior Moderator
staff: senior moderator
#29 Old 5th Sep 2020 at 9:43 PM
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
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.
Lab Assistant
Original Poster
#30 Old 5th Sep 2020 at 11:46 PM
Quote: Originally posted by zoe22
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.
Senior Moderator
staff: senior moderator
#31 Old 6th Sep 2020 at 12:34 PM
Quote: Originally posted by LittleCheshire
That's why I want to get it to work with SharpDevelop!
I'm confused :p
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
Space Pony
#32 Old 6th Sep 2020 at 1:23 PM Last edited by Battery : 6th Sep 2020 at 1:54 PM.
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.
Virtual gardener
staff: administrator
#33 Old 6th Sep 2020 at 2:38 PM
Quote: Originally posted by Battery
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.
This is btw the same for Visual studio as well, if you happen to use that instead  It's quite nifty though! Personally I only use ILSpy when i'm searching through multiple dlls, rather than one class. Else it's indeed what battery suggested.
Lab Assistant
Original Poster
#34 Old 6th Sep 2020 at 6:10 PM
Quote: Originally posted by zoe22
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.

Quote: Originally posted by Battery
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.
Lab Assistant
Original Poster
#35 Old 7th Sep 2020 at 2:40 AM
*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?

Oh c'mon. There better be a point to all this stress I'm under.
Virtual gardener
staff: administrator
#36 Old 7th Sep 2020 at 9:40 AM
Quote: Originally posted by LittleCheshire
*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?
It uses the same concept, but it actually requires 'finding the objects' (even sims and terrain  ) and 'injecting' the interaction. I always open this tutorial for that: http://www.simlogical.com/ContentUp..._script_mod.pdf

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
Senior Moderator
staff: senior moderator
#37 Old 7th Sep 2020 at 10:41 AM
And here I was completely clueless about the ILSpy plugin and just using it separately all this time :P
Test Subject
#38 Old 19th Sep 2020 at 9:11 PM
Got my little hello world working and it was much less hassle than I expected. The build succeeded in the first try but I had to tweak a little the code to get the message showing.

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.
Screenshots
Lab Assistant
Original Poster
#39 Old 1st Nov 2020 at 4:25 AM
Okay so basically, I have three coding projects I'm working on and I'm bouncing between the three of them like a kangaroo on crack because I have nothing too serious on my plate at the moment that will keep me away from coding and learning how to do it. Right now I'm dedicating time to the second project; which is me adding a new social interaction into the game that requires me to modify an existing social interaction in the game. I was wondering how I could give this existing interaction a new definition? I can post what little code I already have, if that helps as well.

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.
Lab Assistant
Original Poster
#40 Old 5th Nov 2020 at 11:26 PM
Okay actually, I retract that upper statement! I'm pretty sure I got that new definition thing down. I only have a very quick question: are internal sealed classes derivable? I'm trying to derive from an interaction that is an internal sealed class but IntelliSense or whatever autofill feature SharpDevelop has isn't picking it up. Can I use the internal sealed class anyway and the autofill feature not picking it up isn't a problem?

Oh c'mon. There better be a point to all this stress I'm under.
Space Pony
#41 Old 6th Nov 2020 at 7:11 AM
No you cant
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 )
Lab Assistant
Original Poster
#42 Old 6th Nov 2020 at 7:40 AM
Oh, I see! Thanks.

GODDAMNIT EA.

Oh c'mon. There better be a point to all this stress I'm under.
Scholar
#43 Old 6th Nov 2020 at 11:53 PM
@LittleChesire Modify an existing social interaction? Which interaction cause a lot of them are coded differently. Some of the social interactions are just all SocialInteractionA or something.

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
Lab Assistant
Original Poster
#44 Old 7th Nov 2020 at 7:52 AM
Hello @PuddingFace

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.
Scholar
#45 Old 7th Nov 2020 at 7:58 AM
Do you see the interaction's ITUN file or code? If not then you can't modify.

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.

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
Lab Assistant
Original Poster
#46 Old 7th Nov 2020 at 10:48 AM
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 c'mon. There better be a point to all this stress I'm under.
Virtual gardener
staff: administrator
#47 Old 7th Nov 2020 at 12:42 PM
Quote: Originally posted by LittleCheshire
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.
Dead as in... they don't react to 'true/false'? :p Because if you got an instantiator called 'Cheshirefrown' in your C# script, you also need to name it 'Cheshirefrown' where the tutorials would have used 'kInstantiator'

So:
(C# code snippet:
Code:
[Tunable]
protected static bool Cheshirefrown = false;
XML:
Code:
<?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>
I also usually hash the XML file like so: "NAMEPSPACE.CLASSNAME". With has I mean, you double click on the XML file in S3PE, you see the 'name' input field. You paste in the correct Namespace + Classname and click 'FNV64'  Because if I recall correctly, else the code can't find the right XML file for the tunable?

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!
Scholar
#48 Old 7th Nov 2020 at 2:48 PM
Quote: Originally posted by LittleCheshire
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.

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
Lab Assistant
Original Poster
#49 Old 8th Nov 2020 at 12:27 AM
Thanks for the explanation, Lyralei! I figured that out a while ago, and have learned a lot since then, but I genuinely thank you for laying the information out like that; I understand Instantiators and XMLs completely now!

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.
Scholar
#50 Old 8th Nov 2020 at 1:35 PM
Yea that tutorial will help you get started. You will learn to make an immediate interaction. And then with that you can make a regular interaction with animations as well.

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
Page 2 of 3
Back to top