Post by alexcroft on Feb 15, 2021 6:50:11 GMT -5
Hi all! I hope you can help me scripting my mod.
I need to overwrite the function _get_ladder_portal_locations in routing.portals.build_ladders_mixin._BuildLaddersMixin with my own function.
I've tried with levelup.gitconnected.com/the-sims-4-modern-python-modding-part-1-setup-83d1a100c5f6 methods and with injector methods. But the game give me an error:
132:b1b5be8c:384ebc3 The game failed to load
I've tried with the injector to override the function with the original one to test if the problem were my tweaks. But the game me the error anyway.
is there something i'm missing in the injection function?
The script code used is this:
I need to overwrite the function _get_ladder_portal_locations in routing.portals.build_ladders_mixin._BuildLaddersMixin with my own function.
I've tried with levelup.gitconnected.com/the-sims-4-modern-python-modding-part-1-setup-83d1a100c5f6 methods and with injector methods. But the game give me an error:
132:b1b5be8c:384ebc3 The game failed to load
I've tried with the injector to override the function with the original one to test if the problem were my tweaks. But the game me the error anyway.
is there something i'm missing in the injection function?
The script code used is this:
from routing import Location
from routing.portals.portal_enums import PortalAlignment
from routing.portals.portal_tuning import PortalFlags
import routing
import routing.portals.build_ladders_mixin
import injector
@injector.inject_to(routing.portals.build_ladders_mixin._BuildLaddersMixin, '_get_ladder_portal_locations')
def my_get_ladder_portal_locations(original, self, obj):
additional_portal_flags = self._get_additional_portal_location_flags()
blocked_alignment_flags = routing.get_blocked_ladder_portals(obj.id, obj.zone_id)
if blocked_alignment_flags & PortalAlignment.get_bit_flag(self.portal_alignment):
return [
(
None, None, None, None, PortalFlags.DEFAULT)]
else:
top_level, bottom_level, _ = routing.get_ladder_levels_and_height(obj.id, obj.zone_id)
down_start = self.climb_down_locations.location_start(obj, override_level=top_level)
down_end = self.climb_down_locations.location_end(obj, override_level=bottom_level)
down_start_position = down_start.position
down_start_routing_surface = routing.SurfaceIdentifier(obj.zone_id, top_level, down_start.routing_surface.type)
down_end_routing_surface = routing.SurfaceIdentifier(obj.zone_id, bottom_level, down_end.routing_surface.type)
if self.climb_up_locations is not None:
up_start = self.climb_up_locations.location_start(obj, override_level=bottom_level)
up_end = self.climb_up_locations.location_end(obj, override_level=top_level)
up_end_position = up_end.position
up_start_routing_surface = routing.SurfaceIdentifier(obj.zone_id, bottom_level, up_start.routing_surface.type)
up_end_routing_surface = routing.SurfaceIdentifier(obj.zone_id, top_level, up_end.routing_surface.type)
locations = [
(
Location((up_start.position), orientation=(up_start.orientation), routing_surface=up_start_routing_surface),
Location(up_end_position, orientation=(up_end.orientation), routing_surface=up_end_routing_surface),
Location(down_start_position, orientation=(down_start.orientation), routing_surface=down_start_routing_surface),
Location((down_end.position), orientation=(down_end.orientation), routing_surface=down_end_routing_surface),
additional_portal_flags)]
else:
locations = [
(
Location(down_start_position, orientation=(down_start.orientation), routing_surface=down_start_routing_surface),
Location((down_end.position), orientation=(down_end.orientation), routing_surface=down_end_routing_surface),
None, None, additional_portal_flags)]
return locations