Forum Discussion
8 years ago
Hmm. Maybe it's the injector that's the problem. Now I'm wondering if it only supports adding to a function, not overwriting anything in it.
I've never really deeply explored how it works. I probably should.
# Python function injection
# By scripthoge at ModTheSims
#
from functools import wraps
import inspect
# method calling injection
def inject(target_function, new_function):
@wraps(target_function)
def _inject(*args, **kwargs):
return new_function(target_function, *args, **kwargs)
return _inject
# decarator injection.
def inject_to(target_object, target_function_name):
def _inject_to(new_function):
target_function = getattr(target_object, target_function_name)
setattr(target_object, target_function_name, inject(target_function, new_function))
return new_function
return _inject_to
def is_injectable(target_function, new_function):
target_argspec = inspect.getargspec(target_function)
new_argspec = inspect.getargspec(new_function)
return len(target_argspec.args) == len(new_argspec.args) - 1
I've never really deeply explored how it works. I probably should.
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.14,700 PostsLatest Activity: 3 years ago
Recent Discussions
- 2 hours ago
- 2 hours ago
- 4 hours ago
- 7 hours ago
- 8 hours ago