Forum Discussion
11 years ago
Instead of overriding an entire pyo file, you can override individual classes or functions.
I can't really post sample code from another project - but I do recommend checking out the Reduce Bills script mod on ModTheSims - two files, injector.pyo (which seems to be a decent base for doing this) and the actual mod itself.
If I'm reading the decompiled code correctly, the mod is a copy and paste of Maxis code with * 0.1 at the end and it simply replaces the function Bills.get_bill_amount.
I couldn't help but notice however that instead of "function ( self )", it's function (original,self). If you had access to the 'original' object, you don't need to paste the Maxis code. Pretty sure that Bill Reduction mod can actually be done in 4 lines - something like:
Using that method, assuming it works (as I said, I've been lazy), would mean multiple mods could modify the same class and/or even the same function plus Maxis updates would still be applied. Cruicial if you were working with something like sim_info or sim.py!
(this post is intended as food for thought - taken from observations)
I can't really post sample code from another project - but I do recommend checking out the Reduce Bills script mod on ModTheSims - two files, injector.pyo (which seems to be a decent base for doing this) and the actual mod itself.
If I'm reading the decompiled code correctly, the mod is a copy and paste of Maxis code with * 0.1 at the end and it simply replaces the function Bills.get_bill_amount.
I couldn't help but notice however that instead of "function ( self )", it's function (original,self). If you had access to the 'original' object, you don't need to paste the Maxis code. Pretty sure that Bill Reduction mod can actually be done in 4 lines - something like:
@
def political_joke_function_name_but_it_made_me_laugh( original, self)
bills = original.get_bill_amount()
return bills*0.1
Using that method, assuming it works (as I said, I've been lazy), would mean multiple mods could modify the same class and/or even the same function plus Maxis updates would still be applied. Cruicial if you were working with something like sim_info or sim.py!
(this post is intended as food for thought - taken from observations)
About The Sims 4 Mods & Custom Content
Find expert tips, troubleshooting help, tutorials for mods and custom content, and The Sims 4 patch files in our forum.15,595 PostsLatest Activity: 49 seconds ago
Community Highlights
Recent Discussions
- 2 minutes ago
- 3 minutes ago
- 4 minutes ago
- 5 minutes ago