juso40 / bl2sdk_Mods

MIT License
45 stars 104 forks source link

BSABT: mod doesn't save current save/spawn location properly #44

Open Frosted-Ink opened 5 months ago

Frosted-Ink commented 5 months ago

idk why, but when i go save in the nearest place possible (like how you would save your respawn at the door in ore chasm in order to farm the Fibber quickly), it just takes me back to the nearest FT station instead, so i have to disable it in order to do that. the rest works like a charm, but this one thing is pretty annoying to put up with, so much so that i have to disable it in order to do it, as i'm in read-only farming at the moment. is there anything that could be done to fix it?

juso40 commented 5 months ago

I'm still waiting for the SDK to update before updating/working on any mods. I don't feel motivated currently to invest more time in my current mods.

Frosted-Ink commented 2 months ago

I'm still waiting for the SDK to update before updating/working on any mods. I don't feel motivated currently to invest more time in my current mods.

i see, no worries though, i'm not impatient on this way, the mod is good as it is

CtrlAltCuteness commented 2 months ago

As I look at this issue, it seems like it might be related to issue #50 (where I get forcibly relocated whenever someone else joins or gets revived at the last active fast travel / respawn location).

BelowNegativeIQ commented 1 week ago

I used chat gpt and a lot of trail and error. I just made it an option where you can toggle in game whether you want to use the default spawn or the better spawns. Just replace the init file with the code below.

from unrealsdk import *

import os

from . import travel
from . import betterspawns
from ..ModMenu import SDKMod, EnabledSaveType, Keybind, ModTypes, OptionManager, RegisterMod

class Main(SDKMod):
    Name: str = "BSABT"
    Description: str = "<B><U><font size='14' color='#e8131d'>Better Spawns and Better Travel</font></U></B>\n" \
                       "This Mod reimplements some of the BL3 QoL features," \
                       " such as spawning at the last respawn station " \
                       "you triggered in game," \
                       " allowing you to open the FT list from anywhere and directly spawning in " \
                       "your car or near a FT Station directly from the map menu." \
                       " To teleport in your car or near a FT " \
                       "simply place and remove a waypoint near the car/FT on your map." \
                       " To open the FT menu press the (by " \
                       "default) F1 key."
    Author: str = "Juso"
    Version = "1.2.0"

    Types: ModTypes = ModTypes.Utility
    SaveEnabledState: EnabledSaveType = EnabledSaveType.LoadWithSettings

    Keybinds = [Keybind("Show FT", "F1")]

    def __init__(self):
        super().__init__()

        self.FILE_PATH = os.path.dirname(os.path.realpath(__file__))
        self.Travel = travel.MapFT()
        self.Spawns = betterspawns.Spawns(self.FILE_PATH)

        # Add a toggle option for Better Spawns with saved state
        self.spawns_enabled_option = OptionManager.Options.Boolean(
            "Enable Better Spawns", 
            "Toggle the Better Spawns functionality on or off.", 
            True  # Default state (True = enabled)
        )

        # Register options to ensure the toggle is saved and loaded
        self.Options = [self.spawns_enabled_option]

    def GameInputPressed(self, input):
        self.Travel.GameInputPressed(input)

    def Enable(self):
        self.Travel.Enable()

        # Enable or disable Spawns based on the saved value of the toggle
        if self.spawns_enabled_option.CurrentValue:
            self.Spawns.Enable()
        else:
            self.Spawns.Disable()

    def Disable(self):
        self.Travel.Disable()
        self.Spawns.Disable()

    def ModOptionChanged(self, option, new_value):
        # Handle enabling/disabling of Better Spawns based on the toggle mid-session
        if option == self.spawns_enabled_option:
            if new_value:
                self.Spawns.Enable()
            else:
                self.Spawns.Disable()

        # The changes will automatically be saved by OptionManager, no need for extra save handling.

RegisterMod(Main())