ok this works flawlessly except no saved variables and resets upon relodui/relog. So what i need help with is where to put this stuff to save and retrieve the data and not try to save a nil value:
Code:
RidinDirty.savedVariables = ZO_SavedVariables:NewAccountWide( RidinDirty.svName, RidinDirty.variableVersion, GetWorldName(), { lastMountOwner = nil }, nil, nil)
current code working with saved variables/initilize commented out:
Code:
RidinDirty = {}
RidinDirty.svName = "RidinDirtyVars" --name of the SV table.
RidinDirty.savedVariables = {} --empty SV table of my addon
--function RidinDirty.Initialize()
--RidinDirty.savedVariables = ZO_SavedVariables:NewAccountWide( RidinDirty.svName, RidinDirty.variableVersion, GetWorldName(), { lastMountOwner = nil }, nil, nil)
--end
local function OnAddOnLoaded(eventCode, addOnName)
if (addOnName ~= "RidinDirty") then return end
EVENT_MANAGER:UnregisterForEvent("RidinDirty", EVENT_ADD_ON_LOADED)
ZO_CreateStringId("SI_BINDING_NAME_MOUNT_OWNER", "Mount Owner")
ZO_CreateStringId("SI_BINDING_NAME_SAVE_MOUNT_OWNER", "Save Mount Owner")
EVENT_MANAGER:UnregisterForEvent("RidinDirty", EVENT_ADD_ON_LOADED)
--RidinDirty.Initialize()
end
--Define the function to save the target displayname below the retilce to the SavedVariables
function RidinDirty.SaveMountOwner()
local displayNameToTaxiWith = GetUnitDisplayName("reticleover")
if displayNameToTaxiWith == nil or displayNameToTaxiWith == "" then return end
RidinDirty.savedVariables.lastMountOwner = displayNameToTaxiWith
d("Saving Owner")
end
--Define the function to Mount with the last saved target
function RidinDirty.MountWithSavedOwner()
local lastMountOwner = RidinDirty.savedVariables.lastMountOwner
if lastMountOwner == nil or lastMountOwner == "" then return end
UseMountAsPassenger(lastMountOwner )
d("Mounting Owner")
end
EVENT_MANAGER:RegisterForEvent("RidinDirty", EVENT_ADD_ON_LOADED, OnAddOnLoaded)
someone please help i cant stare at this any longer!