cecell icon

Untitled

cecell | PRO | 05/26/21 08:46:12 PM UTC | 0 ⭐ | 289 👁️ | Never ⏰ | []
Lua |

133.73 KB

|

None

|

0 👍

/

0 👎

Scriptname cm_EtherealIncarnationMCM extends SKI_ConfigBase
 
Actor Property playerRef Auto
Actor objActor
ActorBase objActorBase
ObjectReference playerObj
Bool _toggleState011
Bool _toggleState012
Bool _toggleState013
Bool _toggleState014
Bool _toggleState015
Bool _toggleState016
Bool _toggleState017
Bool _toggleState08
Bool _toggleState09
Bool _toggleState10
Bool _toggleState11
Bool _toggleState12
Bool _toggleState13
Bool _toggleState14
Bool _toggleState15
Bool _toggleState16
Bool _toggleState018
Bool booksFilePathExists
Bool booksMasterInstalled
Bool cUInstalled
Bool depositWarning
Bool dontTouchFilePathExists
Bool isScriptRunning
Bool loseSomeWeightInstalled
Bool po3ExtenderInstalled
Bool settingsfilepathExists
Bool terminateVar = false
Bool toolScriptPathExists
Float progressBarProgress
Form goldVar1
Form objOwner
Int __storedAlchemy
Int __storedAlteration
Int __storedBlock
Int __storedBooksRead
Int __storedCarryWeight
Int __storedConjuration
Int __storedContainerItems
Int __storedDestruction
Int __storedDragonSouls
Int __storedEnchanting
Int __storedHealth
Int __storedHeavyArmor
Int __storedIllusion
Int __storedInventoryItems
Int __storedLevel
Int __storedLightArmor
Int __storedLockpicking
Int __storedMagicka
Int __storedMarksman
Int __storedOneHanded
Int __storedPerkPoints
Int __storedPickpocket
Int __storedRestoration
Int __storedShouts
Int __storedSmithing
Int __storedSneak
Int __storedSpeechcraft
Int __storedSpells
Int __storedStamina
Int __storedTwoHanded
Int __storedWordsOfPower
Int _addPerkPoint
Int _cloudAmmo
Int _cloudArmor
Int _cloudBooks
Int _cloudIngestibles
Int _cloudIngredients
Int _cloudMisc
Int _cloudScrolls
Int _cloudSoulGems
Int _cloudWeapons
Int _depArmor
Int _depBooks
Int _depCloud
Int _depEverything
Int _depIndiscriminatelyEverything
Int _depIngestibles
Int _depIngredients
Int _depMisc
Int _depSoulGems
Int _depWeapons
Int _displayCloudContainerItemQty
Int _displayCurInventoryItemQty
Int _displayCurrentAlchemy
Int _displayCurrentAlteration
Int _displayCurrentArchery
Int _displayCurrentBlock
Int _displayCurrentCarryWeight
Int _displayCurrentConjuration
Int _displayCurrentDestruction
Int _displayCurrentEnchanting
Int _displayCurrentHealth
Int _displayCurrentHeavyArmor
Int _displayCurrentIllusion
Int _displayCurrentLevel
Int _displayCurrentLightArmor
Int _displayCurrentLockpicking
Int _displayCurrentMagicka
Int _displayCurrentNumBooksRead
Int _displayCurrentNumDragonSouls
Int _displayCurrentNumMapMarkers
Int _displayCurrentNumPerkPoints
Int _displayCurrentOneHanded
Int _displayCurrentPickpocket
Int _displayCurrentRestoration
Int _displayCurrentShouts
Int _displayCurrentSmithing
Int _displayCurrentSneak
Int _displayCurrentSpeech
Int _displayCurrentSpells
Int _displayCurrentStamina
Int _displayCurrentTwoHanded
Int _displayCurrentWordsOfPower
Int _displayStoredAlchemy
Int _displayStoredAlteration
Int _displayStoredArchery
Int _displayStoredBlock
Int _displayStoredCarryWeight
Int _displayStoredConjuration
Int _displayStoredContainerItemQty
Int _displayStoredDestruction
Int _displayStoredEnchanting
Int _displayStoredHealth
Int _displayStoredHeavyArmor
Int _displayStoredIllusion
Int _displayStoredInventoryItemQty
Int _displayStoredLevel
Int _displayStoredLightArmor
Int _displayStoredLockpicking
Int _displayStoredMagicka
Int _displayStoredNumBooksRead
Int _displayStoredNumDragonSouls
Int _displayStoredNumMapMarkers
Int _displayStoredNumPerkPoints
Int _displayStoredOneHanded
Int _displayStoredPickpocket
Int _displayStoredRestoration
Int _displayStoredShouts
Int _displayStoredSmithing
Int _displayStoredSneak
Int _displayStoredSpeech
Int _displayStoredSpells
Int _displayStoredStamina
Int _displayStoredTwoHanded
Int _displayStoredWordsOfPower
Int _emptyContainer
Int _isAQuestItem
Int _isAQuestNPC
Int _isTargetEssential = -1
Int _isTargetProtected = -1
Int _itemGoldValue
Int _keymapOID_K
Int _loadContainer
Int _loadInventory
Int _loadReadBooks
Int _loadSkills
Int _loadSpells
Int _lswAmmo
Int _lswBooks
Int _lswIngestibles
Int _lswIngredients
Int _lswMisc
Int _lswScrolls
Int _lswSoulGems
Int _noFileContainer
Int _noFileInventory
Int _noFileSkills
Int _noFileSpells
Int _notShowOnStealthMeter
Int _noticeFavoriteEquipped
Int _progressBar
Int _progressBarTitle
Int _removePerkPoint
Int _restoreMapMarkers
Int _saveContainer
Int _saveInventory
Int _saveMapMarkers
Int _saveReadBooks
Int _saveSkills
Int _saveSpells
Int _scrollDownToAssignCloudContainer
Int _setCloud
Int _testingOption1
Int _testingOption2
Int _testingOption3
Int _testingOption4
Int _testingOption5
Int _testingOption6
Int _toggleEssential
Int _toggleProtected
Int _wdArmor
Int _wdBooks
Int _wdIngestibles
Int _wdIngredients
Int _wdMisc
Int _wdSoulGems
Int _wdTest
Int _wdWeapons
Int adamantInstalled
Int consoleUtilWarning = 0
Int filesCheckedYet = -1
Int isAContainer = -1
Int isCCAssigned = -1
Int isPlayerOwner = -1
Int isThisTheCC = -1
Int myKeyMapVar = -1
Int numItemsCC = -1
Int numPlayerItems = -1
Int objIsActor = -1
Int objIsOwned = -1
Int objOwnedByPlayer = -1 
Int objType
Int ordinatorInstalled
Int perkModInstalled
Int perkusMaximusInstalled
Int playerAlchemy
Int playerAlteration
Int playerBlock
Int playerCarryWeight
Int playerConjuration
Int playerDestruction
Int playerEnchanting
Int playerHealth
Int playerHeavyArmor
Int playerIllusion
Int playerLevel
Int playerLevelXP
Int playerLightArmor
Int playerLockpicking
Int playerMagicka
Int playerMarksman
Int playerOneHanded
Int playerPerkPoints
Int playerPickpocket
Int playerRestoration
Int playerSmithing
Int playerSneak
Int playerSpeechcraft
Int playerStamina
Int playerTotalPerkPoints
Int playerTwoHanded
Int progressVarIndex
Int smithingPerksOverhaulInstalled
Int testVar
Int vokriiInstalled
Int[] ccDepositTypeCodes
Int[] typeCodes
ObjectReference objFoc
String booksFilePath
String dontTouchFilePath
String filePath
String progressVar
String progressVar2
String settingsfilepath
String testStringVar
String[] Pages
String[] magicMods
String[] magicMods0
String[] modsToSkipItems
String[] modsToSkipSpells
String[] skillArray
Int _containerPicker
String[] containerList
Int currentMenuOption = 0
String[] multiContainerNameToIndex
Int _multiContainerSelect
Int _multiContainerAdd
Int _multiContainerRename
Int _multiContainerSave
Int _multiContainerLoad
;Int _multiInventoryLoad
Int _multiContainerDelete
Int _multiContainerNumberOf
Int _lswQuestItems
Bool isLeveledActorBase = false
 
;Menu layout
event OnPageReset(String page)
  
  SetCursorFillMode(TOP_TO_BOTTOM)
  if !po3ExtenderInstalled
    AddTextOption("Powerofthree's Papyrus Extender", "", OPTION_FLAG_DISABLED)
    AddTextOption("is required but isn't installed!", "", OPTION_FLAG_DISABLED)
    AddEmptyOption()
    AddTextOption("Download and install for functionality!", "", OPTION_FLAG_DISABLED)
    AddTextOption("nexusmods.com/skyrimspecialedition/mods/22854", "", OPTION_FLAG_DISABLED)
    return
  endif
 
  if objIsActor == -1
    EvaluateTarget()
  endif
  
  if (page == "" || page == "Inventory")
  
  ; COLUMN 1 - DEPOSIT & ASSIGN
    SetTitleText("Scroll down to see all options!")
    AddHeaderOption("Deposit")
      _depArmor = AddTextOption("Armor", "", OPTION_FLAG_NONE)
      _depWeapons = AddTextOption("Weapons", "", OPTION_FLAG_NONE)
      _depIngestibles = AddTextOption("Ingestibles: Food, Drink, Potions", "", OPTION_FLAG_NONE)
      _depIngredients = AddTextOption("Alchemy Ingredients", "", OPTION_FLAG_NONE)
      _depBooks = AddTextOption("Books", "", OPTION_FLAG_NONE)
      _depSoulGems = AddTextOption("Soul Gem", "", OPTION_FLAG_NONE)
      _depMisc = AddTextOption("Misc: Ore, Ingots, Junk", "", OPTION_FLAG_NONE)
      _depEverything = AddTextOption("All Except Equipped and Favorited", "", OPTION_FLAG_NONE)
      _depIndiscriminatelyEverything = AddTextOption("DUMP IT ALL NOW", "", OPTION_FLAG_NONE)
      AddEmptyOption()
      
      if isCCAssigned > 0
        ;_scrollDownToAssignCloudContainer = AddTextOption("", "Scroll down to assign", OPTION_FLAG_HIDDEN)
        _depCloud = AddTextOption("Begin Cloud Deposit", "", OPTION_FLAG_NONE)
        AddHeaderOption("")
        _displayCloudContainerItemQty = AddTextOption("Items in Cloud Container:", numItemsCC, OPTION_FLAG_NONE)
        ;SetTextOptionValue(_displayCloudContainerItemQty,numItemsCC)
      else
        ;_scrollDownToAssignCloudContainer = AddTextOption("", "", OPTION_FLAG_HIDDEN)
        _depCloud = AddTextOption("Begin Cloud Deposit", "", OPTION_FLAG_DISABLED)
        AddHeaderOption("")
        _displayCloudContainerItemQty = AddTextOption("Items in Cloud Container:", "Unassigned", OPTION_FLAG_NONE)
        ;SetTextOptionValue(_displayCloudContainerItemQty,"Unassigned")        
      endif
      _keymapOID_K = AddKeyMapOption("Cloud Deposit Hotkey", myKeyMapVar)
      AddEmptyOption()
      AddEmptyOption()
      AddEmptyOption()
    AddHeaderOption("Assign Cloud Container")
      if isAContainer < 1
        _setCloud = AddTextOption("<font color='#FF0000'>Not a valid container</font>", "", OPTION_FLAG_NONE)
      elseif objOwnedByPlayer < 1
        _setCloud = AddTextOption("<font color='#FF0000'>Container not owned by Player</font>", "", OPTION_FLAG_NONE)
      elseif isCCAssigned < 1
        _setCloud = AddTextOption("Cloud Container", "<font color='#00FF00'>Assign</font>", OPTION_FLAG_NONE)
      elseif isThisTheCC > 0
        _setCloud = AddTextOption("Cloud Container", "<font color='#FFFF00'>Unassign</font>", OPTION_FLAG_NONE)
      elseif isCCAssigned > 0
        _setCloud = AddTextOption("Cloud Container", "<font color='#FFFF00'>Reassign</font>", OPTION_FLAG_NONE)
      else
        _setCloud = AddTextOption("Cloud Container", "<font color='#BBBBBB'>N/A</font>", OPTION_FLAG_NONE)
      endif
      
  ; COLUMN 2 - WITHDRAW & PROGRESS BAR
    SetCursorPosition(1)
    
    AddHeaderOption("Withdraw")
      _wdArmor = AddTextOption("Armor", "")
      _wdWeapons = AddTextOption("Weapons", "")
      _wdIngestibles = AddTextOption("Ingestibles: Food, Drink, Potions", "", OPTION_FLAG_NONE)
      _wdIngredients = AddTextOption("Alchemy Ingredients", "", OPTION_FLAG_NONE)
      _wdBooks = AddTextOption("Books", "", OPTION_FLAG_NONE)
      _wdSoulGems = AddTextOption("Soul Gem", "", OPTION_FLAG_NONE)
      _wdMisc = AddTextOption("Misc: Ore, Ingots, Junk", "", OPTION_FLAG_NONE)
      AddEmptyOption()
    AddHeaderOption("Progress-Exit all Menus to Cancel")
      _progressBarTitle = AddTextOption("", "", OPTION_FLAG_NONE)
      _progressBar = AddTextOption("", "", OPTION_FLAG_NONE)
      AddEmptyOption()
      AddEmptyOption()
      AddEmptyOption()
      AddEmptyOption()
      AddEmptyOption()
      AddEmptyOption()
    AddHeaderOption("ACHTUNG BABY! - <font color='#FFFF00'>Destroy Contents!</font>")
      if isAContainer > 0
        _emptyContainer = AddTextOption("<font color='#FFFF00'>Container has:</font>", ObjFoc.GetNumItems() + " items", OPTION_FLAG_NONE)
      else
        _emptyContainer = AddTextOption("<font color='#FF0000'>Target a valid container!</font>", "", OPTION_FLAG_NONE)
      endif
      
  elseif (page == "Transcription")
    SetTitleText("Exit all Menus to Cancel (Data will be Incomplete!)")
  ; COLUMN 1
    AddHeaderOption("Player Skills, Stats and Perk Points")
      _saveSkills = AddTextOption("Save", "", OPTION_FLAG_NONE)
      _loadSkills = AddTextOption("   Restore", "", OPTION_FLAG_NONE)
 
    AddHeaderOption("Spells, Shouts, Words of Power, Dragon Souls")
      _saveSpells = AddTextOption("Save", "", OPTION_FLAG_NONE)
      _loadSpells = AddTextOption("   Restore", "", OPTION_FLAG_NONE)
    
    AddHeaderOption("Player Inventory")
      _saveInventory = AddTextOption("Save", "", OPTION_FLAG_NONE)
      _loadInventory = AddTextOption("   Restore", "", OPTION_FLAG_NONE)
      
    AddHeaderOption("Contents of Targeted Container")
      _saveContainer = AddTextOption("Save", "", OPTION_FLAG_NONE)
      _loadContainer = AddTextOption("   Restore", "", OPTION_FLAG_NONE)
      
  ; COLUMN 2
    SetCursorPosition(1)
  
    AddHeaderOption("Map Markers")
      _saveMapMarkers = AddTextOption("Save", "", OPTION_FLAG_NONE)
      _restoreMapMarkers = AddTextOption("   Restore", "", OPTION_FLAG_NONE)
 
    AddHeaderOption("List of Books Read")
      _saveReadBooks = AddTextOption("Save", "", OPTION_FLAG_NONE)
      _loadReadBooks = AddTextOption("   Restore", "", OPTION_FLAG_NONE)
      AddEmptyOption()
      AddEmptyOption()
      AddEmptyOption()
    AddHeaderOption("Progress (Exit all Menus to Cancel)")
      _progressBarTitle = AddTextOption("", "", OPTION_FLAG_NONE)
      _progressBar = AddTextOption("", "", OPTION_FLAG_NONE)
    AddEmptyOption()
    AddEmptyOption()
    AddEmptyOption()
    AddEmptyOption()
    AddEmptyOption()
    AddHeaderOption("Tsk tsk tsk - Available Perk Points: " + playerPerkPoints)
      _addPerkPoint = AddTextOption("Add one perk point", "", OPTION_FLAG_NONE)  ;   WILL NEED TO BE UPDATED
      _removePerkPoint = AddTextOption("Remove one perk point", "", OPTION_FLAG_NONE)  ;   WILL NEED TO BE UPDATED
 
; DISPLAY PLAYER DATA
  elseif (page == "Stored Data")
 
    SetTitleText("Data on left is ready to restore")
    
  ; COLUMN 1 STORED INFO
    AddHeaderOption("Stored Player Stats")
      _displayStoredLevel = AddTextOption("Level:", __storedLevel, OPTION_FLAG_NONE)
      _displayStoredHealth = AddTextOption("Health:", __storedHealth, OPTION_FLAG_NONE)
      _displayStoredMagicka = AddTextOption("Magicka: ",__storedMagicka, OPTION_FLAG_NONE)
      _displayStoredStamina = AddTextOption("Stamina:",__storedStamina, OPTION_FLAG_NONE)
      _displayStoredSpells = AddTextOption("Spells:",__storedSpells, OPTION_FLAG_NONE)
      _displayStoredNumPerkPoints = AddTextOption("Perk Points:",__storedPerkPoints, OPTION_FLAG_NONE)
      _displayStoredShouts = AddTextOption("Shouts:",__storedShouts, OPTION_FLAG_NONE)
      ;_displayStoredWordsOfPower = AddTextOption("Words of Power:",__storedMagicka, OPTION_FLAG_NONE)
      ;_displayStoredNumDragonSouls = AddTextOption("Dragon Souls:",__storedMagicka, OPTION_FLAG_NONE)
      _displayStoredOneHanded = AddTextOption("One Handed:",__storedOneHanded, OPTION_FLAG_NONE)
      _displayStoredTwoHanded = AddTextOption("Two Handed:",__storedTwoHanded, OPTION_FLAG_NONE)
      _displayStoredArchery = AddTextOption("Archery:",__storedMarksman, OPTION_FLAG_NONE)
      _displayStoredBlock = AddTextOption("Block:",__storedBlock, OPTION_FLAG_NONE)
      _displayStoredSmithing = AddTextOption("Smithing:",__storedSmithing, OPTION_FLAG_NONE)
      _displayStoredHeavyArmor = AddTextOption("Heavy Armor:",__storedHeavyArmor, OPTION_FLAG_NONE)
      _displayStoredLightArmor = AddTextOption("Light Armor:",__storedLightArmor, OPTION_FLAG_NONE)
      _displayStoredPickpocket = AddTextOption("Pickpocket:",__storedPickpocket, OPTION_FLAG_NONE)
      _displayStoredLockpicking = AddTextOption("Lockpicking:",__storedLockpicking, OPTION_FLAG_NONE)
      _displayStoredSneak = AddTextOption("Sneak:",__storedSneak, OPTION_FLAG_NONE)
      _displayStoredAlchemy = AddTextOption("Alchemy:",__storedAlchemy, OPTION_FLAG_NONE)
      _displayStoredSpeech = AddTextOption("Speech:",__storedSpeechcraft, OPTION_FLAG_NONE)
      _displayStoredAlteration = AddTextOption("Alteration:",__storedAlteration, OPTION_FLAG_NONE)
      _displayStoredConjuration = AddTextOption("Conjuration:",__storedConjuration, OPTION_FLAG_NONE)
      _displayStoredDestruction = AddTextOption("Destruction:",__storedDestruction, OPTION_FLAG_NONE)
      _displayStoredIllusion = AddTextOption("Illusion:",__storedIllusion, OPTION_FLAG_NONE)
      _displayStoredRestoration = AddTextOption("Restoration:",__storedRestoration, OPTION_FLAG_NONE)
      _displayStoredEnchanting = AddTextOption("Enchanting:",__storedEnchanting, OPTION_FLAG_NONE)
      _displayStoredCarryWeight = AddTextOption("Carry Weight:",__storedCarryWeight, OPTION_FLAG_NONE)
      ;_displayStoredNumMapMarkers = AddTextOption("Map Markers:",__storedMagicka, OPTION_FLAG_NONE)
    AddHeaderOption("Stored Misc Stats")
      _displayStoredInventoryItemQty = AddTextOption("Inventory Items:",__storedInventoryItems, OPTION_FLAG_NONE)
      _displayStoredNumBooksRead = AddTextOption("Books Read:",__storedBooksRead, OPTION_FLAG_NONE)
 
  ; COLUMN 2
    SetCursorPosition(1)
    AddHeaderOption("Currently Active Player Data (Base)")
      _displayStoredLevel = AddTextOption("Level:",LessThanRedText(playerLevel, __storedLevel), OPTION_FLAG_NONE)
      _displayCurrentHealth = AddTextOption("Health:",LessThanRedText(playerHealth,__storedHealth), OPTION_FLAG_NONE)
      _displayCurrentMagicka = AddTextOption("Magicka: ",LessThanRedText(playerMagicka,__storedMagicka), OPTION_FLAG_NONE)
      _displayCurrentStamina = AddTextOption("Stamina:",LessThanRedText(playerStamina,__storedStamina), OPTION_FLAG_NONE)
      AddHeaderOption("")
      AddHeaderOption("")
      AddHeaderOption("")
      _displayCurrentOneHanded = AddTextOption("One Handed:",LessThanRedText(playerOneHanded,__storedOneHanded), OPTION_FLAG_NONE)
      _displayCurrentTwoHanded = AddTextOption("Two Handed:",LessThanRedText(playerTwoHanded,__storedTwoHanded), OPTION_FLAG_NONE)
      _displayCurrentArchery = AddTextOption("Archery:",LessThanRedText(playerMarksman,__storedMarksman), OPTION_FLAG_NONE)
      _displayCurrentBlock = AddTextOption("Block:",LessThanRedText(playerBlock,__storedBlock), OPTION_FLAG_NONE)
      _displayCurrentSmithing = AddTextOption("Smithing:",LessThanRedText(playerSmithing,__storedSmithing), OPTION_FLAG_NONE)
      _displayCurrentHeavyArmor = AddTextOption("Heavy Armor:",LessThanRedText(playerHeavyArmor,__storedHeavyArmor), OPTION_FLAG_NONE)
      _displayCurrentLightArmor = AddTextOption("Light Armor:",LessThanRedText(playerLightArmor,__storedLightArmor), OPTION_FLAG_NONE)
      _displayCurrentPickpocket = AddTextOption("Pickpocket:",LessThanRedText(playerPickpocket,__storedPickpocket), OPTION_FLAG_NONE)
      _displayCurrentLockpicking = AddTextOption("Lockpicking:",LessThanRedText(playerLockpicking,__storedLockpicking), OPTION_FLAG_NONE)
      _displayCurrentSneak = AddTextOption("Sneak:",LessThanRedText(playerSneak,__storedSneak), OPTION_FLAG_NONE)
      _displayCurrentAlchemy = AddTextOption("Alchemy:",LessThanRedText(playerAlchemy,__storedAlchemy), OPTION_FLAG_NONE)
      _displayCurrentSpeech = AddTextOption("Speech:",LessThanRedText(playerSpeechcraft,__storedSpeechcraft), OPTION_FLAG_NONE)
      _displayCurrentAlteration = AddTextOption("Alteration:",LessThanRedText(playerAlteration,__storedAlteration), OPTION_FLAG_NONE)
      _displayCurrentConjuration = AddTextOption("Conjuration:",LessThanRedText(playerConjuration,__storedConjuration), OPTION_FLAG_NONE)
      _displayCurrentDestruction = AddTextOption("Destruction:",LessThanRedText(playerDestruction,__storedDestruction), OPTION_FLAG_NONE)
      _displayCurrentIllusion = AddTextOption("Illusion:",LessThanRedText(playerIllusion,__storedIllusion), OPTION_FLAG_NONE)
      _displayCurrentRestoration = AddTextOption("Restoration:",LessThanRedText(playerRestoration,__storedRestoration), OPTION_FLAG_NONE)
      _displayCurrentEnchanting = AddTextOption("Enchanting:",LessThanRedText(playerEnchanting,__storedEnchanting), OPTION_FLAG_NONE)
      _displayCurrentCarryWeight = AddTextOption("Carry Weight:",LessThanRedText(playerCarryWeight,__storedCarryWeight), OPTION_FLAG_NONE)
      AddHeaderOption("")
      _displayCurInventoryItemQty = AddTextOption("Inventory Items:",playerRef.GetNumItems(), OPTION_FLAG_NONE)
      
  elseif (page == "Addons-Settings")
    SetTitleText("Additional Settings")
  ; COLUMN 1 - SETTINGS FOR LOSE SOME WEIGHT PLUGIN
    if loseSomeWeightInstalled
      AddHeaderOption("Lose Some Weight-Toggle Types", OPTION_FLAG_NONE)
      _lswScrolls = AddToggleOption("Scrolls", _toggleState011, OPTION_FLAG_NONE)
      _lswBooks = AddToggleOption("Books and Notes", _toggleState012, OPTION_FLAG_NONE)
      _lswIngredients = AddToggleOption("Alchemy Ingredients", _toggleState013, OPTION_FLAG_NONE)
      _lswMisc = AddToggleOption("Misc: Ores, Ingots, Firewood", _toggleState014, OPTION_FLAG_NONE)
      _lswAmmo = AddToggleOption("Arrows and Bolts", _toggleState015, OPTION_FLAG_NONE)
      _lswIngestibles = AddToggleOption("Food and Potions", _toggleState016, OPTION_FLAG_NONE)
      _lswSoulGems = AddToggleOption("Soul Gems ", _toggleState017, OPTION_FLAG_NONE)
      _lswQuestItems = AddToggleOption("Quest Items", _toggleState018, OPTION_FLAG_NONE)
    else
      AddHeaderOption("Lose Some Weight Not Installed", OPTION_FLAG_DISABLED)
    endif
    AddEmptyOption()
    AddEmptyOption()
    AddEmptyOption()
    AddEmptyOption()
  
  ; COLUMN 2 - CLOUD DEPOSIT OPTIONS
    SetCursorPosition(1)
    AddHeaderOption("Cloud Deposit-Toggle Types")
      _cloudScrolls = AddToggleOption("Scrolls", _toggleState08, OPTION_FLAG_NONE)
      _cloudBooks = AddToggleOption("Books", _toggleState09, OPTION_FLAG_NONE)
      _cloudIngredients = AddToggleOption("Alchemy Ingredients", _toggleState10, OPTION_FLAG_NONE)
      _cloudMisc = AddToggleOption("Misc: Ores, Ingots, Straw", _toggleState11, OPTION_FLAG_NONE)
      _cloudAmmo = AddToggleOption("Arrows and Bolts", _toggleState12, OPTION_FLAG_NONE)
      _cloudIngestibles = AddToggleOption("Food, Potions <- " + "<font color='#FF0000'>Caution!</font>", _toggleState13, OPTION_FLAG_NONE)
      _cloudSoulGems = AddToggleOption("Soul Gems ", _toggleState14, OPTION_FLAG_NONE)
      _cloudArmor = AddToggleOption("Armor", _toggleState15, OPTION_FLAG_NONE)
      _cloudWeapons = AddToggleOption("Weapons", _toggleState16, OPTION_FLAG_NONE)
      AddEmptyOption()
      _noticeFavoriteEquipped = AddTextOption("Note: Favorited/Equipped <i>Not</i> Deposited", "", OPTION_FLAG_DISABLED)
 
  elseif page == "Dev Tools"
    SetTitleText("Cell Form: " + cmlib.D2H(playerObj.GetParentCell().GetFormID()) + "    " + getCellXY())
  
  ; SET BOTH COLUMN HEADERS 
  ; COLUMN 1 - INFO ABOUT TARGETED OBJECT
    if objIsActor < 1
      SetCursorPosition(1)
      AddHeaderOption("Target valid actor for info")
      SetCursorPosition(0)
      AddHeaderOption("Targeted Object Info")
      String theObjName = ObjFoc.GetBaseObject().GetName()
      if theObjName
        AddTextOption("Name:",ObjFoc.GetBaseObject().GetName(),OPTION_FLAG_NONE)
      else
        AddTextOption("Name:","N/A",OPTION_FLAG_NONE)
      endif
      Int goldVal = ObjFoc.GetGoldValue()
      if goldVal > 0
        _itemGoldValue = AddTextOption("Gold Value:", goldVal, OPTION_FLAG_NONE)
      else
        _itemGoldValue = AddTextOption("Gold Value:", "N/A", OPTION_FLAG_NONE)
      endif
      _isAQuestItem = AddTextOption("Is a quest Item?:",PO3_SKSEFunctions.IsQuestItem(ObjFoc),OPTION_FLAG_NONE)
      AddTextOption("Pos X:",ObjFoc.GetPositionX(),OPTION_FLAG_NONE)
      AddTextOption("Pos Y:",ObjFoc.GetPositionY(),OPTION_FLAG_NONE)
      AddTextOption("Pos Z:",ObjFoc.GetPositionZ(),OPTION_FLAG_NONE)
      AddTextOption("Ang X:",ObjFoc.GetAngleX(),OPTION_FLAG_NONE)
      AddTextOption("Ang Y:",ObjFoc.GetAngleY(),OPTION_FLAG_NONE)
      AddTextOption("Ang Z:",ObjFoc.GetAngleZ(),OPTION_FLAG_NONE)
      AddTextOption("Weight:",ObjFoc.GetMass(),OPTION_FLAG_NONE)
      AddTextOption("Scale:",ObjFoc.GetScale(),OPTION_FLAG_NONE)
      ActorBase actorOwner = objFoc.GetActorOwner()
      String actorOwnerName = actorOwner.GetName()
      if actorOwnerName
        AddTextOption("Owner:",actorOwner.GetName(), OPTION_FLAG_NONE)
      endif
      Int actorOwnerFormID = actorOwner.GetFormID()
      if actorOwnerFormID
        AddTextOption("Owner Form:",cmlib.D2H(actorOwnerFormID), OPTION_FLAG_NONE)
      endif
      if objIsOwned
        Faction inheritedOwner = cmlib.GetInheritedOwner(ObjFoc)
        if inheritedOwner
          AddTextOption("Owning Faction ID:",cmlib.D2H(inheritedOwner.GetFormID()), OPTION_FLAG_NONE)
        endif
        AddTextOption("Owning Faction Name: ", "", OPTION_FLAG_NONE)
        String facName = inheritedOwner.GetName()
        if !facName || facName == ""
          AddTextOption("","Form only (no name)", OPTION_FLAG_NONE)
        else
          AddTextOption("",facName, OPTION_FLAG_NONE)
        endif
        if inheritedOwner
          Bool isInThatFaction = playerRef.IsInFaction(cmlib.GetInheritedOwner(ObjFoc))
          if isInThatFaction
            AddTextOption("Is Player in Faction?","<font color='#00FF00'>" + isInThatFaction + "</font>", OPTION_FLAG_NONE)
          else
            AddTextOption("Is Player in Faction?","<font color='#FF0000'>" + isInThatFaction + "</font>", OPTION_FLAG_NONE)
          endif
        endif
      endif
      AddEmptyOption()
    elseif objIsActor > 0
      Int spellCount = (objFoc as Actor).GetSpellCount()
      isLeveledActorBase = false
      if !spellCount
        spellCount = (objFoc as Actor).GetActorBase().GetSpellCount()
        isLeveledActorBase = false
      endif
      if !spellCount
        spellCount = (objFoc as Actor).GetLeveledActorBase().GetSpellCount()
        isLeveledActorBase = true
      endif
      SetCursorPosition(0)
      AddHeaderOption("Targeted Actor Info")
      AddTextOption("Name:",objActorBase.GetName(), OPTION_FLAG_NONE)
      _isTargetEssential = AddTextOption("Is Essential? Click-Toggle:",objActorBase.IsEssential(), OPTION_FLAG_NONE)
      _isTargetProtected = AddTextOption("Is Protected? Click-Toggle:",objActorBase.IsProtected(), OPTION_FLAG_NONE)
      _isAQuestNPC = AddTextOption("Is a quest NPC?: ",PO3_SKSEFunctions.IsVIP(ObjFoc) as String, OPTION_FLAG_NONE)
      objActor = objFoc as Actor
      AddTextOption("Relat Rank Me With Them:",playerRef.GetRelationshipRank(objActor), OPTION_FLAG_NONE)
      AddTextOption("Relat Rank Them With Me:",objActor.GetRelationshipRank(playerRef), OPTION_FLAG_NONE)
      AddTextOption("BodyWeight:",objActor.GetWeight(), OPTION_FLAG_NONE)
      AddTextOption("TotalArmorWeight:",ObjFoc.GetTotalArmorWeight(), OPTION_FLAG_NONE)
      AddTextOption("TotalItemWeight:",ObjFoc.GetTotalItemWeight(), OPTION_FLAG_NONE)
      AddTextOption("PosX:",ObjFoc.GetPositionX(), OPTION_FLAG_NONE)
      AddTextOption("PosY:",ObjFoc.GetPositionY(), OPTION_FLAG_NONE)
      AddTextOption("PosZ:",ObjFoc.GetPositionZ(), OPTION_FLAG_NONE)
      AddTextOption("AngX:",ObjFoc.GetAngleX(), OPTION_FLAG_NONE)
      AddTextOption("AngY:",ObjFoc.GetAngleY(), OPTION_FLAG_NONE)
      AddTextOption("AngZ:",ObjFoc.GetAngleZ(), OPTION_FLAG_NONE)
      _notShowOnStealthMeter = AddTextOption("<i>Toggle Ignore on Stealth Meter</i>", "", OPTION_FLAG_NONE)
    SetCursorPosition(1)
    AddHeaderOption("Targeted NPC Stats")
      AddTextOption("Level:",(objFoc as Actor).GetLevel(), OPTION_FLAG_NONE)
      AddTextOption("Health:",(objFoc as Actor).GetActorValue("Health") as Int, OPTION_FLAG_NONE)
      AddTextOption("Magicka: ",(objFoc as Actor).GetActorValue("Magicka") as Int, OPTION_FLAG_NONE)
      AddTextOption("Stamina:",(objFoc as Actor).GetActorValue("Stamina") as Int, OPTION_FLAG_NONE)
 
      AddTextOption("Spells:",spellCount, OPTION_FLAG_NONE)
      AddTextOption("One Handed:",(objFoc as Actor).GetActorValue("OneHanded") as Int, OPTION_FLAG_NONE)
      AddTextOption("Two Handed:",(objFoc as Actor).GetActorValue("TwoHanded") as Int, OPTION_FLAG_NONE)
      AddTextOption("Archery:",(objFoc as Actor).GetActorValue("Marksman") as Int, OPTION_FLAG_NONE)
      AddTextOption("Block:",(objFoc as Actor).GetActorValue("Block") as Int, OPTION_FLAG_NONE)
      AddTextOption("Smithing:",(objFoc as Actor).GetActorValue("Smithing") as Int, OPTION_FLAG_NONE)
      AddTextOption("Heavy Armor:",(objFoc as Actor).GetActorValue("HeavyArmor") as Int, OPTION_FLAG_NONE)
      AddTextOption("Light Armor:",(objFoc as Actor).GetActorValue("LightArmor") as Int, OPTION_FLAG_NONE)
      AddTextOption("Pickpocket:",(objFoc as Actor).GetActorValue("Pickpocket") as Int, OPTION_FLAG_NONE)
      AddTextOption("Lockpicking:",(objFoc as Actor).GetActorValue("Lockpicking") as Int, OPTION_FLAG_NONE)
      AddTextOption("Sneak:",(objFoc as Actor).GetActorValue("Sneak") as Int, OPTION_FLAG_NONE)
      AddTextOption("Alchemy:",(objFoc as Actor).GetActorValue("Alchemy") as Int, OPTION_FLAG_NONE)
      AddTextOption("Speech:",(objFoc as Actor).GetActorValue("Speechcraft") as Int, OPTION_FLAG_NONE)
      AddTextOption("Alteration:",(objFoc as Actor).GetActorValue("Alteration") as Int, OPTION_FLAG_NONE)
      AddTextOption("Conjuration:",(objFoc as Actor).GetActorValue("Conjuration") as Int, OPTION_FLAG_NONE)
      AddTextOption("Destruction:",(objFoc as Actor).GetActorValue("Destruction") as Int, OPTION_FLAG_NONE)
      AddTextOption("Illusion:",(objFoc as Actor).GetActorValue("Illusion") as Int, OPTION_FLAG_NONE)
      AddTextOption("Restoration:",(objFoc as Actor).GetActorValue("Restoration") as Int, OPTION_FLAG_NONE)
      AddTextOption("Enchanting:",(objFoc as Actor).GetActorValue("Enchanting") as Int, OPTION_FLAG_NONE)
      AddTextOption("Carry Weight:",(objFoc as Actor).GetActorValue("CarryWeight") as Int, OPTION_FLAG_NONE)
      AddTextOption("Inventory Items:",objFoc.GetNumItems(), OPTION_FLAG_NONE)
    else
      SetCursorPosition(0)
      AddHeaderOption("Target valid object for info")
      SetCursorPosition(1)
      AddHeaderOption("Target valid actor for info")
    endif
 
; WORKING1
  elseif page == " Containers"
    SetTitleText(" Infini-tainer ")
    SetCursorPosition(0)
    AddHeaderOption("Container Management")
    _multiContainerSelect = AddMenuOption("Containers ", containerList[currentMenuOption])
    _multiContainerNumberOf = AddTextOption("", containerList.length + " Containers Stored", OPTION_FLAG_DISABLED)
    _multiContainerAdd = AddInputOption("Add Container", "")
    _multiContainerRename = AddInputOption("Rename Container", "")
    _multiContainerSave = AddTextOption("Save Targeted Container", ObjFoc.GetNumItems() + " items")
    _multiContainerLoad = AddTextOption("Load to Target", JsonUtil.IntListCount(filePath,"containerformid" + IndexMatch(currentMenuOption)) + " items")
    ;_multiInventoryLoad = AddTextOption("Load to Inventory", "")
    AddEmptyOption()
    AddEmptyOption()
    AddEmptyOption()
    AddEmptyOption()
    _multiContainerDelete = AddTextOption("Delete Container", "")
    SetCursorPosition(19)
    AddHeaderOption("Progress-Exit all Menus to Cancel")
      _progressBarTitle = AddTextOption("", "", OPTION_FLAG_NONE)
      _progressBar = AddTextOption("", "", OPTION_FLAG_NONE)
    
  endif
 
  if !dontTouchFilePathExists
    ShowMessage("Important file missing: \" ..\\Data\\SKSE\\Plugins\\StorageUtilData\\Ethereal Incarnation\\cm_DONOTTOUCHTHIS.json\\\"! Without this file certain mods and items will not be skipped in various functions for convenience sake! To restore the file simply reinstall the mod.",false)
  endif
    
endEvent
 
 
Bool function ContainerHandler(String whatToDo, String stringValue = "", Int intValue = 0, String stringValue2 = "")
;workingch
  if whatToDo == "sort"
    containerList = PO3_SKSEFunctions.SortArrayString(containerList)
    StringArrayReplaceList(filePath, "multicontainername", containerList)
    SetTextOptionValue(_multiContainerNumberOf, containerList.length + " containers stored")
    if intValue == -1
      JsonUtil.Save(filePath)
    endif
  elseif whatToDo == "add"
    if JsonUtil.StringListHas(filePath,"multicontainernametoindex",stringValue)
      ShowMessage("A container named " + stringValue + " already exists!")
      return False
    endif
    Int firstBlank = JsonUtil.StringListFind(filePath, "multicontainernametoindex", "")
    if firstBlank >= 0
      JsonUtil.StringListSet(filePath, "multicontainernametoindex", firstBlank, stringValue)
    else
      JsonUtil.StringListAdd(filePath, "multicontainernametoindex", stringValue)
    endif
    containerList = PapyrusUtil.PushString(containerList, stringValue)
    ContainerHandler("sort","",-1)
    ShowMessage("Container " + stringValue + " has been added",False)
    
  elseif whatToDo == "delete"
    
    Int nameIndex = JsonUtil.StringListFind(filePath,"multicontainernametoindex",stringValue)
    Int nameIndex2 = JsonUtil.StringListFind(filePath,"multicontainername",stringValue)
    JsonUtil.StringListSet(filePath, "multicontainernametoindex", nameIndex, "")
    containerList[nameIndex2] = ""
    JsonUtil.StringListClear(filePath, "containerformid" + nameIndex)
    JsonUtil.StringListClear(filePath, "containeritemquantity" + nameIndex)
    JsonUtil.StringListClear(filePath, "containermodname" + nameIndex)
    ContainerHandler("sort","",-1)
    ShowMessage("Container " + stringValue + " has been deleted",False)
  elseif whatToDo == "rename"
    if JsonUtil.StringListHas(filePath,"multicontainernametoindex",stringValue2)
      return False
    endif
    Int renameIndex1 = JsonUtil.StringListFind(filePath,"multicontainernametoindex",stringValue)
    ;Int renameIndex2 = JsonUtil.StringListFind(filePath,"multicontainername",stringValue)
    JsonUtil.StringListSet(filePath, "multicontainernametoindex", renameIndex1, stringValue2)
    ;JsonUtil.StringListSet(filePath, "multicontainername", renameIndex2, stringValue2)
    Int arrayPos = containerList.Find(stringValue)
    containerList[arrayPos] = stringValue2
    ContainerHandler("sort")
    JsonUtil.Save(filePath)
    ShowMessage("Container " + stringValue + " has been renamed to " + stringValue2,False)
  endif
  return TRUE
endfunction
 
function IntArrayReplaceList(String fileNm, String listName, Int[] intArray)
  Int i = 0
  JsonUtil.IntListClear(fileNm,listName)
  while i < intArray.length
    JsonUtil.IntListAdd(fileNm,listName,intArray[i])
    i += 1
  endwhile
endfunction
 
function StringArrayReplaceList(String fileNm, String listName, String[] stringArray)
  Int i = 0
  JsonUtil.StringListClear(fileNm,listName)
  while i < stringArray.length
    JsonUtil.StringListAdd(fileNm,listName,stringArray[i])
    i += 1
  endwhile
endfunction
 
event OnOptionInputOpen(int option)
 
  if option == _multiContainerAdd
    SetInputDialogStartText("New Container Name")
  elseif option == _multiContainerRename
    SetInputDialogStartText(containerList[currentMenuOption])
  endif
endevent
 
event OnOptionInputAccept(Int option, String optionInput)
  ;add new container to list
  ;select new container in list  ; working6
  if option == _multiContainerAdd
    ContainerHandler("add",optionInput)
        SetMenuOptionValue(_multiContainerSelect, optionInput)
  elseif option == _multiContainerRename
    ContainerHandler("rename",containerList[currentMenuOption],0,optionInput)
        SetMenuOptionValue(_multiContainerSelect, optionInput)
  endif
  
endevent
 
event OnOptionMenuOpen(int option)
  
  if (option == _multiContainerSelect)
        SetMenuDialogStartIndex(currentMenuOption)
        SetMenuDialogDefaultIndex(0)
        SetMenuDialogOptions(containerList)
    endIf
    
endevent
 
 
event OnOptionMenuAccept(int a_option, int a_index)
    {Called when the user accepts a new menu entry}
  ; WORKING3
    if (a_option == _multiContainerSelect)
        currentMenuOption = a_index
        SetMenuOptionValue(a_option, containerList[currentMenuOption])
    SetTextOptionValue(_multiContainerLoad, JsonUtil.IntListCount(filePath,"containerformid" + IndexMatch(currentMenuOption)) + " items")
    endIf
endEvent
 
Int function IndexMatch(Int i, String s = "")
  if s
    return JsonUtil.StringListFind(filePath,"multicontainernametoindex",s)
  else
    return JsonUtil.StringListFind(filePath,"multicontainernametoindex",JsonUtil.StringListGet(filePath,"multicontainername",i))
  endif
endfunction
 
String function LessThanRedText(Int var1, Int var2, String s = "")
  String prefix = "<font color='#FF0000'>" 
  String suffix = "</font>"
  if !s
    s = var1 as String
  endif
  if var1 < var2
    return prefix + s + suffix
  endif
  return s
endfunction
 
function TerminateProcess()
 
  SetProgressBarTitle("Canceled by user!")
  Debug.Notification("Canceled!")
  terminateVar = false
  EnableAllOptions()
 
endfunction
 
;--------------------STAT STORAGE---------------------------------------------------
 
function loadStats()
 
  __storedLevel = JsonUtil.GetPathIntValue(filePath, ".skills.playerlevel")
  __storedHealth = JsonUtil.GetPathFloatValue(filePath, ".skills.playerhealth") as Int
  __storedMagicka = JsonUtil.GetPathFloatValue(filePath, ".skills.playermagicka") as Int
  __storedStamina = JsonUtil.GetPathFloatValue(filePath, ".skills.playerstamina") as Int
  __storedSpells = JsonUtil.IntListCount(filePath,"spellformid")
  __storedShouts = JsonUtil.IntListCount(filePath,"shoutformid")
  __storedWordsOfPower = JsonUtil.IntListCount(filePath,"wordofpowerformid")
  __storedPerkPoints = JsonUtil.GetPathIntValue(filePath, ".skills.totalperkpoints")
  __storedDragonSouls = JsonUtil.GetPathIntValue(filePath, ".shouts.dragonsouls")
  __storedOneHanded = JsonUtil.GetPathFloatValue(filePath, ".skills.OneHanded.skilllevel") as Int
  __storedTwoHanded = JsonUtil.GetPathFloatValue(filePath, ".skills.TwoHanded.skilllevel") as Int
  __storedMarksman = JsonUtil.GetPathFloatValue(filePath, ".skills.Marksman.skilllevel") as Int
  __storedBlock = JsonUtil.GetPathFloatValue(filePath, ".skills.Block.skilllevel") as Int
  __storedSmithing = JsonUtil.GetPathFloatValue(filePath, ".skills.Smithing.skilllevel") as Int
  __storedHeavyArmor = JsonUtil.GetPathFloatValue(filePath, ".skills.HeavyArmor.skilllevel") as Int
  __storedLightArmor = JsonUtil.GetPathFloatValue(filePath, ".skills.LightArmor.skilllevel") as Int
  __storedPickpocket = JsonUtil.GetPathFloatValue(filePath, ".skills.Pickpocket.skilllevel") as Int
  __storedLockpicking = JsonUtil.GetPathFloatValue(filePath, ".skills.Lockpicking.skilllevel") as Int
  __storedSneak = JsonUtil.GetPathFloatValue(filePath, ".skills.Sneak.skilllevel") as Int
  __storedAlchemy = JsonUtil.GetPathFloatValue(filePath, ".skills.Alchemy.skilllevel") as Int
  __storedSpeechcraft = JsonUtil.GetPathFloatValue(filePath, ".skills.Speechcraft.skilllevel") as Int
  __storedAlteration = JsonUtil.GetPathFloatValue(filePath, ".skills.Alteration.skilllevel") as Int
  __storedConjuration = JsonUtil.GetPathFloatValue(filePath, ".skills.Conjuration.skilllevel") as Int
  __storedDestruction = JsonUtil.GetPathFloatValue(filePath, ".skills.Destruction.skilllevel") as Int
  __storedIllusion = JsonUtil.GetPathFloatValue(filePath, ".skills.Illusion.skilllevel") as Int
  __storedRestoration = JsonUtil.GetPathFloatValue(filePath, ".skills.Restoration.skilllevel") as Int
  __storedEnchanting = JsonUtil.GetPathFloatValue(filePath, ".skills.Enchanting.skilllevel") as Int
  __storedCarryWeight = JsonUtil.GetPathFloatValue(filePath, ".skills.playercarryweight") as Int
  __storedBooksRead = JsonUtil.IntListCount(filePath, "bookformid")
  __storedInventoryItems = JsonUtil.IntListCount(filePath, "inventoryformids")
  __storedContainerItems = JsonUtil.IntListCount(filePath, "containerkeylist")
 
endfunction
 
function GetStats()
 
  playerLevel = playerRef.GetLevel()
  playerHealth = playerRef.GetBaseActorValue("Health") as Int
  playerMagicka = playerRef.GetBaseActorValue("Magicka") as Int
  playerStamina = playerRef.GetBaseActorValue("Stamina") as Int
  playerOneHanded = playerRef.GetBaseActorValue("OneHanded") as Int
  playerTwoHanded = playerRef.GetBaseActorValue("TwoHanded") as Int
  playerMarksman = playerRef.GetBaseActorValue("Marksman") as Int
  playerBlock = playerRef.GetBaseActorValue("Block") as Int
  playerSmithing = playerRef.GetBaseActorValue("Smithing") as Int
  playerHeavyArmor = playerRef.GetBaseActorValue("HeavyArmor") as Int
  playerLightArmor = playerRef.GetBaseActorValue("LightArmor") as Int
  playerPickpocket = playerRef.GetBaseActorValue("Pickpocket") as Int
  playerLockpicking = playerRef.GetBaseActorValue("Lockpicking") as Int
  playerSneak = playerRef.GetBaseActorValue("Sneak") as Int
  playerAlchemy = playerRef.GetBaseActorValue("Alchemy") as Int
  playerSpeechcraft = playerRef.GetBaseActorValue("Speechcraft") as Int
  playerAlteration = playerRef.GetBaseActorValue("Alteration") as Int
  playerConjuration = playerRef.GetBaseActorValue("Conjuration") as Int
  playerDestruction = playerRef.GetBaseActorValue("Destruction") as Int
  playerIllusion = playerRef.GetBaseActorValue("Illusion") as Int
  playerRestoration = playerRef.GetBaseActorValue("Restoration") as Int
  playerEnchanting = playerRef.GetBaseActorValue("Enchanting") as Int
  playerCarryWeight = playerRef.GetBaseActorValue("CarryWeight") as Int
 
endfunction
 
;  --------------------PROGRESS BAR--------------------------------------------------- 
 
function AdvanceProgressBar(Int progressNum,Int totalNum, Bool reverse = false)
  Int numDots = 60
  if reverse
    progressBarProgress = (((totalNum - progressNum) as Float)/(totalNum as Float))
  else
    progressBarProgress = ((progressNum as Float)/(totalNum as Float))
  endif
  Int totalDots = Math.Floor(progressBarProgress * numDots)
  String loopString = progressVar
  while progressVarIndex < totalDots
    ;if (totalDots as Float)/10 == (numDots/10)
      ;loopString = cmlib.SetNthChar(loopString,"|",progressVarIndex)
      ;loopString = cmlib.SubStringInsert(loopString,"|","x")
    ;else
      loopString = cmlib.SetNthChar(loopString,".",progressVarIndex)
      ;loopString = cmlib.SubStringInsert(loopString,".","x")
    ;endif
    progressVarIndex += 1
  endwhile
  progressVar = loopString
  SetTextOptionValue(_progressBar, progressVar)
endfunction
 
function SetProgressBarTitle(String sTitle)
  SetTextOptionValue(_progressBarTitle, sTitle)
  progressBarProgress = 0
  ;progressVar = "x                                                                                                    x"
  progressVar = "                                                               |"
  progressVarIndex = 1
  SetTextOptionValue(_progressBar, progressVar)
endfunction
 
;--------------------CLOUD CONTAINER------------------------------------------------
 
function SetCloudContainer(ObjectReference objFocus)
 
  if !cmlib.IsContainer(objFocus)
    ShowMessage("Failure! The game doesn't recognize that as a container.",False)
    return
  elseif objFocus.GetActorOwner() != playerBase && !playerRef.IsInFaction(cmlib.GetInheritedOwner(ObjFocus))
    ShowMessage("Only containers owned by the player may be assigned as the cloud container.",False)
    return
  elseif getIsCCAssigned(ObjFoc)
    if ShowMessage("This container is already assigned as the cloud container. Do you want to unassign it?")
      cm_CloudContainer09.Clear()
      SetTextOptionValue(_displayCloudContainerItemQty, "<font color='#FFFF00'>Unassigned</font>")
      SetTextOptionValue(_setCloud,"<font color='#00FF00'>Assign</font>")
      SetOptionFlags(_depCloud, OPTION_FLAG_DISABLED)
      isThisTheCC = 0
      isCCAssigned = 0
      ForcePageReset()
      return
    endif
  elseif cmlib.IsContainer(cm_CloudContainer09.GetReference()) && !getIsCCAssigned(ObjFoc) && ShowMessage("Are you sure you want to reassign the cloud container?")
    cm_CloudContainer09.ForceRefTo(objFocus)
    isCCAssigned = 1
    isThisTheCC = 1
    SetTextOptionValue(_scrollDownToAssignCloudContainer, "")
    SetOptionFlags(_scrollDownToAssignCloudContainer, OPTION_FLAG_HIDDEN)
    SetOptionFlags(_depCloud, OPTION_FLAG_NONE)
    SetTextOptionValue(_setCloud,"<font color='#FFFF00'>Unassign</font>")
  else
    cm_CloudContainer09.ForceRefTo(objFocus)
    isCCAssigned = 1
    isThisTheCC = 1
    SetOptionFlags(_depCloud, OPTION_FLAG_NONE)
    SetOptionFlags(_scrollDownToAssignCloudContainer, OPTION_FLAG_HIDDEN)
    SetTextOptionValue(_setCloud,"<font color='#FFFF00'>Unassign</font>")
    ;ForcePageReset()
  endif
 
  ;JsonUtil.Save(filePath)
  numItemsCC = cm_CloudContainer09.GetReference().GetNumItems()
  SetTextOptionValue(_displayCloudContainerItemQty, numItemsCC)
endfunction
 
Int function getIsCCAssigned(ObjectReference objFocus = None)
  if objFocus
    return (cm_CloudContainer09.GetReference() == objFocus) as Int
  elseif cm_CloudContainer09.GetReference().GetBaseObject() as Container
    return 1
  else
    return 0
  endif
endfunction
 
;--------------------SKILLS---------------------------------------------------------
 
function SaveSkills(Actor playerAct, String pathNm)
 
  if perkModInstalled && !ShowMessage("A perk point mod such as Ordinator, Vokrii, Smithing Perks Overhaul, Adamant or PerMa has been detected. This may cause unpredictable results. You can however always add and remove perk points using the buttons in the menu.\nDo you want to proceed?", True, "$Yes","$No")
    return
  elseif !ShowMessage("This will replace the stored player stats. Do you want to proceed?")
    return
  endif
 
  DisableAllOptions()
  SetProgressBarTitle("Saving stats...")
  
  Int iSkillIndex = 0
  Float curSkillLvl
  Int storedSkillVal
  ActorValueInfo avi
  Int legendaryLevel
  playerPerkPoints = Game.GetPerkPoints()
  String responseString
  String responseSuffix
  playerTotalPerkPoints = cmlib.TotalPerkPoints(PlayerAct,skillArray)
  playerLevel = playerAct.GetLevel()
  playerLevelXP = Game.GetPlayerExperience() as Int
  playerHealth = playerAct.GetBaseActorValue("Health") as Int
  playerMagicka = playerAct.GetBaseActorValue("Magicka") as Int
  playerStamina = playerAct.GetBaseActorValue("Stamina") as Int
  playerCarryWeight = playerAct.GetBaseActorValue("CarryWeight") as Int
  
; Clear existing to prepare
  JsonUtil.ClearPath(pathNm, ".skills")
 
  JsonUtil.SetPathIntValue(pathNm, ".skills.totalperkpoints", playerTotalPerkPoints)
  
  JsonUtil.SetPathIntValue(pathNm, ".skills.playerlevel", playerLevel)
  JsonUtil.SetPathFloatValue(pathNm, ".skills.playerxp", playerLevelXP)
  JsonUtil.SetPathFloatValue(pathNm, ".skills.playerhealth", playerHealth)
  JsonUtil.SetPathFloatValue(pathNm, ".skills.playermagicka", playerMagicka)
  JsonUtil.SetPathFloatValue(pathNm, ".skills.playerstamina", playerStamina)
  JsonUtil.SetPathFloatValue(pathNm, ".skills.playercarryweight", playerCarryWeight)
  iSkillIndex = 0
  
  while (iSkillIndex < 18)
    avi = ActorValueInfo.GetActorValueInfoByName(skillArray[iSkillIndex])
    curSkillLvl = playerAct.GetBaseActorValue(skillArray[iSkillIndex])
    legendaryLevel = avi.GetSkillLegendaryLevel()
    JsonUtil.SetPathFloatValue(pathNm, ".skills." + skillArray[iSkillIndex] + ".skilllevel", curSkillLvl)
    JsonUtil.SetPathIntValue(pathNm, ".skills." + skillArray[iSkillIndex] + ".legendarylevel", legendaryLevel)
    iSkillIndex += 1
  endwhile
 
  responseString = "Success, skills"
  responseSuffix = " were successfully recorded!"
  
; Confirmation
  if JsonUtil.Save(filePath)
    if playerTotalPerkPoints
      ShowMessage(responseString + " and " + playerTotalPerkPoints + " perkPoints" + responseSuffix,False)
    else
      ShowMessage(responseString + responseSuffix,False)
    endif
  else
    ShowMessage("Failure, for an unknown reason the data couldn't be written to the hard drive!",False)
  endif
  
  LoadStats()
  GetStats()
  
  EnableAllOptions()
  
endFunction
 
function LoadSkills(Actor PlayerAct, String pathNm)
 
  if perkModInstalled && !ShowMessage("A perk point mod such as Ordinator, Vokrii, Smithing Perks Overhaul or PerMa has been detected which may cause unpredictable results. Would you like to continue? (You can manually correct any miscalculations using the add/subtract function in this mod)", true, "$Yes", "$No")
    return
  elseif !ShowMessage("Are you sure you want to restore the stored skill values?")
    return
  endif
  
  if !cuInstalled && !ShowMessage("Because ConsoleUtil SSE isn't installed, your level won't be set automatically and will have to be set manually. After this process completes type this into the console:\nplayer.setlevel " + __storedLevel + "\nDo you want to proceed?",True,"$Yes","$No")
    return
  endif
  
  DisableAllOptions()
  
  Float savedSkillLvl
  Float curSkillLevel
  Float curSkillXP
  
  Int savedLegendaryLevel
  Int curLegendaryLevel
  Int numSkillsChanged = 0
  Int diff
  
  Int savedPlayerLevel = JsonUtil.GetPathIntValue(pathNm, ".skills.playerlevel")
  Int curPlayerLevel = playerAct.GetLevel()
  Float savedPlayerLevelXP = JsonUtil.GetPathFloatValue(pathNm, ".skills.playerxp")
  Float curPlayerLevelXP = Game.GetPlayerExperience()
  
  Float savedHealth = JsonUtil.GetPathFloatValue(pathNm, ".skills.playerhealth")
  Float curHealth = playerAct.GetBaseActorValue("Health")
  Float savedMagicka = JsonUtil.GetPathFloatValue(pathNm, ".skills.playermagicka")
  Float curMagicka = playerAct.GetBaseActorValue("Magicka")
  Float savedStamina = JsonUtil.GetPathFloatValue(pathNm, ".skills.playerstamina")
  Float curStamina = playerAct.GetBaseActorValue("Stamina")
  Float savedCarryWeight = JsonUtil.GetPathFloatValue(pathNm, ".skills.playercarryweight")
  Float curCarryWeight = playerAct.GetBaseActorValue("CarryWeight")
 
  if savedPlayerLevelXP >= curPlayerLevelXP
    Game.SetPlayerExperience(savedPlayerLevelXP)
  endif
 
; Player Stats
  if savedHealth >= curHealth
    playerAct.SetActorValue("Health", savedHealth)
  endif
  
  if savedMagicka >= curMagicka
    playerAct.SetActorValue("Magicka", savedMagicka)
  endif
  
  if savedStamina >= curStamina
    playerAct.SetActorValue("Stamina", savedStamina)
  endif
  
  if savedCarryWeight >= curCarryWeight
    playerAct.SetActorValue("CarryWeight", savedCarryWeight)
  endif
  
  ActorValueInfo avi
   
; Skills
  Int iSkillIndex = 0
  while (iSkillIndex < 18)
    avi = ActorValueInfo.GetActorValueInfoByName(skillArray[iSkillIndex])
    savedSkillLvl = JsonUtil.GetPathFloatValue(pathNm, ".skills." + skillArray[iSkillIndex] + ".skilllevel")
    curSkillLevel = playerAct.GetBaseActorValue(skillArray[iSkillIndex]) as Int
    curSkillXP = avi.GetSkillExperience()
    savedLegendaryLevel = JsonUtil.GetPathIntValue(pathNm, ".skills." + skillArray[iSkillIndex] + ".legendarylevel")
    curLegendaryLevel = avi.GetSkillLegendaryLevel()
    
    if savedSkillLvl >= curSkillLevel
      playerAct.SetActorValue(skillArray[iSkillIndex], savedSkillLvl)
    endif
    
    if savedLegendaryLevel >= curLegendaryLevel
      avi.SetSkillLegendaryLevel(savedLegendaryLevel)
    endif
    
    iSkillIndex += 1
  endwhile
 
; Perk Points
    Int curTtlPerkPoints = cmlib.TotalPerkPoints(PlayerAct,skillArray)
    Int savedPerkPoints = JsonUtil.GetPathIntValue(pathNm, ".skills.totalperkpoints")
    diff = savedPerkPoints - curTtlPerkPoints
    if diff > 0
      Game.ModPerkPoints(diff)
    elseif diff < 0 && ShowMessage("This character's current total perk points [" + curTtlPerkPoints + "] exceeds what is stored " + savedPerkPoints + "]! Do you want to reduce your current number of perk points to match the record?",TRUE,"$Yes","$No")
      Game.ModPerkPoints(diff)
    endif
;  endif
  
; Player Level
  ConsoleUtil.ExecuteCommand("player.setlevel " + savedPlayerLevel)
 
; Update variables containing stats
  LoadStats()
  GetStats()
  
; Confirmation
  ShowMessage("Success! Player stats have been restored.",false)
 
  EnableAllOptions()
  
endFunction
 
;--------------------SPELLS---------------------------------------------------------
 
function SaveSpells(Actor playerAct, String pathNm)
 
  if !ShowMessage("This will replace the existing spell record. Do you want to proceed? (This function takes longer than the skills function!)",true,"$Yes","$No")
    return
  endif
  
  DisableAllOptions()
  Spell[] modSpells
  
  Spell curSpell
  Shout curShout
  String nameOfMod
  Int decForm
  Int subDecForm
  String spellFullName
  String shoutFullName
  String wopFullName
  
  Int numWordsOfPower = cm_WordsOfPower.GetSize()
  Int wWoPStored = 0
  Int spellsStored = 0
  Int shoutsStored = 0
  Int wopStored = 0
  Int iModIndex = 0
  
  Int iShoutIndex = 0
  Int iWoPIndex = 0
  WordOfPower curWoP
  Int wordUnlocked
  Int wordKnown
  Form curForm
  Int numSpells
  Int numShouts = cm_Shouts.GetSize()
  String responseString
  Int numDragonSouls = PlayerAct.GetActorValue("dragonsouls") as int
  Int totalIterations = 0
  Int numMods = magicMods.length
  
  JsonUtil.ClearPath(pathNm, ".spells")
  JsonUtil.ClearPath(pathNm, ".shouts")
  JsonUtil.IntListClear(pathNm, "spellformid")
  JsonUtil.StringListClear(pathNm, "spellmodname")
  JsonUtil.IntListClear(pathNm, "shoutformid")
  JsonUtil.StringListClear(pathNm, "shoutmodname")
  JsonUtil.IntListClear(pathNm, "wordofpowerformid")
  JsonUtil.StringListClear(pathNm, "wordofpowermodname")
  
  Int iSpellIndex = 0
;/  
; Vanilla Spells
  numSpells = cm_vanillaSpells.GetSize()
  SetProgressBarTitle("Iterating " + numSpells + " vanilla spells")
  while (iSpellIndex < numSpells)
    AdvanceProgressBar(iSpellIndex,numSpells)
    curForm = cm_vanillaSpells.GetAt(iSpellIndex)
    ;curForm = curSpell as Form
    if playerRef.HasSpell(curSpell)
      nameOfMod = cmlib.GetFormModName(curForm)
      spellFullName = curForm.GetName()
      JsonUtil.IntListAdd(pathNm,"spellformid",cmlib.GetTheSubForm("",curSpell.GetFormID()),TRUE)
      JsonUtil.StringListAdd(pathNm,"spellmodname",magicMods[iModIndex],TRUE)
      ;JsonUtil.SetPathStringValue(pathNm, ".spells." + cmlib._ModName(nameOfMod) + "." + subDecForm + ".fullname", spellFullName)
      spellsStored += 1
    endif
    iSpellIndex += 1
    if terminateVar
      TerminateProcess()
      return
    endif
  endwhile/;
  
; Mod Spells
  while iModIndex < numMods
    iSpellIndex = 0
    if MiscUtil.FileExists("data/" + magicMods[iModIndex])
      modSpells = PO3_SKSEFunctions.GetAllSpellsInMod(magicMods[iModIndex],None,TRUE)
      numSpells = modSpells.length
      if numSpells > 0
        nameOfMod = magicMods[iModIndex]
        SetProgressBarTitle(numSpells + " spells: " + nameOfMod)
        while (iSpellIndex < numSpells)
          AdvanceProgressBar(iSpellIndex,numSpells)
          curSpell = modSpells[iSpellIndex]
          ;curForm = curSpell as Form
          if playerRef.HasSpell(curSpell)
            spellFullName = (curSpell as Form).GetName()
            JsonUtil.IntListAdd(pathNm,"spellformid",cmlib.GetTheSubForm("",curSpell.GetFormID()),TRUE)
            JsonUtil.StringListAdd(pathNm,"spellmodname",magicMods[iModIndex],TRUE)
            spellsStored += 1
          endif
          iSpellIndex += 1  
        endwhile
      endif
    endif
    if terminateVar
      TerminateProcess()
      return
    endif
    iModIndex += 1
  endwhile
  
; Shouts
  SetProgressBarTitle("Checking " + numShouts + " shouts...")
  while (iShoutIndex < numShouts)
    AdvanceProgressBar(iShoutIndex,numShouts)
    curForm = cm_Shouts.GetAt(iShoutIndex)
    decForm = curForm.GetFormID()
    nameOfMod = cmlib.GetFormModName(curForm)
    if modsToSkipSpells.Find(nameOfMod) == -1
      curShout = curForm as Shout
      if PlayerAct.HasSpell(curShout)
        shoutFullName = curForm.GetName()
        subDecForm = cmlib.GetTheSubForm("",decForm)
        JsonUtil.IntListAdd(pathNm,"shoutformid",subDecForm,TRUE)
        JsonUtil.StringListAdd(pathNm,"shoutmodname",nameOfMod,TRUE)
        shoutsStored += 1
      endif
    endif
    iShoutIndex += 1
    if terminateVar
      TerminateProcess()
      return
    endif
  endwhile
 
; Words of Power
  SetProgressBarTitle("Checking " + numWordsOfPower + " words of power...")
  while (iWoPIndex < numWordsOfPower)
    AdvanceProgressBar(iWoPIndex,numWordsOfPower)
    curForm = cm_WordsOfPower.GetAt(iWoPIndex)
    curWoP = curForm as WordOfPower
    decForm = curForm.GetFormID()
    wordUnlocked = Game.IsWordUnlocked(curWoP) as Int
    wordKnown = curWoP.PlayerKnows() as Int
    if wordUnlocked || wordKnown
      nameOfMod = cmlib.GetFormModName(curForm)
      subDecForm = cmlib.GetTheSubForm("",decForm)
      wopFullName = curForm.GetName()
      JsonUtil.IntListAdd(pathNm,"wordofpowerformid",subDecForm,TRUE)
      JsonUtil.StringListAdd(pathNm,"wordofpowermodname",nameOfMod,TRUE)
      JsonUtil.SetPathStringValue(pathNm, ".shouts.wordsofpower." + subDecForm + ".fullname", wopFullName)
      JsonUtil.SetPathIntValue(pathNm, ".shouts.wordsofpower." + subDecForm + ".unlocked", wordUnlocked)
      JsonUtil.SetPathIntValue(pathNm, ".shouts.wordsofpower." + subDecForm + ".known", wordKnown)
      wopStored += 1
    endif
    iWoPIndex += 1
    totalIterations += 1
 
    if terminateVar
      TerminateProcess()
      return
    endif
  endwhile
  
; Dragon souls
  JsonUtil.SetPathIntValue(pathNm, ".shouts.dragonsouls", numDragonSouls)
  
; Confirmation
  if JsonUtil.Save(filePath)
    responseString = "Success! Saved:"
    if spellsStored
      responseString = responseString + "\nSpell(s): " + spellsStored
    endif
    if shoutsStored
      responseString = responseString + "\nShout(s): " + shoutsStored
    endif
    if wopStored
      responseString = responseString + "\nWord(s) of Power: " + wopStored
    endif
    if numDragonSouls
      responseString = responseString + "\nDragon Soul(s): " + numDragonSouls
    endif
    ShowMessage(responseString,false)
  else
    ShowMessage("Failure, for an unknown reason data cannot be written to hard drive!",false)
  endif
 
  __storedSpells = spellsStored
  __storedDragonSouls = numDragonSouls
  __storedShouts = shoutsStored
  __storedWordsOfPower = wopStored
 
  EnableAllOptions()
  
endFunction
 
function LoadSpells(Actor playerAct, String pathNm)
 
  if !ShowMessage("This will add the stored spells to your character. Do you want to proceed?",TRUE,"$Yes","$No")
    return
  endif
 
  DisableAllOptions()
  
  Int subDecForm
  String nameOfMod
  Int spellsLearned = 0
  Int spellFailed = 0
  Int shoutsLearned = 0
  Int shoutsFailed = 0
  Int wWoPLearned = 0
  Int wWoPFailed = 0
  Int wWoPUnlocked = 0
  Int unKnown = 0
  Form curForm
  Spell curSpell
  Shout curShout
  WordOfPower curWoP
  Int iSpellsIndex = 0
  Int iShoutsIndex = 0
  Int iWoPIndex = 0
  Int totalIterations = 0
 
  Int totalSpells = JsonUtil.IntListCount(pathNm, "spellformid")
  Int totalShouts = JsonUtil.IntListCount(pathNm, "shoutformid")
  Int numWordsOfPower = JsonUtil.IntListCount(pathNm, "wordofpowerformid")
  Int numDragonSouls = JsonUtil.GetPathIntValue(pathNm, ".shouts.dragonsouls")
  
; Spells
  SetProgressBarTitle("Restoring " + totalSpells + " spells...")
  while iSpellsIndex < totalSpells
    AdvanceProgressBar(iSpellsIndex,totalSpells)
    subDecForm = JsonUtil.IntListGet(pathNm,"spellformid",iSpellsIndex)
    nameOfMod = JsonUtil.StringListGet(pathNm,"spellmodname",iSpellsIndex)
    curForm = Game.GetFormFromFile(subDecForm,nameOfMod)
    curSpell = curForm as Spell
    if !playerAct.HasSpell(curForm)
      if playerAct.AddSpell(curSpell, false)
        spellsLearned += 1
      else
        spellFailed += 1
      endif
    endif
    iSpellsIndex += 1
    totalIterations += 1
    if terminateVar
      TerminateProcess()
      return
    endif
  endwhile
  
; Shouts
  if totalShouts
    SetProgressBarTitle("Restoring " + totalShouts + " shouts...")
    while (iShoutsIndex < totalShouts)
      AdvanceProgressBar(iShoutsIndex,totalShouts)
      subDecForm = JsonUtil.IntListGet(pathNm, "shoutformid", iShoutsIndex)
      nameOfMod = JsonUtil.StringListGet(pathNm, "shoutmodname", iShoutsIndex)
      curForm = Game.GetFormFromFile(subDecForm,nameOfMod)
      curShout = curForm as Shout
      if !playerAct.HasSpell(curForm)
        if playerAct.AddShout(curShout)
          shoutsLearned += 1
        else
          shoutsFailed += 1
        endif
      endif
      iShoutsIndex += 1
      totalIterations += 1
      if terminateVar
        TerminateProcess()
        return
      endif
    endwhile
  endif
  
  if numWordsOfPower
    SetProgressBarTitle("Restoring " + numWordsOfPower + " words of power...")
    while (iWoPIndex < numWordsOfPower)
      AdvanceProgressBar(iWoPIndex,numWordsOfPower)
      subDecForm = JsonUtil.IntListGet(pathNm, "wordofpowerformid", iWoPIndex)
      nameOfMod = JsonUtil.StringListGet(pathNm, "wordofpowermodname", iWoPIndex)
      curForm = Game.GetFormFromFile(subDecForm,nameOfMod)
      curWoP = curForm as WordOfPower
      if JsonUtil.GetPathIntValue(pathNm,".shouts.wordsofpower." + subDecForm + ".unlocked")
        Game.UnlockWord(curWoP)
        wWoPUnlocked += 1
      endif
      if JsonUtil.GetPathIntValue(pathNm,".shouts.wordsofpower." + subDecForm + ".known")
        Game.TeachWord(curWoP)
        wWoPLearned += 1
      endif
      iWoPIndex += 1
      totalIterations += 1
      if terminateVar
        TerminateProcess()
        return
      endif
    endwhile
  endif
  
; Dragon souls
  if numDragonSouls
    
  endif
  Int numCurDragonSouls = PlayerAct.GetActorValue("dragonsouls") as int
  Int diff = numDragonSouls - numCurDragonSouls
  if diff > 0
    PlayerAct.ModActorValue("dragonsouls", diff)
  elseif diff < 0 && ShowMessage("This character currently has " + numCurDragonSouls + " dragon souls which exceeds the number stored: " + numDragonSouls + "! Do you want to reduce the number of unspent dragon souls to match what is saved?",TRUE,"$Yes","$No")
    PlayerAct.ModActorValue("dragonsouls", diff)
  endif
  
; Confirmation
  string responseString = "Success! Restored:"
  if !spellsLearned && !shoutsLearned && !wWoPUnlocked && !wWoPLearned
    ShowMessage("Player already knows all that is stored!",False)
  else
    if spellsLearned
      responseString = responseString + "\nSpells: " + spellsLearned
    endif
    if shoutsLearned
      responseString = responseString + "\nShouts: " + shoutsLearned
    endif
    if wWoPUnlocked
      responseString = responseString + "\nWords of Power: " + wWoPUnlocked + " (unlocked)"
    endif
    if wWoPLearned
      responseString = responseString + "\nWords of Power: " + wWoPLearned + " (known)"
    endif
    if numDragonSouls
      responseString = responseString + "\nDragon Souls: " + numDragonSouls
    endif
    ShowMessage(responseString,false)
  endif
  
  EnableAllOptions()
 
endFunction
 
;--------------------INVENTORY-------------------------------------------------------
 
function SaveInventory(Actor playerAct, String pathNm)
 
  if !ShowMessage("Are you sure? This will replace the existing inventory record.")
    return
  endif
  
  DisableAllOptions()
  ObjectReference refSource = playerRefAlias.GetReference()
  Form curForm
  String nameOfMod
  String formFullName
  Int itemQty
  String fullName
  Int subDecForm
  Int totalPieceCount = 0
  Int iFormIndex = 0
  Int totalIterations = 0
  Int numQuestItems = 0
  Int itemsSkipped = 0
  String[] modsSkipped
 
  PO3_SKSEFunctions.AddAllItemsToList(refSource, cm_contentsPlayerInventory, false, false, true)
  Int totalForms = cm_contentsPlayerInventory.GetSize()
    
  JsonUtil.ClearPath(pathNm,".inventory")
  JsonUtil.IntListClear(pathNm,"inventoryformid")
  JsonUtil.IntListClear(pathNm,"inventoryitemquantity")
  JsonUtil.StringListClear(pathNm,"inventorymodname")
  JsonUtil.IntListClear(pathNm,"inventoryitemequipped")
 
  JsonUtil.IntListClear(pathNm, "inventoryquestitemformid")
  JsonUtil.IntListClear(pathNm,"inventoryquestitemquantity")
  JsonUtil.StringListClear(pathNm, "inventoryquestitemmodname")
  JsonUtil.StringListClear(pathNm, "inventoryquestitemname")
  
  SetProgressBarTitle("Saving " + totalForms + " items from inventory...")
  while (iFormIndex < totalForms)
    AdvanceProgressBar(iFormIndex,totalForms)
    curForm = cm_contentsPlayerInventory.GetAt(iFormIndex)
    nameOfMod = cmlib.GetFormModName(curForm)
    if modsToSkipItems.Find(nameOfMod) < 0
      itemQty = playerAct.GetItemCount(curForm)
      formFullName = curForm.GetName()
      subDecForm = cmlib.GetTheSubForm("",curForm.GetFormID())
      if PO3_SKSEFunctions.IsQuestItem(curForm as ObjectReference)
        JsonUtil.IntListAdd(pathNm,"inventoryquestitemformid",subDecForm,TRUE)
        JsonUtil.IntListAdd(pathNm,"inventoryquestitemquantity",itemQty,TRUE)
        JsonUtil.StringListAdd(pathNm, "inventoryquestitemmodname",nameOfMod,TRUE)
        JsonUtil.StringListAdd(pathNm, "inventoryquestitemname",formFullName,TRUE)
        numQuestItems += 1
      else
        JsonUtil.IntListAdd(pathNm,"inventoryformid",subDecForm,TRUE)
        JsonUtil.IntListAdd(pathNm,"inventoryitemquantity",itemQty,TRUE)
        JsonUtil.StringListAdd(pathNm,"inventorymodname",nameOfMod,TRUE)
        JsonUtil.IntListAdd(pathNm,"inventoryitemequipped",playerAct.IsEquipped(curForm) as Int,TRUE)
      endif
      if curForm != Gold001
        totalPieceCount = totalPieceCount + itemQty
      else
        totalPieceCount = totalPieceCount + 1
      endif
    else
      itemsSkipped += 1
      modsSkipped = PapyrusUtil.PushString(modsSkipped, nameOfMod)
    endif
    iFormIndex += 1
    totalIterations += 1
    if totalIterations > (totalForms + 100)
      ShowMessage("This process seems to be malfunctioning. Terminating!",false)
      EnableAllOptions()
      return
    endif
    if terminateVar
      TerminateProcess()
      return
    endif
  endwhile
  
  if JsonUtil.Save(filePath)
    if numQuestItems
      ShowMessage("Success, " + (totalForms as Int) + " different items saved and " + numQuestItems + " different quest items saved separately!",False)
    else
      ShowMessage("Success, " + (totalForms as Int) + " different items saved!",False)
    endif
  else
    ShowMessage("Failure! For an unknown reason data was unable to be written!",False)
  endif
  if itemsSkipped
    ShowMessage("Because of rules in the settings file " + itemsSkipped + " item(s) not recorded.  Item(s) from: " + modsSkipped as String,False)
  endif
  __storedInventoryItems = totalForms as Int
  EnableAllOptions()
  
endFunction
 
function LoadInventory(Actor playerAct, String pathNm)
 
  if !ShowMessage("Are you sure you want to restore the recorded inventory items?")
    return
  endif
 
  DisableAllOptions()
  
  Int itemQty
  Int subDecForm
  String nameOfMod
  String nameOfItem
  Int isThisEquipped
  Int equipItems = 0
  Form curForm
  Int iFormIndex = 0
  Int totalIterations = 0
  Int numKeys =  JsonUtil.IntListCount(pathNm, "inventoryformid")
  Int numQuestItems = JsonUtil.IntListCount(pathNm, "inventoryquestitemformid")
  Int itemsEquipped = 0
  
  if ShowMessage("Do you want to equip the same items that were equipped when the inventory list was saved?",TRUE,"$Yes","$No")
    equipItems = 1
  endif
  
  SetProgressBarTitle("Loading " + numKeys + " different items into inventory...")
  while (iFormIndex < numKeys)
    AdvanceProgressBar(iFormIndex,numKeys)
    subDecForm = JsonUtil.IntListGet(pathNm, "inventoryformid", iFormIndex)
    itemQty = JsonUtil.IntListGet(pathNm, "inventoryitemquantity", iFormIndex)
    nameOfMod = JsonUtil.StringListGet(pathNm, "inventorymodname", iFormIndex)
 
    curForm = Game.GetFormFromFile(subDecForm, nameOfMod)
    playerAct.AddItem(curForm, itemQty, TRUE)
    
    if equipItems && JsonUtil.IntListGet(pathNm, "inventoryitemequipped", iFormIndex)
      playerAct.EquipItem(curForm,False,TRUE)
      itemsEquipped += 1
    endif
    
    iFormIndex += 1
    totalIterations += 1
    if totalIterations > (numKeys + 200)
      ShowMessage("This process seems to be malfunctioning. Terminating!",false)
      EnableAllOptions()
      return
    endif
    if terminateVar
      TerminateProcess()
      return
    endif
  endwhile
  
  ShowMessage("Success, " + numKeys + " different items loaded.",false)
    
; Quest Items
  iFormIndex = 0
  if numQuestItems < 1
    ShowMessage("No quest items are saved so there are none to review.",False)
  elseif numQuestItems > 0 && ShowMessage("Do you want to load quest items? There are " + numQuestItems + " quest items stored. If yes, the items will be shown one item at a time for review.",TRUE,"$Yes","$No")
    while iFormIndex < numQuestItems
      subDecForm = JsonUtil.IntListGet(pathNm, "inventoryquestitemformid", iFormIndex)
      itemQty = JsonUtil.IntListGet(pathNm, "inventoryquestitemquantity", iFormIndex) 
      nameOfMod = JsonUtil.StringListGet(pathNm, "inventoryquestitemmodname", iFormIndex)
      nameOfItem = JsonUtil.StringListGet(pathNm, "inventoryquestitemname", iFormIndex)
      curForm = Game.GetFormFromFile(subDecForm, nameOfMod)
      if ShowMessage("Do you want to load\nName: " + nameOfItem + "\nFrom: " + nameOfMod + "\nQty: " + itemQty + "\nFormID: " + cmlib.D2H(curForm.GetFormID()) + "\nQuantity already in inventory: " + PlayerObj.GetItemCount(curForm),TRUE,"$Yes","$No")
        playerAct.AddItem(curForm, itemQty, False)
      endif
    endwhile
  endif
  
  ShowMessage("Inventory loading process complete!",False)
  EnableAllOptions()
endFunction
 
;--------------------CONTAINER-------------------------------------------------------
 
String function SaveContainer(ObjectReference objFocus, String pathNm, Int whichOne = -2)
 
  if !cmlib.IsContainer(objFocus)
    return "Failed! This function is only for use on containers."
  elseif objFocus.GetNumItems() <= 0
    return "The targeted container has no contents to save!"
  elseif objFocus.GetItemCount(objFocus.GetNthForm(0)) == 0
    return "Open the container, close it and then try again."
  elseif !ShowMessage("This will replace the existing container record. Proceed?")
    return "Process terminated by user."
  elseif whichOne == -2 && (JsonUtil.StringListFind(filePath, "multicontainernametoindex", containerList[currentMenuOption]) < 0)
    return "This container record cannot be found."
  else
    PO3_SKSEFunctions.AddAllItemsToList(objFocus, cm_contentsChest)
  endif
  ; working5
  
  if whichOne == -2
    whichOne = IndexMatch(0,containerList[currentMenuOption])
  endif
  
  DisableAllOptions()
  
  Int itemQty
  Form curForm
  String nameOfMod
  String formFullName
  Int decForm
  Int subDecForm
  Int totalPieceCount = 0
  Int iFormIndex = 0
  Int totalForms = cm_contentsChest.GetSize()
  Int numOfItems = 0
  Int totalIterations = 0
  Int itemsSkipped = 0
  String[] modsSkipped
 
  JsonUtil.IntListClear(pathNm,"containerformid" + whichOne)
  JsonUtil.IntListClear(pathNm,"containeritemquantity" + whichOne)
  JsonUtil.StringListClear(pathNm,"containermodname" + whichOne)
  ShowMessage("cm_contentsChest: " + cm_contentsChest.GetSize() + "\nGetNumItems: " + objFocus.GetNumItems() + "\nTotalForms: " + totalForms)
  SetProgressBarTitle("Saving " + totalForms + " items...")
  while iFormIndex < totalForms
    AdvanceProgressBar(iFormIndex,totalForms)
    curForm = cm_contentsChest.GetAt(iFormIndex)
    decForm = curForm.GetFormID()
    nameOfMod = cmlib.GetFormModName(curForm)
    if modsToSkipItems.Find(nameOfMod) < 0
      itemQty = objFocus.GetItemCount(curForm)
      formFullName = curForm.GetName()
      subDecForm = cmlib.GetTheSubForm("",decForm)
      JsonUtil.IntListAdd(pathNm,"containerformid" + whichOne,subDecForm,TRUE)
      JsonUtil.IntListAdd(pathNm,"containeritemquantity" + whichOne,itemQty,TRUE)
      JsonUtil.StringListAdd(pathNm,"containermodname" + whichOne,nameOfMod,TRUE)
      if curForm != Gold001
        totalPieceCount = totalPieceCount + itemQty
      else
        totalPieceCount = totalPieceCount + 1
      endif
      numOfItems += 1
    else
      itemsSkipped += 1
      modsSkipped = PapyrusUtil.PushString(modsSkipped, nameOfMod)
    endif
    iFormIndex += 1
 
    totalIterations += 1
    if totalIterations > (totalForms + 200)
      EnableAllOptions()
      return "The process seems to be corrupted. Terminating!"
    endif
    if terminateVar
      TerminateProcess()
      return "Process terminated!"
    endif
  endwhile
 
; Confirmation
  
  if JsonUtil.Save(filePath)
    ShowMessage("Success! " + totalPieceCount + " individual pieces of " + numOfItems + " different items have been recorded.",False)
  else
    ShowMessage("Failure!  For an unknown reason data could not be written to disk!",False)
  endif
  if itemsSkipped
    ShowMessage("Because of rules in the settings file " + itemsSkipped + " item(s) were not recorded.  The item(s) were from the mod(s): " + modsSkipped as String,False)
  endif
  EnableAllOptions()
  
endFunction
 
function LoadContainer(ObjectReference objFocus, String pathNm, Int whichOne = -2)
 
  if !cmlib.IsContainer(objFocus)
    ShowMessage("The targeted object is not recognized by the game as a container!",False)
    return
  elseif !ShowMessage("Are you sure you want to fill the targeted container with the recorded items?")
    return
  endif
 
  DisableAllOptions()
 
  if whichOne == -2
    whichOne = IndexMatch(0,containerList[currentMenuOption])
  endif
  
  Int itemQty
  Int subDecForm
  String nameOfMod
  String formFullName
  Form curForm
  Int totalForms = 0
  Int iFormIndex = 0
  Int numKeys =  JsonUtil.IntListCount(pathNm, "containerformid" + whichOne)
  
  SetProgressBarTitle("Loading " + numKeys + " different items into container...")
  while (iFormIndex < numKeys)
    AdvanceProgressBar(iFormIndex,numKeys)
    subDecForm = JsonUtil.IntListGet(pathNm, "containerformid" + whichOne, iFormIndex)
    itemQty = JsonUtil.IntListGet(pathNm, "containeritemquantity" + whichOne, iFormIndex)
    nameOfMod = JsonUtil.StringListGet(pathNm, "containermodname" + whichOne, iFormIndex)
    curForm = Game.GetFormFromFile(subDecForm, nameOfMod)
    objFocus.AddItem(curForm, itemQty, TRUE)
    iFormIndex += 1
    
    if terminateVar
      TerminateProcess()
      return
    endif
  endwhile
  
  ShowMessage("Success, " + numKeys + " different items loaded into the targeted container!",False)
  
  EnableAllOptions()
  
endfunction
 
function EmptyContainer(ObjectReference objFocus)
 
  Int totalForms = objFocus.GetNumItems()
  
  if !cmlib.IsContainer(objFocus)
    ShowMessage("That isn't a container!",False)
    return
  elseif totalForms <= 0
    ShowMessage("The targeted container has no contents to destroy!",False)
    return
  elseif !ShowMessage("CAUTION: Are you sure you want to permanently destroy the " + objFoc.GetNumItems() + " items in the targeted container?")
    return
  else
    if !ShowMessage("Are you really, REALLY sure?")
      return
    endif
  endif
  
  DisableAllOptions()
  
  Int itemQty
  Form curForm
  
  Int iFormIndex = 0
  
  objFocus.RemoveAllItems()
 
  if objFocus.GetNumItems() < 1
    ShowMessage("Success, " + totalForms + " different items were successfully destroyed.",False)
  else
    ShowMessage("Unexpected failure? The targeted container does not appear to be empty.",False)
  endif
  
  EnableAllOptions()
  
endfunction
 
;--------------------DEPOSIT/WITHDRAW-------------------------------------------------------
 
String function DepStuff(ObjectReference refSource, ObjectReference refDestination, Int itemType = 0, Bool cloud = False)
 
  PO3_SKSEFunctions.AddAllItemsToList(refSource, cm_contentsPlayerInventory, true, true, true)
  Int totalForms = cm_contentsPlayerInventory.GetSize()
  if IsAContainer != 1 && !cloud
    return "Failure, target is not recognized by the game as a valid container."
  elseif totalForms < 1
    return "No items to deposit"
  elseif cloud && isCCAssigned != 1
    return "No cloud container assigned"
  endif
  
  if itemType == 99
    ShowMessage("This will dump all but quest items, proceed?")
    refSource.RemoveAllItems(refDestination,TRUE)
    return "All but quest items dumped into container indiscriminately!"
  endif
  
  DisableAllOptions()
  
  Int preTotalForms = totalForms
  Int totalPieceCount = 0
  Int itemQty
  Int itemsMoved = 0
  Int curFormType
  Form curForm
  String nameOfMod
  
  Int iFormIndex = 0
  SetProgressBarTitle("Sifting through " + totalForms + " items...")
  while (iFormIndex < totalForms)
    AdvanceProgressBar(iFormIndex,totalForms)
    curForm = cm_contentsPlayerInventory.GetAt(iFormIndex)
    curFormType = curForm.GetType()
    nameOfMod = cmlib.GetFormModName(curForm)
  ; Filters to skip items based on specific list and/or mod
    if !cm_itemsToSkip.HasForm(curForm) && modstoskipitems.Find(nameOfMod) < 0 && !PO3_SKSEFunctions.IsQuestItem(curForm as ObjectReference)
    ; Cloud deposit conditions first then regular
      if (cloud && ccDepositTypeCodes.Find(curFormType) != -1) || (!cloud && curFormType == itemType)
        itemQty = refSource.GetItemCount(curForm)
        refSource.RemoveItem(curForm,itemQty,TRUE,refDestination)
        itemsMoved += 1
        if curForm == Gold001
          totalPieceCount = totalPieceCount + 1
        else
          totalPieceCount = totalPieceCount + itemQty
        endif
      endif
    endif
    if terminateVar
      TerminateProcess()
      return "Canceled by user!"
    endif
    iFormIndex += 1
  endwhile
  EnableAllOptions()
  if cloud
    numItemsCC = cm_CloudContainer09.GetReference().GetNumItems()
  endif
  if !cloud && itemsMoved < 1
    return "There were no items in the player's inventory able to be moved."
  elseif !cloud && itemsMoved
    return "Success, " + itemsMoved + " different items deposited."
  elseif itemsMoved < 1
    return "No items able to be deposited."
  elseif itemsMoved > 0
    return itemsMoved + " item(s) successfully deposited"
  else
    return "idk wth happened"
  endif
  
endfunction
 
function WdStuff(ObjectReference refSource, ObjectReference refDestination, Int itemType)
  
  ;cm_contentsChest.revert()
  PO3_SKSEFunctions.AddAllItemsToList(refSource, cm_contentsChest)
  Int totalForms = cm_contentsChest.GetSize()
  if totalForms < 1
    ShowMessage("The container has no items to withdraw!",False)
    return
  endif
 
  DisableAllOptions()
  
  ;isPlayer = (refsource == )
  
  Int totalPieceCount = 0
  Int itemQty
  Int itemsMoved = 0
  Form curForm
  Int iFormIndex = 0
  Int totalIterations = 0
 
  SetProgressBarTitle("Withdrawing items...")
  while iFormIndex < totalForms
    AdvanceProgressBar(iFormIndex,totalForms)
    curForm = cm_contentsChest.GetAt(iFormIndex)
    if curForm.GetType() == itemType
      itemQty = refSource.GetItemCount(curForm)
      refSource.RemoveItem(curForm,itemQty,TRUE,refDestination)
      itemsMoved += 1
      if curForm != Gold001
        totalPieceCount = totalPieceCount + itemQty
      else
        totalPieceCount = totalPieceCount + 1
      endif
    endif
    iFormIndex += 1
 
    if terminateVar
      TerminateProcess()
      return
    endif
  endwhile
  
  if !itemsMoved
    ShowMessage("There were no items in the container that were able to be moved.",False)
  else
    ShowMessage("Success, " + itemsMoved + " different items have been withdrawn.",False)
  endif
  
  numItemsCC = cm_CloudContainer09.GetReference().GetNumItems()
  EnableAllOptions()
  
endfunction
 
;--------------------MAP MARKERS----------------------------------------------------
 
function SaveMapMarkers(String pathNm)
  
  if !ShowMessage("This will overwrite saved map markers. Proceed?",TRUE,"$Yes","$No")
    return
  endif
  
  DisableAllOptions()
  
  Int totalForms = 403
  Int iFormIndex = 0
  ObjectReference curObjRef
  Int markerStatus
  Int visibleOnly = 0
  Int fastTravelVisible = 0
  
  JsonUtil.IntListClear(pathNm, "mapmarkerstatelistvanilla")
  
  SetProgressBarTitle("Checking status of " + totalForms + " map markers...")
  while iFormIndex < totalForms
    AdvanceProgressBar(iFormIndex,totalForms)
    curObjRef = cm_vanillaMapMarkers.GetAt(iFormIndex) as ObjectReference
    if curObjRef.IsMapMarkerVisible()
      if curObjRef.CanFastTravelToMarker()
        markerStatus = 2
        fastTravelVisible += 1
      else
        markerStatus = 1
        visibleOnly += 1
      endif
    else
      markerStatus = 0
    endif
    JsonUtil.IntListAdd(pathNm,"mapmarkerstatelistvanilla",markerStatus,TRUE)
    iFormIndex += 1
    
    if terminateVar
      TerminateProcess()
      return
    endif
  endwhile
 
; Confirmation
  if JsonUtil.Save(pathNm)
    if visibleOnly && fastTravelVisible
      ShowMessage(visibleOnly + " view-only markers and " + fastTravelVisible + " fast travel markers have been recorded.",False)
    elseif !visibleOnly
      ShowMessage(fastTravelVisible + " markers with fast travel successfully recorded.",False)
    elseif !fastTravelVisible
      ShowMessage(visibleOnly + " view-only markers without fast travel have been recorded.",False)
    else
      ShowMessage("For an unknown reason the game does not recognize that any map markers are visible. This is an error!",False)
    endif
  else
    ShowMessage("Failure, For an unknown reason the data was unable to be written to the hard drive!",False)
  endif
  EnableAllOptions()
  
endfunction
 
function RestoreMapMarkers(String pathNm)
  
  DisableAllOptions()
  
  Int totalForms = 404
  Int iFormIndex = 0
  ObjectReference curObjRef
  Int markerStatus
  Int visibleOnly = 0
  Int fastTravelVisible = 0
  Int totalIterations = 0
 
  SetProgressBarTitle("Loading saved map markers...")
  while (iFormIndex < totalForms)
    AdvanceProgressBar(iFormIndex,totalForms)
    curObjRef = cm_vanillaMapMarkers.GetAt(iFormIndex) as ObjectReference
    markerStatus = JsonUtil.IntListGet(pathNm,"mapmarkerstatelistvanilla",iFormIndex)
    if markerStatus == 2 && !curObjRef.CanFastTravelToMarker()
      curObjRef.AddToMap(TRUE)
      fastTravelVisible += 1
    elseif markerStatus == 1 && !curObjRef.IsMapMarkerVisible()
      curObjRef.AddToMap(False)
      visibleOnly += 1
    endif
    iFormIndex += 1
    
    totalIterations += 1
    if totalIterations > (totalForms + 200)
      ShowMessage("This process seems to be malfunctioning. Terminating!",false)
      EnableAllOptions()
      return
    endif
    if terminateVar
      TerminateProcess()
      return
    endif
  endwhile
  
; Confirmation
  if !visibleOnly && !fastTravelVisible
    ShowMessage("No markers added, all recorded marker data is already visible!",False)
  elseif !visibleOnly
    ShowMessage(fastTravelVisible + " markers have been successfully added for fast travel.",False)
  elseif !fastTravelVisible
    ShowMessage(visibleOnly + " markers have been made visible but not available for fast travel.",False)
  else
    ShowMessage(visibleOnly + " markers have been made visible and " + fastTravelVisible + " markers have been added for fast travel.",False)
  endif
  EnableAllOptions()
  
endfunction
 
;--------------------BOOKS----------------------------------------------------
 
function SaveBooksRead(String pathNm)
 
  if !booksFilePathExists && !ShowMessage("Important file missing: \\\"..\\Data\\SKSE\\Plugins\\StorageUtilData\\Ethereal Incarnation\\cm_BookData.json\\\"! This will disable support for books from supported mods. Reinstalling the mod should restore the file. Proceed with Vanilla Skyrim books only?", True, "$Yes", "$No")
    return
  elseif booksFilePathExists && !ShowMessage("Approx 8,600 books from 72 different mods are supported. Depending on how many supported mods are loaded this could take a long time. Do you wish to proceed?")
    return
  endif
  
  DisableAllOptions()
  
  Int iModIndex = 0
  Int iFormIndex = 0
  Bool isInstalled
  Int numMods = JsonUtil.StringListCount(booksFilePath,"bookmodlist")
  Int numBooks
  Int numVanillaBooks = cm_vanillaBooks.GetSize()
  Int numBooksRead = 0
  Int decForm
  Int subDecForm
  Form curForm
  String nameOfMod
  Int numModsDetected = 0
  String nameOfBook
  Int totalIterations = 0
  Book curBook
  String pathModName
  Int modNameChecked
  
  JsonUtil.IntListClear(pathNm, "bookformid")
  JsonUtil.StringListClear(pathNm, "bookmodname")  
  
; All vanilla books first
  SetProgressBarTitle("[" + numVanillaBooks + " books] vanilla ...")
  while iFormIndex < numVanillaBooks
    curForm = cm_vanillaBooks.GetAt(iFormIndex)
    curBook = curForm as Book
    nameOfBook = curForm.GetName()
    decForm = curForm.GetFormID()
    nameOfMod = cmlib.GetFormModName(curForm)
    subDecForm = cmlib.GetTheSubForm("",decForm)
    if curBook.IsRead()
      JsonUtil.IntListAdd(pathNm, "bookformid", subDecForm,TRUE)
      JsonUtil.StringListAdd(pathNm, "bookmodname", nameOfMod,TRUE)
      numBooksRead += 1
    endif
    AdvanceProgressBar(iFormIndex,numVanillaBooks)
    iFormIndex += 1
    totalIterations += 1
    if totalIterations > (numVanillaBooks + 200)
      ShowMessage("This process seems to be malfunctioning. Terminating!",false)
      EnableAllOptions()
      return
    endif
    if terminateVar
      TerminateProcess()
      return
    endif
  endwhile
  
  iFormIndex = 0
  
; All books from supported mods
  if booksFilePathExists
    while iModIndex < numMods
      nameOfMod = JsonUtil.StringListGet(booksFilePath,"bookmodlist",iModIndex)
      if MiscUtil.FileExists("data/" + nameOfMod)
        numBooks = JsonUtil.IntListCount(booksFilePath,nameOfMod)
        SetProgressBarTitle(" [" + numBooks + " books] " + nameOfMod)
        while iFormIndex < numBooks
          AdvanceProgressBar(iFormIndex,numBooks)
          subDecForm = JsonUtil.IntListGet(booksFilePath,nameOfMod,iFormIndex)
          curForm = Game.GetFormFromFile(subDecForm,nameOfMod)
          curBook = curForm as Book
          nameOfBook = curForm.GetName()
 
          if curBook.IsRead()
            JsonUtil.IntListAdd(pathNm, "bookformid", subDecForm,TRUE)
            JsonUtil.StringListAdd(pathNm, "bookmodname", nameOfMod,TRUE)
            numBooksRead += 1
          endif
          iFormIndex += 1
          
          totalIterations += 1
          if totalIterations > 10000
            ShowMessage("This process seems to be malfunctioning. Terminating!",false)
            EnableAllOptions()
            return
          endif
        endwhile
        modNameChecked = 0
        numModsDetected += 1
      endif
      iModIndex += 1
    endwhile
    if terminateVar
      TerminateProcess()
      return
    endif
  endif
  
; Confirmation
  if JsonUtil.Save(filePath)
    if numModsDetected < 1
      ShowMessage("Success! The read status of " + numBooksRead + " books has now been recorded.",false)
    elseif numBooksRead > 0
      ShowMessage("Success, " + numModsDetected + " supported mod(s) were detected and the read status of " + numBooksRead + " different books has been recorded.",false)
    else
      ShowMessage("No books were recorded as read.",false)
    endif
  else
    ShowMessage("For an unknown reason the data couldn't be written.",false)
  endif
 
  __storedBooksRead = numBooksRead
 
  EnableAllOptions()
 
endfunction
 
function LoadBooksRead(String pathNm, ObjectReference playerObject)
 
  if !ShowMessage("It is recommended that you be in an interior cell with very little activity before performing this function! Proceed?",true,"$Yes","$No")
    return
  endif
  
  DisableAllOptions()
  
  Int numBooks
  Int iFormIndex = 0
  Int iModIndex = 0
  Int subDecForm
  Int restoreBooks = 0
  String nameOfMod
  Int numBooksRead = 0
  Int numBooksUnableToRead = 0
  Form curForm
  ObjectReference bookPlacedAtMe
  Int totalIterations
  Book curBook
  
  if ShowMessage("Would you also like for one of each book to be placed in your inventory?",TRUE,"$Yes","$No")
    restoreBooks = 1
  endif
  
  numBooks = JsonUtil.IntListCount(pathNm, "bookformid")
  SetProgressBarTitle("Loading: " + numBooks + " books...")
  while iFormIndex < numBooks
    AdvanceProgressBar(iFormIndex,numBooks)
    subDecForm = JsonUtil.IntListGet(pathNm,"bookformid",iFormIndex)
    nameOfMod = JsonUtil.StringListGet(pathNm,"bookmodname",iFormIndex)
    curForm = Game.GetFormFromFile(subDecForm,nameOfMod)
    curBook = curForm as Book
    if !curBook.IsRead()
;/      bookPlacedAtMe = playerObject.PlaceAtMe(curForm)
      if !PO3_SKSEFunctions.IsQuestItem(bookPlacedAtMe)
        bookPlacedAtMe.Activate(playerObject)
        if curBook.IsRead()
          numBooksRead += 1
        else
          numBooksUnableToRead += 1
        endif
        if playerRef.GetItemCount(curForm) < 1 && restoreBooks
          playerObject.AddItem(bookPlacedAtMe,1,TRUE)
        else
          bookPlacedAtMe.Disable()
          bookPlacedAtMe.Delete()
        endif
      else
        bookPlacedAtMe.Disable()
        bookPlacedAtMe.Delete()
      endif /;
      if !PO3_SKSEFunctions.IsQuestItem(curForm as ObjectReference)
        PO3_SKSEFunctions.SetReadFlag(curBook)
        if curBook.IsRead()
          numBooksRead += 1
        else
          numBooksUnableToRead += 1
        endif
        if restoreBooks
          playerObject.AddItem(curForm,1,TRUE)
        endif
      endif
    endif
    iFormIndex += 1
    totalIterations += 1
    if totalIterations > (10000)
      ShowMessage("This process seems to be malfunctioning. Terminating!",false)
      EnableAllOptions()
      return
    endif
    if terminateVar
      TerminateProcess()
      return
    endif
  endwhile
 
; Confirmation
  String messageText
  if (numBooksRead + numBooksUnableToRead) > 0
    messageText = "Success!\nBooks Read: " + numBooksRead + "\nBooks Unread: " + numBooksUnableToRead
  else
    ShowMessage("It appears that all saved books are already marked as having been read.",false)
  endif
  if restoreBooks
    ShowMessage(messageText + "\nAll books are in your inventory.",false)
  else
    ShowMessage(messageText,false)
  endif
  EnableAllOptions()
  
endfunction
 
;--------------------MISC FUNCTIONS----------------------------------------------------
 
; function to quickly add stuff in json format
function StoreStuffManually()
 
endFunction
 
function SaveModListJson()
  JsonUtil.StringListClear(filePath, "loadedmodlist")
  String nameOfMod
  Int iModIndex = 0
  Int numMods = Game.GetModCount() ;The number of active mods.
  Int totalIterations
  while iModIndex < numMods
    nameOfMod = Game.GetModName(iModIndex) ;Gets Name of Mod eg. Skyrim.esm, Update.esm, Hearthfire.esm, etc.
    JsonUtil.StringListAdd(filePath, "loadedmodlist", nameOfMod,TRUE)
    iModIndex += 1
    if iModIndex > (numMods + 100)
      return
    endif
  endwhile
  JsonUtil.Save(filePath)
endfunction
 
String Function getCellXY()
  ; learned this code from the Player Cell Position mode by Ashen (open perms)
  ; https://www.nexusmods.com/skyrimspecialedition/mods/46173
  return (Math.Floor(playerRef.GetPositionX()/4096)) as Int+","+(Math.Floor(playerRef.GetPositionY()/4096)) as Int
endfunction
 
function EvaluateTarget()
 
  isCCAssigned = getIsCCAssigned()
  if isCCAssigned < 1
    isThisTheCC = 0
  else
    isThisTheCC = getIsCCAssigned(ObjFoc)
    numItemsCC = cm_CloudContainer09.GetReference().GetNumItems()
    isCCAssigned = 1
  endif
  
  if objFoc
    if objIsActor == -1 ; If this check has been performed all else is already done
      if (objFoc as Actor).GetLevel() < 1
        objIsActor = 0
        objActor = None
        objActorBase = None
        if isAContainer == -1
          isAContainer = cmlib.IsContainer(objFoc) as Int
        endif
        if objOwner == None || objIsOwned < 0
          objOwner = cmlib.GetOwner(objFoc)
          if objOwner
            objIsOwned = 1
            if objOwner == playerRef.GetActorBase() as Form
              objOwnedByPlayer = 1
            else
              objOwnedByPlayer = 0
            endif
          else
            objIsOwned = 0
            objOwnedByPlayer = 0
          endif
        endif
      else ; Is an actor
        objIsActor = 1
        objActorBase = objActor.GetActorBase()
      endif
    endif
  endif
 
endfunction
 
;--------------------MENU FUNCTIONS----------------------------------------------------
 
function DisableSkills()
 
  SetOptionFlags(_saveSkills, OPTION_FLAG_DISABLED)
  SetOptionFlags(_loadSkills, OPTION_FLAG_DISABLED)
 
endfunction
 
function DisableSpellsAndInventory()
 
  SetOptionFlags(_saveSpells, OPTION_FLAG_DISABLED)
  SetOptionFlags(_loadSpells, OPTION_FLAG_DISABLED)
  SetOptionFlags(_saveInventory, OPTION_FLAG_DISABLED)
  SetOptionFlags(_loadInventory, OPTION_FLAG_DISABLED)
  SetOptionFlags(_saveContainer, OPTION_FLAG_DISABLED)
  SetOptionFlags(_loadContainer, OPTION_FLAG_DISABLED)
  
endfunction
 
function DisableAllOptions()
 
  isScriptRunning = TRUE
  SetOptionFlags(_saveSkills, OPTION_FLAG_DISABLED)
  SetOptionFlags(_loadSkills, OPTION_FLAG_DISABLED)
  SetOptionFlags(_saveSpells, OPTION_FLAG_DISABLED)
  SetOptionFlags(_loadSpells, OPTION_FLAG_DISABLED)
  SetOptionFlags(_saveInventory, OPTION_FLAG_DISABLED)
  SetOptionFlags(_loadInventory, OPTION_FLAG_DISABLED)
  SetOptionFlags(_saveContainer, OPTION_FLAG_DISABLED)
  SetOptionFlags(_loadContainer, OPTION_FLAG_DISABLED)
  SetOptionFlags(_emptyContainer, OPTION_FLAG_DISABLED)
  SetOptionFlags(_depArmor, OPTION_FLAG_DISABLED)
  SetOptionFlags(_depWeapons, OPTION_FLAG_DISABLED)
  SetOptionFlags(_depIngestibles, OPTION_FLAG_DISABLED)
  SetOptionFlags(_depIngredients, OPTION_FLAG_DISABLED)
  SetOptionFlags(_depBooks, OPTION_FLAG_DISABLED)
  SetOptionFlags(_depSoulGems, OPTION_FLAG_DISABLED)
  SetOptionFlags(_depMisc, OPTION_FLAG_DISABLED)
  SetOptionFlags(_depEverything, OPTION_FLAG_DISABLED)
  SetOptionFlags(_wdArmor, OPTION_FLAG_DISABLED)
  SetOptionFlags(_wdWeapons, OPTION_FLAG_DISABLED)
  SetOptionFlags(_wdIngestibles, OPTION_FLAG_DISABLED)
  SetOptionFlags(_wdIngredients, OPTION_FLAG_DISABLED)
  SetOptionFlags(_wdBooks, OPTION_FLAG_DISABLED)
  SetOptionFlags(_wdSoulGems, OPTION_FLAG_DISABLED)
  SetOptionFlags(_wdMisc, OPTION_FLAG_DISABLED)
  SetOptionFlags(_depCloud, OPTION_FLAG_DISABLED)
  SetOptionFlags(_setCloud, OPTION_FLAG_DISABLED)
  SetOptionFlags(_saveMapMarkers, OPTION_FLAG_DISABLED)
  SetOptionFlags(_restoreMapMarkers, OPTION_FLAG_DISABLED)
  SetOptionFlags(_saveReadBooks, OPTION_FLAG_DISABLED)
  SetOptionFlags(_loadReadBooks, OPTION_FLAG_DISABLED)
  SetOptionFlags(_addPerkPoint, OPTION_FLAG_DISABLED)
  SetOptionFlags(_removePerkPoint, OPTION_FLAG_DISABLED)
  
endfunction
 
function EnableAllOptions(Bool check = False)
 
  isScriptRunning = False
  SetOptionFlags(_saveSkills, OPTION_FLAG_NONE)
  SetOptionFlags(_loadSkills, OPTION_FLAG_NONE)
  SetOptionFlags(_saveInventory, OPTION_FLAG_NONE)
  SetOptionFlags(_loadInventory, OPTION_FLAG_NONE)
  SetOptionFlags(_saveContainer, OPTION_FLAG_NONE)
  SetOptionFlags(_loadContainer, OPTION_FLAG_NONE)
  SetOptionFlags(_emptyContainer, OPTION_FLAG_NONE)
  SetOptionFlags(_depArmor, OPTION_FLAG_NONE)
  SetOptionFlags(_depWeapons, OPTION_FLAG_NONE)
  SetOptionFlags(_depIngestibles, OPTION_FLAG_NONE)
  SetOptionFlags(_depIngredients, OPTION_FLAG_NONE)
  SetOptionFlags(_depBooks, OPTION_FLAG_NONE)
  SetOptionFlags(_depSoulGems, OPTION_FLAG_NONE)
  SetOptionFlags(_depMisc, OPTION_FLAG_NONE)
  SetOptionFlags(_depEverything, OPTION_FLAG_NONE)
  SetOptionFlags(_wdArmor, OPTION_FLAG_NONE)
  SetOptionFlags(_wdWeapons, OPTION_FLAG_NONE)
  SetOptionFlags(_wdIngestibles, OPTION_FLAG_NONE)
  SetOptionFlags(_wdIngredients, OPTION_FLAG_NONE)
  SetOptionFlags(_wdBooks, OPTION_FLAG_NONE)
  SetOptionFlags(_wdSoulGems, OPTION_FLAG_NONE)
  SetOptionFlags(_wdMisc, OPTION_FLAG_NONE)
  SetOptionFlags(_depCloud, OPTION_FLAG_NONE)
  SetOptionFlags(_setCloud, OPTION_FLAG_NONE)
  SetOptionFlags(_saveMapMarkers, OPTION_FLAG_NONE)
  SetOptionFlags(_restoreMapMarkers, OPTION_FLAG_NONE)
  SetOptionFlags(_saveReadBooks, OPTION_FLAG_NONE)
  SetOptionFlags(_loadReadBooks, OPTION_FLAG_NONE)
  SetOptionFlags(_addPerkPoint, OPTION_FLAG_NONE)
  SetOptionFlags(_removePerkPoint, OPTION_FLAG_NONE)
  SetInfoText("")
  SetTextOptionValue(_progressBar, "")
  SetTextOptionValue(_progressBarTitle, "")
  loadStats()
  cm_contentsChest.Revert()
  cm_contentsPlayerInventory.Revert()
  cm_contentsCloudContainer.Revert()
  cm_genericChest.Revert()
  
endfunction
 
;--------------------STARTUP/EVENTS----------------------------------------------------
 
function OnGameReload()
  RegisterForCrosshairRef()
  filesCheckedYet = -1
  VarValInit()
  parent.OnGameReload()
endfunction
 
event OnInit()
  filesCheckedYet = -1
  VarValInit()
  parent.OnInit()
endevent
 
event OnConfigInit()
  VarValInit()
endEvent
 
event OnPlayerLoadGame()
  RegisterForCrosshairRef()
  filesCheckedYet = -1
  VarValInit()
endevent
 
event OnConfigClose()
  if isScriptRunning
    terminateVar = true
    TerminateProcess()
    debug.Messagebox("Ethereal Incarnation process terminated! Prior data is lost but partial progress may have been saved.")
  endif
  _isTargetEssential = -1
  _isTargetProtected = -1
  isAContainer = -1
  isCCAssigned = -1
  isPlayerOwner = -1
  isThisTheCC = -1
  numItemsCC = -1
  objIsActor = -1
  objIsOwned = -1
  objOwnedByPlayer = -1
  numPlayerItems = -1
  cm_contentsChest.Revert()
  cm_contentsPlayerInventory.Revert()
  cm_contentsCloudContainer.Revert()
  cm_genericChest.Revert()
endevent
 
event OnConfigOpen()
  if !isScriptRunning
    terminateVar = false
  else
    ShowMessage("A running process has been terminated!")
    terminateVar = true
  endif
  ;EvaluateTarget()
  VarValInit()
  LoadStats()
  GetStats()
endevent
 
; functions to run when selecting an option
event OnOptionSelect(Int option)
  if option == _saveSkills
    SaveSkills(playerRef, filePath)
  elseif option == _loadSkills
    LoadSkills(playerRef, filePath)
  elseif option == _saveSpells
    SaveSpells(playerRef, filePath)
  elseif option == _loadSpells
    LoadSpells(playerRef, filePath)
  elseif option == _saveInventory
    SaveInventory(playerRef, filePath)
  elseif option == _loadInventory
    LoadInventory(playerRef, filePath)
  elseif option == _saveContainer
    SaveContainer(objFoc, filePath,999999)
  elseif option == _loadContainer
    LoadContainer(objFoc, filePath,999999)
  elseif option == _emptyContainer
    emptyContainer(objFoc)
  elseif option == _depArmor
    ShowMessage(DepStuff(playerRef as ObjectReference,objFoc,26),False)
  elseif option == _depWeapons
    ShowMessage(DepStuff(playerRef as ObjectReference,objFoc,41),False)
  elseif option == _depIngestibles
    ShowMessage(DepStuff(playerRef as ObjectReference,objFoc,46),False)
  elseif option == _depIngredients
    ShowMessage(DepStuff(playerRef as ObjectReference,objFoc,30),False)
  elseif option == _depBooks
    ShowMessage(DepStuff(playerRef as ObjectReference,objFoc,27),False)
  elseif option == _depSoulGems
    ShowMessage(DepStuff(playerRef as ObjectReference,objFoc,52),False)
  elseif option == _depMisc
    ShowMessage(DepStuff(playerRef as ObjectReference,objFoc,32),False)
  elseif option == _depEverything
    ShowMessage(DepStuff(playerRef as ObjectReference,objFoc),False)
  elseif option == _wdArmor
    WdStuff(objFoc,playerRef,26)
  elseif option == _wdWeapons
    WdStuff(objFoc,playerRef,41)
  elseif option == _wdIngestibles
    WdStuff(objFoc,playerRef,46)
  elseif option == _wdIngredients
    WdStuff(objFoc,playerRef,30)
  elseif option == _wdBooks
    WdStuff(objFoc,playerRef,27)
  elseif option == _wdSoulGems
    WdStuff(objFoc,playerRef,52)
  elseif option == _wdMisc
    WdStuff(objFoc,playerRef,32)
  elseif option == _depCloud
    ShowMessage(DepStuff(playerObj,cm_CloudContainer09.GetReference(),0,TRUE))
  elseif option == _setCloud
    SetCloudContainer(objFoc)
  elseif option == _saveMapMarkers
    SaveMapMarkers(filePath)
  elseif option == _restoreMapMarkers
    restoreMapMarkers(filePath)
  elseif option == _saveReadBooks
    SaveBooksRead(filePath)
  elseif option == _loadReadBooks
    LoadBooksRead(filePath,playerObj)
  elseif option == _addPerkPoint
    if !cmlib.givePlayerPerkPoint()
      ShowMessage("Unable to add perk point for an unknown reason!",false)
    else
      playerPerkPoints += 1
      ForcePageReset()
    endif
  elseif option == _removePerkPoint
    if !cmlib.removePlayerPerkPoint()
      ShowMessage("You cannot have less than zero perk points!",false)
    else
      playerPerkPoints -= 1
      ForcePageReset()
    endif
  elseif option == _lswScrolls
    _toggleState011 = !_toggleState011
    SetToggleOptionValue(option, _toggleState011)
    JsonUtil.SetPathIntValue(settingsfilepath,".losesomeweight.23",_toggleState011 as Int)
    JsonUtil.Save(settingsfilepath)
  elseif option == _lswBooks
    _toggleState012 = !_toggleState012
    SetToggleOptionValue(option, _toggleState012)
    JsonUtil.SetPathIntValue(settingsfilepath,".losesomeweight.27",_toggleState012 as Int)
    JsonUtil.Save(settingsfilepath)
  elseif option == _lswIngredients
    _toggleState013 = !_toggleState013
    SetToggleOptionValue(option, _toggleState013)
    JsonUtil.SetPathIntValue(settingsfilepath,".losesomeweight.30",_toggleState013 as Int)
    JsonUtil.Save(settingsfilepath)
  elseif option == _lswMisc
    _toggleState014 = !_toggleState014
    SetToggleOptionValue(option, _toggleState014)
    JsonUtil.SetPathIntValue(settingsfilepath,".losesomeweight.32",_toggleState014 as Int)
    JsonUtil.Save(settingsfilepath)
  elseif option == _lswAmmo
    _toggleState015 = !_toggleState015
    SetToggleOptionValue(option, _toggleState015)
    JsonUtil.SetPathIntValue(settingsfilepath,".losesomeweight.42",_toggleState015 as Int)
    JsonUtil.Save(settingsfilepath)
  elseif option == _lswIngestibles
    _toggleState016 = !_toggleState016
    SetToggleOptionValue(option, _toggleState016)
    JsonUtil.SetPathIntValue(settingsfilepath,".losesomeweight.46",_toggleState016 as Int)
    JsonUtil.Save(settingsfilepath)
  elseif option == _lswSoulGems
    _toggleState017 = !_toggleState017
    SetToggleOptionValue(option, _toggleState017)
    JsonUtil.SetPathIntValue(settingsfilepath,".losesomeweight.52",_toggleState017 as Int)
    JsonUtil.Save(settingsfilepath)
  elseif option == _lswQuestItems
    _toggleState018 = !_toggleState018
    SetToggleOptionValue(option, _toggleState018)
    JsonUtil.SetPathIntValue(settingsfilepath,".losesomeweight.quest",_toggleState018 as Int)
    JsonUtil.Save(settingsfilepath)
  elseif option == _cloudScrolls
    _toggleState08 = !_toggleState08
    SetToggleOptionValue(option, _toggleState08)
    JsonUtil.SetPathIntValue(settingsfilepath,".settings.cloudcontainer.deposit.23",(_toggleState08 as Int) * 23)
    GetCloudDepositOptions()
    JsonUtil.Save(settingsfilepath)
  elseif option == _cloudBooks
    _toggleState09 = !_toggleState09
    SetToggleOptionValue(option, _toggleState09)
    JsonUtil.SetPathIntValue(settingsfilepath,".settings.cloudcontainer.deposit.27",(_toggleState09 as Int) * 27)
    GetCloudDepositOptions()
    JsonUtil.Save(settingsfilepath)
  elseif option == _cloudIngredients
  _toggleState10 = !_toggleState10
    SetToggleOptionValue(option, _toggleState10)
    JsonUtil.SetPathIntValue(settingsfilepath,".settings.cloudcontainer.deposit.30",(_toggleState10 as Int) * 30)
    GetCloudDepositOptions()
    JsonUtil.Save(settingsfilepath)
  elseif option == _cloudMisc
    _toggleState11 = !_toggleState11
    SetToggleOptionValue(option, _toggleState11)
    JsonUtil.SetPathIntValue(settingsfilepath,".settings.cloudcontainer.deposit.32",(_toggleState11 as Int) * 32)
    GetCloudDepositOptions()
    JsonUtil.Save(settingsfilepath)
  elseif option == _cloudAmmo
    _toggleState12 = !_toggleState12
    SetToggleOptionValue(option, _toggleState12)
    JsonUtil.SetPathIntValue(settingsfilepath,".settings.cloudcontainer.deposit.42",(_toggleState12 as Int) * 42)
    GetCloudDepositOptions()
    JsonUtil.Save(settingsfilepath)
  elseif option == _cloudIngestibles
    _toggleState13 = !_toggleState13
    SetToggleOptionValue(option, _toggleState13)
    JsonUtil.SetPathIntValue(settingsfilepath,".settings.cloudcontainer.deposit.46",(_toggleState13 as Int) * 46)
    GetCloudDepositOptions()
    JsonUtil.Save(settingsfilepath)
  elseif option == _cloudSoulGems
    _toggleState14 = !_toggleState14
    SetToggleOptionValue(option, _toggleState14)
    JsonUtil.SetPathIntValue(settingsfilepath,".settings.cloudcontainer.deposit.52",(_toggleState14 as Int) * 52)
    GetCloudDepositOptions()
    JsonUtil.Save(settingsfilepath)
  elseif option == _cloudArmor
    _toggleState15 = !_toggleState15
    SetToggleOptionValue(option, _toggleState15)
    JsonUtil.SetPathIntValue(settingsfilepath,".settings.cloudcontainer.deposit.26",(_toggleState15 as Int) * 26)
    GetCloudDepositOptions()
    JsonUtil.Save(settingsfilepath)
  elseif option == _cloudWeapons
    _toggleState16 = !_toggleState16
    SetToggleOptionValue(option, _toggleState16)
    JsonUtil.SetPathIntValue(settingsfilepath,".settings.cloudcontainer.deposit.41",(_toggleState16 as Int) * 41)
    GetCloudDepositOptions()
    JsonUtil.Save(settingsfilepath)
  elseif option == _isTargetEssential
    ActorBase thatActorBase = (ObjFoc as Actor).GetActorBase()
    Actor thatActor = ObjFoc as Actor
    if ObjFoc as Actor
      thatActorBase.SetEssential(!thatActorBase.IsEssential())
      SetTextOptionValue(_isTargetEssential, "Is Essential?: " + thatActorBase.IsEssential() + " - Click2Toggle")
    endif
  elseif option == _isTargetProtected
    ActorBase thatActorBase = (ObjFoc as Actor).GetActorBase()
    Actor thatActor = ObjFoc as Actor
    if ObjFoc as Actor
      thatActorBase.SetProtected(!thatActorBase.IsProtected())
      SetTextOptionValue(_isTargetProtected, "Is Protected?: " + thatActorBase.IsProtected() + " - Click2Toggle")
    endif
  elseif option == _notShowOnStealthMeter
    (ObjFoc as Actor).SetNotShowOnStealthMeter(True)
  elseif option == _depIndiscriminatelyEverything
    ShowMessage(DepStuff(playerRef as ObjectReference,objFoc,99),False)
    SetTextOptionValue(_multiContainerLoad, JsonUtil.IntListCount(filePath,"containerformid" + IndexMatch(currentMenuOption)) + " items")
  elseif option == _multiContainerSave
    ShowMessage(SaveContainer(objFoc,filePath))
    SetTextOptionValue(_multiContainerLoad, JsonUtil.IntListCount(filePath,"containerformid" + IndexMatch(currentMenuOption)) + " items")
  elseif option == _multiContainerLoad
    LoadContainer(objFoc, filePath)
    SetTextOptionValue(_multiContainerSave, ObjFoc.GetNumItems() + " items")
  elseif option == _multiContainerDelete
  ;working4
    if ShowMessage("Are you sure you want to permanently delete this container record?",TRUE)
      ContainerHandler("delete",containerList[currentMenuOption])
      SetMenuOptionValue(_multiContainerSelect, containerList[0])
      SetTextOptionValue(_multiContainerLoad, JsonUtil.IntListCount(filePath,"containerformid" + IndexMatch(0,containerList[0])) + " items")
    endif
  endif
  
endEvent
 
event OnOptionKeyMapChange(int a_option, int a_keyCode, string a_conflictControl, string a_conflictName)
; Called when a key has been remapped
  if (a_option == _keymapOID_K)
    bool continue = true
    if (a_conflictControl != "")
      string msg
      if (a_conflictName != "")
        msg = "This key is already mapped to:\n'" + a_conflictControl + "'\n(" + a_conflictName + ")\n\nAre you sure you want to continue?"
      else
        msg = "This key is already mapped to:\n'" + a_conflictControl + "'\n\nAre you sure you want to continue?"
      endIf
      continue = ShowMessage(msg, true, "$Yes", "$No")
    endIf
    if (continue)
      SetKeymapOptionValue(a_option, a_keyCode)
      myKeyMapVar = a_keyCode
      JsonUtil.SetPathIntValue(settingsfilepath,".settings.keymap.cloudcontainer",myKeyMapVar)
      JsonUtil.Save(settingsfilepath)
      WriteSettings()
    endIf
  endIf
endEvent
 
; contents of the info box at the bottom of the MCM page
event OnOptionHighlight(Int option)
 
  if option == _saveSkills
    SetInfoText("Saves player health, magicka, stamina, carry weight, level, total perk points, current level xp, skill levels (including legendary levels).")
  elseif option == _loadSkills
    SetInfoText("Sets player health, magicka, stamina, carry weight, level, total perk points, current level xp, skill levels (including legendary levels) to the saved values.")
  elseif option == _saveSpells
    SetInfoText("Saves spells that are learned by books, shouts, words of power and dragon souls from supported mods. " + (magicMods.length + magicMods0.length) + " mods currently supported.")
  elseif option == _loadSpells
    SetInfoText("Adds all saved spells, shouts and words of power that are unknown to the player.")
  elseif option == _saveInventory
    SetInfoText("Saves all items in a player's inventory. DOES NOT SAVE PLAYER ENCHANTED ITEMS!")
  elseif option == _loadInventory
    SetInfoText("Loads saved items into the player's inventory.")
  elseif option == _saveContainer
    SetInfoText("Save contents of a valid targeted container. DOES NOT SAVE PLAYER ENCHANTED ITEMS!")
  elseif option == _loadContainer
    SetInfoText("Loads saved items into a valid targeted container.")
  elseif option == _emptyContainer
    SetInfoText("Destroys the contents of a valid targeted container (USE WITH CAUTION).")
  elseif option == _depArmor
    SetInfoText("Deposits unequipped and unfavorited armor, clothing and jewelry into a valid targeted container.")
  elseif option == _depWeapons
    SetInfoText("Deposits unequipped and unfavorited weapons into a valid targeted container.")
  elseif option == _depIngestibles
    SetInfoText("Deposits unfavorited ingestibles e.g. potions and food into a valid targeted container. CAUTION: This will deposit health and magicka potions as well!")
  elseif option == _depIngredients
    SetInfoText("Deposits all alchemy ingredients into a valid targeted container.")
  elseif option == _depBooks
    SetInfoText("Deposits all books and notes into a valid targeted container.")
  elseif option == _depSoulGems
    SetInfoText("Deposits all soul gems into a valid targeted container.")
  elseif option == _depMisc
    SetInfoText("Deposits all miscellaneous items e.g. ore, firewood and gems into a valid targeted container.")
  elseif option == _depEverything
    SetInfoText("Deposits all items except those equipped and favorited into a valid targeted container.")
  elseif option == _wdArmor
    SetInfoText("Withdraws all armor, clothing and jewelry contained in a valid targeted container.")
  elseif option == _wdWeapons
    SetInfoText("Withdraws all weapons contained in a valid targeted container.")
  elseif option == _wdIngestibles
    SetInfoText("Withdraws all e.g. potions and food contained in a valid targeted container.")
  elseif option == _wdIngredients
    SetInfoText("Withdraws all alchemy ingredients contained in a valid targeted container.")
  elseif option == _wdBooks
    SetInfoText("Withdraws all books and notes from the targeted container.")
  elseif option == _wdSoulGems
    SetInfoText("Withdraws all soul gems from the targeted container.")
  elseif option == _wdMisc
    SetInfoText("Withdraws all miscellaneous items such as ore, firewood and gems from the targeted container.")
  elseif option == _depCloud
    SetInfoText("Deposits all items of the types selected in options except for those favorited and equipped into the cloud container.")
  elseif option == _setCloud
    SetInfoText("Assigns, unassigns or reassigns the cloud container.")
  elseif option == _saveMapMarkers
    SetInfoText("Saves vanilla map markers including those that are visible only and those available for fast travel.")
  elseif option == _restoreMapMarkers
    SetInfoText("Adds saved map markers to the map along with their status e.g. visible only and available for fast travel.")
  elseif option == _saveReadBooks
    SetInfoText("Saves a list of all books from supported mods that the player has read.")
  elseif option == _loadReadBooks
    SetInfoText("Loads saved books, marks them as read (if possible) and then adds all of these books to the player's inventory that aren't already in player's inventory. NOTE: Books referenced by quests are neither marked as read nor added to the player's inventory.")
    elseif option == _addPerkPoint
    SetInfoText("Add one perk point to the player.")
  elseif option == _removePerkPoint
    SetInfoText("Remove one available perk point from the player.")
  elseif option == _lswScrolls
    SetInfoText("Lose Some Weight option to reduce the weight of scrolls to zero.")
  elseif option == _lswBooks
    SetInfoText("Lose Some Weight option to reduce the weight of books and notes to zero.")
  elseif option == _lswIngredients
    SetInfoText("Lose Some Weight option to reduce the weight of alchemy ingredients to zero.")
  elseif option == _lswMisc
    SetInfoText("Lose Some Weight option to reduce the weight of miscellaneous items such as ore, firewood and gems to zero.")
  elseif option == _lswAmmo
    SetInfoText("Lose Some Weight option to reduce the weight of bolts and arrows to zero.")
  elseif option == _lswIngestibles
    SetInfoText("Lose Some Weight option to reduce the weight of ingestibles e.g. potions and food to zero.")
  elseif option == _lswSoulGems
    SetInfoText("Lose Some Weight option to reduce the weight of soul gems to zero.")
  elseif option == _cloudScrolls
    SetInfoText("Include scrolls when using cloud deposit.")
  elseif option == _cloudBooks
    SetInfoText("Include books and notes when using cloud deposit.")
  elseif option == _cloudIngredients
    SetInfoText("Include alchemy ingredients when using cloud deposit.")
  elseif option == _cloudMisc
    SetInfoText("Include misc items e.g. ore, firewood and gems to zero when using cloud deposit.")
  elseif option == _cloudAmmo
    SetInfoText("Include bolts and arrows when using cloud deposit.")
  elseif option == _cloudIngestibles
    SetInfoText("Include ingestibles e.g. potions and food when using cloud deposit. CAUTION: This will deposit health and magicka potions as well!")
  elseif option == _cloudSoulGems
    SetInfoText("Include soul gems when using cloud deposit.")
  elseif option == _cloudArmor
    SetInfoText("Include armor, clothing and jewelry when using cloud deposit.")
  elseif option == _cloudWeapons
    SetInfoText("Include weapons when using cloud deposit.")
  elseif option == _isTargetEssential
    SetInfoText("Is this target marked as essential by the game? Click to toggle.")
  elseif option == _isTargetProtected
    SetInfoText("Is this target marked as protected by the game? Click to toggle.")
  elseif option == _notShowOnStealthMeter
    SetInfoText("Will this NPC affect your stealth meter? Click to toggle.")
  elseif option == _depIndiscriminatelyEverything
    SetInfoText("Immediately dump all of your inventory except for quest items into a valid targeted container.")
  elseif option == _isAQuestItem
    SetInfoText("If TRUE then this item is referenced by a Quest.")
  elseif option == _isAQuestNPC
    SetInfoText("If TRUE then this NPC is referenced by a Quest.")
  elseif option == _itemGoldValue
    SetInfoText("Full sale value before modifiers such as speech skill, perks, etc. This value should only apply to items than can be picked up by the player but from time to time the game shows values for items that cannot.")
  endif
  
endevent
 
event OnCrosshairRefChange(ObjectReference ref)
  objFoc = ref  ; remember what the player is targeting
endevent
 
Event OnKeyUp(Int KeyCode, Float HoldTime)
  If KeyCode == myKeyMapVar
    if isCCAssigned != 1
      isCCAssigned = getIsCCAssigned()
    endif
    if isScriptRunning
      Debug.Notification("Canceling deposit...")
      terminateVar = TRUE
    else
      Game.SetInChargen(TRUE, TRUE, TRUE)
      Debug.Notification("Beginning deposit")
      Debug.Notification(DepStuff(playerObj,cm_CloudContainer09.GetReference(),0,TRUE))
      Game.SetInChargen(False, False, False)
    endif
  EndIf
EndEvent
 
;--------------------READ/WRITE SETTINGS----------------------------------------------------
 
function WriteSettings()
  JsonUtil.SetPathIntValue(settingsfilepath,".settings.keymap.cloudcontainer",myKeyMapVar)
  if (myKeyMapVar == -1)
    UnregisterForAllKeys()
  else
    RegisterForKey(myKeyMapVar)
  Endif
  
  JsonUtil.SetPathIntValue(settingsfilepath,".losesomeweight.23",_toggleState011 as Int)  ; scrolls
  JsonUtil.SetPathIntValue(settingsfilepath,".losesomeweight.27",_toggleState012 as Int)  ; book
  JsonUtil.SetPathIntValue(settingsfilepath,".losesomeweight.30",_toggleState013 as Int)  ; ing
  JsonUtil.SetPathIntValue(settingsfilepath,".losesomeweight.32",_toggleState014 as Int)  ; ores, ingots
  JsonUtil.SetPathIntValue(settingsfilepath,".losesomeweight.42",_toggleState015 as Int)  ; ammunition
  JsonUtil.SetPathIntValue(settingsfilepath,".losesomeweight.46",_toggleState016 as Int)  ; ingestibles
  JsonUtil.SetPathIntValue(settingsfilepath,".losesomeweight.52",_toggleState017 as Int)  ; soul gem
  JsonUtil.SetPathIntValue(settingsfilepath,".losesomeweight.quest",_toggleState018 as Int)  ; soul gem
  JsonUtil.SetPathIntValue(settingsfilepath,".settings.cloudcontainer.deposit.23",(_toggleState08 as Int) * 23)  ; scrolls
  JsonUtil.SetPathIntValue(settingsfilepath,".settings.cloudcontainer.deposit.27",(_toggleState09 as Int) * 27)  ; book
  JsonUtil.SetPathIntValue(settingsfilepath,".settings.cloudcontainer.deposit.30",(_toggleState10 as Int) * 30)  ; ing
  JsonUtil.SetPathIntValue(settingsfilepath,".settings.cloudcontainer.deposit.32",(_toggleState11 as Int) * 32)  ; ores, ingots
  JsonUtil.SetPathIntValue(settingsfilepath,".settings.cloudcontainer.deposit.42",(_toggleState12 as Int) * 42)  ; ammunition
  JsonUtil.SetPathIntValue(settingsfilepath,".settings.cloudcontainer.deposit.46",(_toggleState13 as Int) * 46)  ; ingestibles
  JsonUtil.SetPathIntValue(settingsfilepath,".settings.cloudcontainer.deposit.52",(_toggleState14 as Int) * 52)  ; soul gem
  JsonUtil.SetPathIntValue(settingsfilepath,".settings.cloudcontainer.deposit.26",(_toggleState15 as Int) * 26)  ; armor,cloth
  JsonUtil.SetPathIntValue(settingsfilepath,".settings.cloudcontainer.deposit.41",(_toggleState16 as Int) * 41)  ; weapon
  
  JsonUtil.Save(settingsfilepath)
  
endfunction
 
function GetCloudDepositOptions()
 
  ccDepositTypeCodes[0] = JsonUtil.GetPathIntValue(settingsfilepath,".settings.cloudcontainer.deposit.23")  ; scrolls
  ccDepositTypeCodes[1] = JsonUtil.GetPathIntValue(settingsfilepath,".settings.cloudcontainer.deposit.27")  ; book
  ccDepositTypeCodes[2] = JsonUtil.GetPathIntValue(settingsfilepath,".settings.cloudcontainer.deposit.30")  ; ing
  ccDepositTypeCodes[3] = JsonUtil.GetPathIntValue(settingsfilepath,".settings.cloudcontainer.deposit.32")  ; ores, ingots
  ccDepositTypeCodes[4] = JsonUtil.GetPathIntValue(settingsfilepath,".settings.cloudcontainer.deposit.42")  ; ammunition
  ccDepositTypeCodes[5] = JsonUtil.GetPathIntValue(settingsfilepath,".settings.cloudcontainer.deposit.46")  ; ingestibles
  ccDepositTypeCodes[6] = JsonUtil.GetPathIntValue(settingsfilepath,".settings.cloudcontainer.deposit.52")  ; soul gem
  ccDepositTypeCodes[7] = JsonUtil.GetPathIntValue(settingsfilepath,".settings.cloudcontainer.deposit.26")  ; armor,cloth
  ccDepositTypeCodes[8] = JsonUtil.GetPathIntValue(settingsfilepath,".settings.cloudcontainer.deposit.41")  ; weapon
 
endfunction
 
 
function LoadSettings()
  myKeyMapVar = JsonUtil.GetPathIntValue(settingsfilepath,".settings.keymap.cloudcontainer")
  if (myKeyMapVar == -1)
    UnregisterForAllKeys()
  else
    RegisterForKey(myKeyMapVar)
  Endif
  
  _toggleState011 = JsonUtil.GetPathIntValue(settingsfilepath,".losesomeweight.23") as Bool
  _toggleState012 = JsonUtil.GetPathIntValue(settingsfilepath,".losesomeweight.27") as Bool
  _toggleState013 = JsonUtil.GetPathIntValue(settingsfilepath,".losesomeweight.30") as Bool
  _toggleState014 = JsonUtil.GetPathIntValue(settingsfilepath,".losesomeweight.32") as Bool
  _toggleState015 = JsonUtil.GetPathIntValue(settingsfilepath,".losesomeweight.42") as Bool
  _toggleState016 = JsonUtil.GetPathIntValue(settingsfilepath,".losesomeweight.46") as Bool
  _toggleState017 = JsonUtil.GetPathIntValue(settingsfilepath,".losesomeweight.52") as Bool
  _toggleState018 = JsonUtil.GetPathIntValue(settingsfilepath,".losesomeweight.quest") as Bool
  _toggleState08 = JsonUtil.GetPathIntValue(settingsfilepath,".settings.cloudcontainer.deposit.23") as Bool  ; scrolls
  _toggleState09 = JsonUtil.GetPathIntValue(settingsfilepath,".settings.cloudcontainer.deposit.27") as Bool  ; book
  _toggleState10 = JsonUtil.GetPathIntValue(settingsfilepath,".settings.cloudcontainer.deposit.30") as Bool  ; ing
  _toggleState11 = JsonUtil.GetPathIntValue(settingsfilepath,".settings.cloudcontainer.deposit.32") as Bool  ; ores, ingots
  _toggleState12 = JsonUtil.GetPathIntValue(settingsfilepath,".settings.cloudcontainer.deposit.42") as Bool  ; ammunition
  _toggleState13 = JsonUtil.GetPathIntValue(settingsfilepath,".settings.cloudcontainer.deposit.46") as Bool  ; ingestibles
  _toggleState14 = JsonUtil.GetPathIntValue(settingsfilepath,".settings.cloudcontainer.deposit.52") as Bool  ; soul gem
  _toggleState15 = JsonUtil.GetPathIntValue(settingsfilepath,".settings.cloudcontainer.deposit.26") as Bool  ; armor,cloth
  _toggleState16 = JsonUtil.GetPathIntValue(settingsfilepath,".settings.cloudcontainer.deposit.41") as Bool  ; weapons
  GetCloudDepositOptions()
  
endfunction
 
function VarValInit()
  
  progressVar = "x                                                            x"
  progressVarIndex = 1
  ;Gold001 = Game.GetFormFromFile(15,"Skyrim.esm")
  if filesCheckedYet != 1
    
    playerObj = playerRef as ObjectReference
    
    containerList = JsonUtil.StringListToArray(filePath, "multicontainername")
    ContainerHandler("sort")
    JsonUtil.Save(filePath)
    if containerList.length <= 0
      ContainerHandler("add","New Container")
    endif
    typeCodes = new Int[8]
    skillArray = new String[18]
    magicMods = new String[107]
    ;magicMods0 = new String[128]
    ccDepositTypeCodes = new Int[9]
    if !playerRef.HasSpell(cm_Spell_HighlightCloudContainer)
      playerRef.AddSpell(cm_Spell_HighlightCloudContainer)
    endif
    booksFilePathExists = MiscUtil.FileExists("data/SKSE/plugins/StorageUtilData/Ethereal Incarnation/cm_BookData.json")
    loseSomeWeightInstalled = MiscUtil.FileExists("data/LoseSomeWeight-LSW.esp")
    po3ExtenderInstalled = MiscUtil.FileExists("data/SKSE/plugins/po3_PapyrusExtender.dll")
    dontTouchFilePath = "../StorageUtilData/Ethereal Incarnation/cm_DONOTTOUCHTHIS.json"
    settingsfilepath = "../StorageUtilData/Ethereal Incarnation/cm_Settings.json"
    booksFilePath = "../StorageUtilData/Ethereal Incarnation/cm_BookData.json"
    toolScriptPathExists = MiscUtil.FileExists("data/Scripts/bm_tools.pex")
    filePath = "../StorageUtilData/Ethereal Incarnation/cm_etherealIncarnationData.json"
    booksMasterInstalled = MiscUtil.FileExists("data/booksMaster.esp")
    cUInstalled = MiscUtil.FileExists("data/SKSE/plugins/ConsoleUtilSSE.dll")
    dontTouchFilePathExists = MiscUtil.FileExists("data/SKSE/plugins/StorageUtilData/Ethereal Incarnation/cm_DONOTTOUCHTHIS.json")
    settingsfilepathExists = MiscUtil.FileExists("data/SKSE/plugins/StorageUtilData/Ethereal Incarnation/cm_Settings.json")
    ordinatorInstalled = MiscUtil.FileExists("data/Ordinator - Perks of Skyrim.esp") as Int
    adamantInstalled = MiscUtil.FileExists("data/Adamant.esp") as Int
    smithingPerksOverhaulInstalled = MiscUtil.FileExists("data/Smithing Perks Overhaul SE.esp") as Int
    vokriiInstalled = MiscUtil.FileExists("data/Vokrii - Minimalistic Perks of Skyrim.esp") as Int
    if MiscUtil.FileExists("PerkusMaximus_Mage.esp") as Int || MiscUtil.FileExists("PerkusMaximus_Master.esp") as Int || MiscUtil.FileExists("PerkusMaximus_Thief.esp") as Int || MiscUtil.FileExists("PerkusMaximus_Warrior.esp") as Int
      perkusMaximusInstalled = 1
    endif
    perkModInstalled = ordinatorInstalled + smithingPerksOverhaulInstalled + vokriiInstalled + adamantInstalled + perkusMaximusInstalled
    
    magicMods[0] = "Skyrim.esm"
    magicMods[1] = "Dawnguard.esm"
    magicMods[2] = "Dragonborn.esm"
    magicMods[3] = "Mining For Mages Redux.esp"
    magicMods[4] = "Chronomancy Spell Pack.esp"
    magicMods[5] = "LoreOfRuin.esp"
    magicMods[6] = "DS3 Spell Pack.esp"
    magicMods[7] = "mihailfirewyrm.esp"
    magicMods[8] = "agni3.esp"
    magicMods[9] = "Cosmic Spells.esp"
    magicMods[10] = "Dukkhas Forbidden Death Magic.esp"
    magicMods[11] = "AnnaDruidConjuration.esp"
    magicMods[12] = "MysticismMagic.esp"
    magicMods[13] = "OverlordMagic.esp"
    magicMods[14] = "Odin - Skyrim Magic Overhaul.esp"
    magicMods[15] = "Daedric Entity Restoration Project.esp"
    magicMods[16] = "AwakenedMagicka.esp"
    magicMods[17] = "AetherialTomes.esp"
    magicMods[18] = "Tomebound.esp"
    magicMods[19] = "Arcanum.esp"
    magicMods[20] = "ReachMage.esp"
    magicMods[21] = "The Career Mage.esp"
    magicMods[22] = "khajitdave-necromanticsummons-v01.esp"
    magicMods[23] = "Phenderix Magic Evolved.esp"
    magicMods[24] = "Use the Force Skyrim.esp"
    magicMods[25] = "Triumvirate - Mage Archetypes.esp"
    magicMods[26] = "DragonMonarch's Master Spells.esp"
    magicMods[27] = "New Skyrim Master Spells.esp"
    magicMods[28] = "TheDarkPathSpells.esp"
    magicMods[29] = "DustAdept.esp"
    magicMods[30] = "Dwemertech - Magic of the Dwarves.esp"
    magicMods[31] = "MJHSynthesisRedux.esp"
    magicMods[32] = "Air Spells.esp"
    magicMods[33] = "ColdharbourDaedra.esp"
    magicMods[34] = "PathOfTheAntiMage.esp"
    magicMods[35] = "Darkspell01.esp"
    magicMods[36] = "ForgottenMagic_Redone.esp"
    magicMods[37] = "GlamorilLite.esp"
    magicMods[38] = "The Dark Arts.esp"
    magicMods[39] = "Apocalypse - Magic of Skyrim.esp"
    magicMods[40] = "CorpseToCoinage.esp"
    magicMods[41] = "Apocalypse - Waterstride Spell Addon.esp"
    magicMods[42] = "Elemental Destruction Magic Redux.esp"
    magicMods[43] = "Apocalypse - More Apocalypse.esp"
    magicMods[44] = "Undriel_SummonIceHorse.esp"
    magicMods[45] = "Calling of the Conjurer.esp"
    magicMods[46] = "ShadowSpellPackage.esp"
    magicMods[47] = "ShadefireSpellsV.1.1.esp"
    magicMods[48] = "SummonSkaafins.esp" ; Summon Mihail's Skaafins
    magicMods[49] = "rt_teleportation.esp" ; RustyTrader's Teleportation SSE
    magicMods[50] = "Cure Disease Spell of Stendarr - SE.esl"
    magicMods[51] = "Unrelenting Flame Spells and Enchanted Sword.esp"
    magicMods[52] = "fta_TES5BoundEquipLootTable.esp"
    magicMods[53] = "RedLightningSpells.esp"
    magicMods[54] = "Arcane Miscellanea.esp"
    magicMods[55] = "Summon Gallus SE.esp"
    magicMods[56] = "UndeathFixes.esp"
    magicMods[57] = "DHSpell.esp"
    magicMods[58] = "survival_spells.esp"
    magicMods[59] = "EnchantedArsenal.esp"
    magicMods[60] = "Crimson Storm.esp"
    magicMods[61] = "DaxafaganSpells.esp"
    magicMods[62] = "MidasSkyrim.esp"
    magicMods[63] = "FestusKrexSpell.esp"
    magicMods[64] = "FestusKrexSpell.esl"
    magicMods[65] = "SuckLife.esp"
    magicMods[66] = "NecromancySpellsPack.esp"
    magicMods[67] = "ZCSkyrimTeleportationCollection.esp"
    magicMods[68] = "Atom Bomb.esp"
    magicMods[69] = "Levin.esp"
    magicMods[70] = "Dishonored Blink.esp"
    magicMods[71] = "PotentBasicSpells.esp"
    magicMods[72] = "Archmage Eye Of Magnus and Spells.esp"
    magicMods[73] = "SummonSkeleton.esp"
    magicMods[74] = "LiamsConjurationSpells.esp"
    magicMods[75] = "Skyrim Immersive Creatures Special Edition.esp"
    magicMods[76] = "JJSC.esp"
    magicMods[77] = "Z Mage light.esp"
    magicMods[78] = "Destruction Mage's Compendium.esp"
    magicMods[79] = "Yeetus Magic Destruction Spells.esp"
    magicMods[80] = "Z Cyclone -Spell type-.esp"
    magicMods[81] = "SpellCollection.esp"
    magicMods[82] = "CrowdControlExtended.esp"
    magicMods[83] = "CurePoisonSpellV1.1.esp"
    magicMods[84] = "CurePoisonSpell (truly deadly poisons).esp"
    magicMods[85] = "DragonGuard.esp"
    magicMods[86] = "Interactive Summons And Illusions.esp"
    magicMods[87] = "Z Acceleration.esp"
    magicMods[88] = "SkeletonResisReanimateNoMore.esp"
    magicMods[89] = "MJResto.esp"
    magicMods[90] = "Conjurer's Compendium.esp"
    magicMods[91] = "UndeadWerewolfSE.esp"
    magicMods[92] = "Dwemerend.esp"
    magicMods[93] = "Summon Astrid SE.esp"
    magicMods[94] = "shehaiblu.esp"
    magicMods[95] = "shehai.esp"
    magicMods[96] = "Z Flame Atronach.esp"
    magicMods[97] = "DLC1Uni.esp"
    magicMods[98] = "hovering torch.esp"
    magicMods[99] = "ConjurationThrallsExpanded.esp"
    magicMods[100] = "Blastbones.esp"
    magicMods[101] = "MarkRecallNPC.esp"
    magicMods[102] = "Wasserwandeln SE.esp"
    magicMods[103] = "Waterwalking.esp"
    magicMods[104] = "SOTI.esp" ; Spells of the Initiate
    magicMods[105] = "Alteration Muffle and Invisibility.esp"
    magicMods[106] = "Glenmoril.esm"
    magicMods[107] = "IHarvest.esl"
    magicMods[108] = "ProgressiveNoviceSpells.esl"
    magicMods[109] = "Astral.esp"
;/  magicMods[110] = ""
    magicMods[111] = ""
    magicMods[112] = ""
    magicMods[113] = ""
    magicMods[114] = ""
    magicMods[115] = ""
    magicMods[116] = ""
    magicMods[117] = ""
    magicMods[118] = ""
    magicMods[119] = ""
    magicMods[120] = ""
    magicMods[121] = ""
    magicMods[122] = ""
    magicMods[123] = ""
    magicMods[124] = ""
    magicMods[125] = ""
    magicMods[126] = ""
    magicMods[127] = "" /;
    
;/    magicMods0[0] = ""
    magicMods0[1] = ""
    magicMods0[2] = ""
    magicMods0[3] = ""
    magicMods0[4] = ""
    magicMods0[5] = ""
    magicMods0[6] = ""
    magicMods0[7] = ""
    magicMods0[8] = ""
    magicMods0[9] = ""
    magicMods0[10] = ""
    magicMods0[11] = ""
    magicMods0[12] = ""
    magicMods0[13] = ""
    magicMods0[14] = ""
    magicMods0[15] = ""
    magicMods0[16] = ""
    magicMods0[17] = ""
    magicMods0[18] = ""
    magicMods0[19] = ""
    magicMods0[20] = ""
    magicMods0[21] = ""
    magicMods0[22] = ""
    magicMods0[23] = ""
    magicMods0[24] = ""
    magicMods0[25] = ""
    magicMods0[26] = ""
    magicMods0[27] = ""
    magicMods0[28] = ""
    magicMods0[29] = ""
    magicMods0[30] = ""
    magicMods0[31] = ""
    magicMods0[32] = ""
    magicMods0[33] = ""
    magicMods0[34] = ""
    magicMods0[35] = ""
    magicMods0[36] = ""
    magicMods0[37] = ""
    magicMods0[38] = ""
    magicMods0[39] = ""
    magicMods0[40] = ""
    magicMods0[41] = ""
    magicMods0[42] = ""
    magicMods0[43] = ""
    magicMods0[44] = ""
    magicMods0[45] = ""
    magicMods0[46] = ""
    magicMods0[47] = ""
    magicMods0[48] = ""
    magicMods0[49] = ""
    magicMods0[50] = ""
    magicMods0[51] = ""
    magicMods0[52] = ""
    magicMods0[53] = ""
    magicMods0[54] = ""
    magicMods0[55] = ""
    magicMods0[56] = ""
    magicMods0[57] = ""
    magicMods0[58] = ""
    magicMods0[59] = ""
    magicMods0[60] = ""
    magicMods0[61] = ""
    magicMods0[62] = ""
    magicMods0[63] = ""
    magicMods0[64] = ""
    magicMods0[65] = ""
    magicMods0[66] = ""
    magicMods0[67] = ""
    magicMods0[68] = ""
    magicMods0[69] = ""
    magicMods0[70] = ""
    magicMods0[71] = ""
    magicMods0[72] = ""
    magicMods0[73] = ""
    magicMods0[74] = ""
    magicMods0[75] = ""
    magicMods0[76] = ""
    magicMods0[77] = ""
    magicMods0[78] = ""
    magicMods0[79] = ""
    magicMods0[80] = ""
    magicMods0[81] = ""
    magicMods0[82] = ""
    magicMods0[83] = ""
    magicMods0[84] = ""
    magicMods0[85] = ""
    magicMods0[86] = ""
    magicMods0[87] = ""
    magicMods0[88] = ""
    magicMods0[89] = ""
    magicMods0[90] = ""
    magicMods0[91] = ""
    magicMods0[92] = ""
    magicMods0[93] = ""
    magicMods0[94] = ""
    magicMods0[95] = ""
    magicMods0[96] = ""
    magicMods0[97] = ""
    magicMods0[98] = ""
    magicMods0[99] = ""
    magicMods0[100] = ""
    magicMods0[101] = ""
    magicMods0[102] = ""
    magicMods0[103] = ""
    magicMods0[104] = ""
    magicMods0[105] = ""
    magicMods0[106] = "" /;
    
    typeCodes[0] = 30
    typeCodes[1] = 42
    typeCodes[2] = 26
    typeCodes[3] = 27
    typeCodes[4] = 46
    typeCodes[5] = 32
    typeCodes[6] = 52
    typeCodes[7] = 41
    
    skillArray[0] = "OneHanded"
    skillArray[1] = "TwoHanded"
    skillArray[2] = "Marksman"
    skillArray[3] = "Block"
    skillArray[4] = "Smithing"
    skillArray[5] = "HeavyArmor"
    skillArray[6] = "LightArmor"
    skillArray[7] = "Pickpocket"
    skillArray[8] = "Lockpicking"
    skillArray[9] = "Sneak"
    skillArray[10] = "Alchemy"
    skillArray[11] = "Speechcraft"
    skillArray[12] = "Alteration"
    skillArray[13] = "Conjuration"
    skillArray[14] = "Destruction"
    skillArray[15] = "Illusion"
    skillArray[16] = "Restoration"
    skillArray[17] = "Enchanting"
    
    Pages = new String[6]
    Pages[0] = "Inventory"
    Pages[1] = "Transcription"
    Pages[2] = "Stored Data"
    Pages[3] = "Addons-Settings"
    Pages[4] = " Containers"
    Pages[5] = "Dev Tools"
    
    JsonUtil.Load(dontTouchFilePath)
    JsonUtil.Load(settingsfilepath)
    JsonUtil.Load(booksFilePath)
    JsonUtil.Load(filePath)
    modsToSkipSpells = JsonUtil.StringListToArray(dontTouchFilePath, "modstoskipspells")
    modsToSkipItems = JsonUtil.StringListToArray(dontTouchFilePath, "modstoskipitems")
 
    SaveModListJson()
 
    filesCheckedYet = 1
    
  endif
 
 
  LoadSettings()
  GetCloudDepositOptions()
  LoadStats()
  GetStats()
  
endfunction
 
;--------------------SKYUI VERSION CONTROL----------------------------------------------------
 
event OnVersionUpdate(Int a_version)
  Int newVersion = 9821
  if (a_version >= newVersion && CurrentVersion < newVersion)
    Debug.Notification("Ethereal Incarnation updating to version " + a_version)
    OnConfigInit()
  endif
endEvent
 
Int function GetVersion()
 
  return 9821 ;0.9821
  
endFunction
 
FormList Property cm_itemsToSkip  Auto  
 
ReferenceAlias Property cm_CloudContainer09  Auto  
 
FormList Property cm_vanillaMapMarkers  Auto  
 
SPELL Property cm_Spell_HighlightCloudContainer Auto  
 
FormList Property cm_vanillaBooks  Auto  
 
FormList Property cm_Shouts  Auto  
 
FormList Property cm_WordsOfPower  Auto  
 
FormList Property cm_vanillaSpells  Auto  
 
ActorBase Property playerBase  Auto  
 
FormList Property cm_contentsPlayerInventory  Auto  
 
FormList Property cm_contentsCloudContainer  Auto  
 
FormList Property cm_contentsChest  Auto  
 
FormList Property cm_genericChest  Auto  
ReferenceAlias Property playerRefAlias  Auto  
 
MiscObject Property Gold001  Auto  

Comments