- Site Map >
- Modding and Creation >
- Sims 3 Creation >
- Modding Discussion >
- Overriding
- Site Map >
- Modding and Creation >
- Sims 3 Creation >
- Modding Discussion >
- Overriding
Replies: 15 (Who?), Viewed: 2385 times.
#1
9th Aug 2010 at 7:34 AM
Overriding
I was trying to figure out how to override a function that an object calls without having to make a clone of that object and derive it and then use override. Specifically I wanted to make any and all computers (which is key because I know I could make a copy of all of the objk files and then change it to the proper script but it wouldn't include any custom content computers) use a different version of the IsComputerUsable method (without core modding of course). Does anyone have any light on the subject?Thanks
Advertisement
#2
9th Aug 2010 at 8:00 AM
Posts: 11,682
Thanks: 9680 in 11 Posts
Well I am guessing you write your script calling it the same thing and stick it in the mods folder. If resource.cfg gives the folder contents high priority, it should override. But you probably also have to give it the same resource number, which means you have to include everything that was originally under that instance number. What exactly is the definition of a core mod? This sounds like it.
"You can do refraction by raymarching through the depth buffer" (c. Reddeyfish 2017)
"You can do refraction by raymarching through the depth buffer" (c. Reddeyfish 2017)
#3
9th Aug 2010 at 8:05 AM
Well I consider a core mod one to be where you edit the actual main scripts for the game and then insert the new one which overrides the original. For core mods they conflict with each other because there would only be four files (or so) to edit. Would calling it the same thing and have like proper namespaces and classes to actually get it in the right spot actually work? I'm not really sure what you refer to as the same resource number unless you are referring to going into core modding which would take all of the Sims3GamePlay files to get to the part of just the computer.
Lab Assistant
#4
9th Aug 2010 at 9:56 AM
Posts: 105
Thanks: 3609 in 7 Posts
In ani_'s "Get Drunk" mod it alters all of the bar objects with a new function. You might want to ask them
#5
9th Aug 2010 at 12:32 PM
I'll take a look at it, but Is the new function overriding an old one t hough?
Lab Assistant
#6
9th Aug 2010 at 1:07 PM
Posts: 105
Thanks: 3609 in 7 Posts
Quote: Originally posted by Kolipoki
I'll take a look at it, but Is the new function overriding an old one t hough? |
It appears so. Or ani_ removed the old one.
#7
9th Aug 2010 at 4:26 PM
So i'm not really sure what you are referring to for which function it is overriding. It just looks like ani_ adds new interactions.
#8
9th Aug 2010 at 4:33 PM
Quote: Originally posted by Kolipoki
I was trying to figure out how to override a function that an object calls without having to make a clone of that object and derive it and then use override. |
There is a non-core way, though. The IsComputerUsable() method gets only called by interactions. You could clone all these interactions and change their Test() methods to call a different method. Then you remove all the original interactions from all computers (and use a listener to handle new computers) and add your changed interactions. Of course this will have no effect, if other code instantiates the original interactions directly.
If gotcha is all you’ve got, then you’ve got nothing. - Paul Krugman
#9
9th Aug 2010 at 5:00 PM
Well considering there are 45 different calls of the IsComputerUsable() method that would still take some time. But maybe if I clarify myself more it might make more sense/another way. I don't want to change or remove anything that is already there I only want to add my own checks into it.
#10
9th Aug 2010 at 7:34 PM
Quote: Originally posted by Kolipoki
Well considering there are 45 different calls of the IsComputerUsable() method that would still take some time. |
Quote:
I don't want to change or remove anything that is already there I only want to add my own checks into it. |
If gotcha is all you’ve got, then you’ve got nothing. - Paul Krugman
#11
10th Aug 2010 at 1:33 AM
While a change is a change sometimes it would seem easier to be able to add something then to edit the already existing one.
#12
10th Aug 2010 at 4:48 AM
Posts: 3,878
Thanks: 21111 in 16 Posts
Quote: Originally posted by Kolipoki
So i'm not really sure what you are referring to for which function it is overriding. It just looks like ani_ adds new interactions. |
I don't override anything. I copied the code for the make drinks interaction for example, and made my own version of it so I could insert the code I needed inside the original make drink interaction. Then just removed the original from the object (which by the way I'm doing wrongly in the drunk mod, it's better to do it in the ITUN file, instead of the code).
And speaking of ITUN files. If you only want to add a check when an object is usable, can't you achieve that by modifying the original ITUN of the interaction you are using?
There is a section in there called
Code:
<Current_Tuning> <BaseAvailability>
Where you can add different kinds of checks, like what age groups can use it, or is it allowed for pregnant people or not.
#13
10th Aug 2010 at 6:08 PM
Quote: Originally posted by ani_
which by the way I'm doing wrongly in the drunk mod, it's better to do it in the ITUN file, instead of the code |
If gotcha is all you’ve got, then you’ve got nothing. - Paul Krugman
#14
10th Aug 2010 at 7:23 PM
Posts: 3,878
Thanks: 21111 in 16 Posts
Because I noticed that just removing the interaction from the object, will not stop Sim's from using them. The coffee mod for example, the original "Serve Hot Beverage" interaction was removed in code, I couldn't see it if I clicked the coffee machine, but sims would still be able to use it. Changing the ITUN file I was able to both remove it from the object, and stop Sim's from using it.
This same bug still exist in the drunk mod, sims will sometimes just drink juice, even thou the interaction is no longer in the object itself.
This same bug still exist in the drunk mod, sims will sometimes just drink juice, even thou the interaction is no longer in the object itself.
#15
10th Aug 2010 at 8:30 PM
Quote: Originally posted by ani_
Because I noticed that just removing the interaction from the object, will not stop Sim's from using them. |
I don't think that's the case for interactions like that, though. Might be because you derived some of the interactions instead of cloning them. Other code that just looks for the base class will access the original Singleton and not your new one.
If gotcha is all you’ve got, then you’ve got nothing. - Paul Krugman
Lab Assistant
#16
10th Aug 2010 at 9:15 PM
Posts: 105
Thanks: 3609 in 7 Posts
Quote: Originally posted by ani_
Because I noticed that just removing the interaction from the object, will not stop Sim's from using them. The coffee mod for example, the original "Serve Hot Beverage" interaction was removed in code, I couldn't see it if I clicked the coffee machine, but sims would still be able to use it. Changing the ITUN file I was able to both remove it from the object, and stop Sim's from using it. This same bug still exist in the drunk mod, sims will sometimes just drink juice, even thou the interaction is no longer in the object itself. |
I noticed that too. And it only happens on community lots.
Who Posted
|