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
The Attack Cat
retired moderator
Original Poster
#1 Old 9th Aug 2010 at 7:34 AM
Default 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
One horse disagreer of the Apocalypse
#2 Old 9th Aug 2010 at 8:00 AM
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)
The Attack Cat
retired moderator
Original Poster
#3 Old 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 Old 9th Aug 2010 at 9:56 AM
In ani_'s "Get Drunk" mod it alters all of the bar objects with a new function. You might want to ask them
The Attack Cat
retired moderator
Original Poster
#5 Old 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 Old 9th Aug 2010 at 1:07 PM
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.
The Attack Cat
retired moderator
Original Poster
#7 Old 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.
1978 gallons of pancake batter
#8 Old 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.
In short: You cannot, not without a core mod. You can't even override the IsComputerUsable() method if you derive a new class from Computer, because the method isn't virtual.

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
The Attack Cat
retired moderator
Original Poster
#9 Old 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.
1978 gallons of pancake batter
#10 Old 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.
That is the price for doing it non-core. A lot of things that are just minor changes for a core mod become very difficult if you want to do it non-core.

Quote:
I don't want to change or remove anything that is already there I only want to add my own checks into it.
That doesn't matter, really. A change is a change is a change, and you can only change code with core mods.

If gotcha is all you’ve got, then you’ve got nothing. - Paul Krugman
The Attack Cat
retired moderator
Original Poster
#11 Old 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.
Mad Poster
#12 Old 10th Aug 2010 at 4:48 AM
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.
1978 gallons of pancake batter
#13 Old 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
And why is that? I'd prefer doing something like that in code anytime. Changing the original ITUN resource results in a tuning mod. Tuning mods can conflict with other mods; scripting mods are virtually incapable of conflicting with any other mod. Plus, removing a whole interaction from an object saves a bit of processing time in comparison to a changed tuning which just makes the test method of that interaction return false.

If gotcha is all you’ve got, then you’ve got nothing. - Paul Krugman
Mad Poster
#14 Old 10th Aug 2010 at 7:23 PM
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.
1978 gallons of pancake batter
#15 Old 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.
Something like that can happen if code "manually" instatiates an interaction instance and adds it to a sim's queue like in the MakeSimGoHome (or whatever) method.

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 Old 10th Aug 2010 at 9:15 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. 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.
Back to top