-- -- -- Sky Indent PROXiCiDE aka Taewon -- Version 0.5 -- -- Allows you to beautify Papyrus source code -- -- Steam: http://steamcommunity.com/id/PROXiCiDE -- Nexus: http://skyrim.nexusmods.com/users/3018315 -- Bethesda: http://forums.bethsoft.com/user/425376-taewon/ -- -- -- Version History -- 0.5 Support for SKSE 1.7.0, SkyUI 4.1 -- 0.4 -- Keywords for Functions and Events used to be generated from the Creation Kit WIKI -- Functions and Events are now parsed from a collection of Papyrus source code -- Alot eaiser to keep SkyIndent updated -- -- Reason was because there are undocumented functions and shortcuts -- Example GetRef() -> GetReference() -- -- *.PSC -- Skyrim default -- SkyUI -- SKSE -- 0.3 -- Optimizations, supports SKSE Events / Functions -- File size of SkyIndent.lua has been reduced significantly -- 0.2b -- Fixed array indentation -- 0.2a -- Tab spacing is the default if no option -s# passed in the command line arguments -- 0.1a -- Initial Release -- -- local StrLen = string.len local StrSub = string.sub local StrByte = string.byte local StrChar = string.char local StrRep = string.rep local StrFormat = string.format local OsExit = os.exit local function OsError(str) print('Error: '..StrFormat(str)) os.execute("pause") OsExit(1) end local program = nil local codeTable01 = {} local codeTable02 = {} local function EraseTable(t) for k in next,t do t[k] = nil end end local function StrIns(s, pos, insertStr) return StrSub(s, 1, pos) .. insertStr .. StrSub(s, pos + 1) end local function StrDel(s, pos1, pos2) return StrSub(s, 1, pos1 - 1) .. StrSub(s, pos2 + 1) end local Lexer = {} local TokenData = {} TokenData.AND = 1 TokenData.ASSIGNMENT = 2 TokenData.ASTERISK = 3 TokenData.CIRCUMFLEX = 4 TokenData.COLON = 5 TokenData.COMMA = 6 TokenData.COMMENT_LONG = 7 TokenData.COMMENT_SHORT = 8 TokenData.DOUBLEPERIOD = 9 TokenData.EQUALITY = 10 TokenData.GT = 11 TokenData.GTE = 12 TokenData.IDENTIFIER = 13 TokenData.KEYWORD = 14 TokenData.LEFTBRACKET = 15 TokenData.LEFTPAREN = 16 TokenData.LEFTWING = 17 TokenData.LINEBREAK = 18 TokenData.LT = 19 TokenData.LTE = 20 TokenData.MINUS = 21 TokenData.NOT = 22 TokenData.NE = 23 TokenData.NUMBER = 24 TokenData.OR = 25 TokenData.MODULO = 26 TokenData.PERIOD = 27 TokenData.PLUS = 28 TokenData.RIGHTBRACKET = 29 TokenData.RIGHTPAREN = 30 TokenData.RIGHTWING = 31 TokenData.SEMICOLON = 32 TokenData.SLASH = 33 TokenData.SPECIAL = 34 TokenData.STRING = 35 TokenData.TRIPLEPERIOD = 37 TokenData.UNKNOWN = 38 TokenData.VERTICAL = 39 TokenData.WHITESPACE = 40 -- ascii codes local ByteData = {} ByteData.LINEBREAK_UNIX = StrByte("\n") ByteData.LINEBREAK_MAC = StrByte("\r") ByteData.SINGLE_QUOTE = StrByte("'") ByteData.DOUBLE_QUOTE = StrByte('"') ByteData.NUM_0 = StrByte("0") ByteData.NUM_9 = StrByte("9") ByteData.PERIOD = StrByte(".") ByteData.SPACE = StrByte(" ") ByteData.TAB = StrByte("\t") ByteData.E = StrByte("E") ByteData.e = StrByte("e") ByteData.MINUS = StrByte("-") ByteData.EQUALS = StrByte("=") ByteData.LEFTBRACKET = StrByte("[") ByteData.RIGHTBRACKET = StrByte("]") ByteData.BACKSLASH = StrByte("\\") ByteData.COMMA = StrByte(",") ByteData.SEMICOLON = StrByte(";") ByteData.COLON = StrByte(":") ByteData.LEFTPAREN = StrByte("(") ByteData.RIGHTPAREN = StrByte(")") ByteData.EXCLAMATIONMARK = StrByte("!") ByteData.PLUS = StrByte("+") ByteData.SLASH = StrByte("/") ByteData.LEFTWING = StrByte("{") ByteData.RIGHTWING = StrByte("}") ByteData.CIRCUMFLEX = StrByte("^") ByteData.ASTERISK = StrByte("*") ByteData.LESSTHAN = StrByte("<") ByteData.GREATERTHAN = StrByte(">") ByteData.AND = StrByte("&") ByteData.OR = StrByte("|") ByteData.MODULO = StrByte("%") local newline = {} newline[ByteData.LINEBREAK_UNIX] = 1 newline[ByteData.LINEBREAK_MAC] = 1 local whitespaces = {} whitespaces[ByteData.SPACE] = 1 whitespaces[ByteData.TAB] = 1 local SymbolData = {} SymbolData[ByteData.PERIOD] = -1 SymbolData[ByteData.LESSTHAN] = -1 SymbolData[ByteData.GREATERTHAN] = -1 SymbolData[ByteData.LEFTBRACKET] = -1 SymbolData[ByteData.EQUALS] = -1 SymbolData[ByteData.MINUS] = -1 SymbolData[ByteData.SINGLE_QUOTE] = -1 SymbolData[ByteData.DOUBLE_QUOTE] = -1 SymbolData[ByteData.EXCLAMATIONMARK] = -1 SymbolData[ByteData.SEMICOLON] = -1 SymbolData[ByteData.RIGHTBRACKET] = TokenData.RIGHTBRACKET SymbolData[ByteData.COMMA] = TokenData.COMMA SymbolData[ByteData.COLON] = TokenData.COLON SymbolData[ByteData.LEFTPAREN] = TokenData.LEFTPAREN SymbolData[ByteData.RIGHTPAREN] = TokenData.RIGHTPAREN SymbolData[ByteData.PLUS] = TokenData.PLUS SymbolData[ByteData.SLASH] = TokenData.SLASH SymbolData[ByteData.LEFTWING] = TokenData.LEFTWING SymbolData[ByteData.RIGHTWING] = TokenData.RIGHTWING SymbolData[ByteData.CIRCUMFLEX] = TokenData.CIRCUMFLEX SymbolData[ByteData.ASTERISK] = TokenData.ASTERISK SymbolData[ByteData.OR] = -1 SymbolData[ByteData.AND] = -1 SymbolData[ByteData.MODULO] = TokenData.MODULO -- The following was generated from the Creation Kit wiki -- http://www.creationkit.com/Keyword_Reference local IndentIgnore = {0, 0} local IndentLeft = {-1, 0} local IndentRight = {0, 1} local IndentBoth = {-1, 1} function IndentType(t) local s={} table.insert(s, { name = string.lower(t[1]), orig = t[1], type = t[2] }) return s end KeywordReferenceData = { IndentType {"Else",IndentBoth}, IndentType {"ElseIf",IndentBoth}, IndentType {"Native",IndentIgnore}, IndentType {"New",IndentIgnore}, IndentType {"As",IndentIgnore}, IndentType {"Int",IndentIgnore}, IndentType {"Length",IndentIgnore}, IndentType {"Import",IndentIgnore}, IndentType {"None",IndentIgnore}, IndentType {"Parent",IndentIgnore}, IndentType {"Property",IndentIgnore}, IndentType {"String",IndentIgnore}, IndentType {"Hidden",IndentIgnore}, IndentType {"Self",IndentIgnore}, IndentType {"Return",IndentIgnore}, IndentType {"ScriptName",IndentIgnore}, IndentType {"True",IndentIgnore}, IndentType {"Global",IndentIgnore}, IndentType {"Float",IndentIgnore}, IndentType {"Bool",IndentIgnore}, IndentType {"AutoReadOnly",IndentIgnore}, IndentType {"Extends",IndentIgnore}, IndentType {"False",IndentIgnore}, IndentType {"Auto",IndentIgnore}, IndentType {"EndEvent",IndentLeft}, IndentType {"EndFunction",IndentLeft}, IndentType {"EndIf",IndentLeft}, IndentType {"EndProperty",IndentLeft}, IndentType {"EndState",IndentLeft}, IndentType {"EndWhile",IndentLeft}, IndentType {"If",IndentRight}, IndentType {"State",IndentRight}, IndentType {"Event",IndentRight}, IndentType {"Function",IndentRight}, IndentType {"While",IndentRight}, } function FindKeywordReference(name) for k,v in ipairs(KeywordReferenceData) do if string.lower(name) == v[1].name then return v[1].name,v[1].orig,v[1].type end end return nil,nil,nil end -- The following was generated from the Creation Kit wiki -- http://www.creationkit.com/Category:Script_Objects function CaseType(t) local s={} for i,v in ipairs(t) do s[string.lower(v)]=v end return s end ScriptObjects = CaseType { "Action", "Activator", "ActiveMagicEffect", "Actor", "ActorBase", "ActorValueInfo", "Alias", "Ammo", "Apparatus", "Armor", "ArmorAddon", "Art", "AssociationType", "Book", "Cell", "Class", "ColorForm", "CombatStyle", "ConstructibleObject", "Container", "Debug", "DefaultObjectManager", "Door", "EffectShader", "Enchantment", "EncounterZone", "EquipSlot", "Explosion", "Faction", "Flora", "Form", "FormList", "Furniture", "Game", "GlobalVariable", "Hazard", "HeadPart", "Idle", "ImageSpaceModifier", "ImpactDataSet", "Ingredient", "Input", "Key", "Keyword", "LeveledActor", "LeveledItem", "LeveledSpell", "Light", "Location", "LocationAlias", "LocationRefType", "MagicEffect", "Math", "Message", "MiscObject", "ModEvent", "MusicType", "NetImmerse", "ObjectReference", "Outfit", "Package", "Perk", "Potion", "Projectile", "Quest", "Race", "ReferenceAlias", "Scene", "Scroll", "Shout", "SKSE", "SoulGem", "Sound", "SoundCategory", "SoundDescriptor", "Spell", "Static", "StringUtil", "TalkingActivator", "TextureSet", "Topic", "TopicInfo", "Tree", "UI", "UICallback", "Utility", "VisualEffect", "VoiceType", "Weapon", "Weather", "WordOfPower", "WorldSpace", "WornObject", } -- The following used to be generated from the Creation Kit wiki -- http://www.creationkit.com/Category:Papyrus -- -- Now generated from a collection of Papyrus files ApiData = CaseType { -- Generated data for Skyrim "IsFurnitureMarkerInUse", "GetSunPositionX", "Dismount", "ToggleCollisions", "CanFlyHere", "ShowLimitedRaceMenu", "SetAV", "GetPlayerGrabbedRef", "SetFogPower", "SetDestroyed", "KillSilent", "TryToClear", "RemoveShout", "ClearTempEffects", "KeepOffsetFromActor", "HasForm", "SetProtected", "IsInInterior", "SetCrimeGold", "GetGiftFilter", "Resurrect", "StopObjectProfiling", "CanPayCrimeGold", "GetRace", "Dispel", "FindRandomReferenceOfAnyTypeInListFromRef", "TraceAndBox", "ForceMovementRotationSpeedRamp", "HasCommonParent", "StartScriptProfiling", "IsFightingControlsEnabled", "SetCrimeFaction", "GetValueInt", "RegisterForUpdateGameTime", "IsStopping", "SetActorOwner", "GetEquippedWeapon", "ShowTitleSequenceMenu", "GetAlias", "HasLOS", "IsMapMarkerVisible", "GetActorOwner", "CenterOnCellAndWait", "GetLeveledActorBase", "TryToEvaluatePackage", "HasParentRelationship", "SetCleared", "SetValueInt", "SetEnemy", "GetKiller", "TryToRemoveFromFaction", "UnequipItem", "CaptureFrameRate", "GetEditorLocation", "StartStackProfiling", "FailAllObjectives", "SetSubGraphFloatVariable", "IsActive", "HasMagicEffectWithKeyword", "AddItem", "PlaySyncedAnimationAndWaitSS", "FindClosestReferenceOfAnyTypeInListFromRef", "FindClosestReferenceOfTypeFromRef", "SetMotionType", "MoveToPackageLocation", "GetCurrentWeatherTransition", "IsSneakingControlsEnabled", "AddInventoryEventFilter", "GetAt", "GetSize", "GetBudgetCount", "IncrementSkill", "ClearLookAt", "Show", "IsInFaction", "QuitGame", "PlayerKnows", "TriggerScreenBlood", "WornHasKeyword", "GetGoldValue", "IsBeingRidden", "GetAVPercentage", "SetObjectiveDisplayed", "TraceStack", "SetPublic", "GetLockLevel", "Ceiling", "RemoveDependentAnimatedObjectReference", "DoCombatSpellApply", "SetLockLevel", "FindClosestActor", "PlayImpactEffect", "StartDeferredKill", "AddAchievement", "GetBribeAmount", "SetINIFloat", "GetLocation", "MessageBox", "SetDontMove", "SetAttackActorOnSight", "SetHeadTracking", "UnequipSpell", "ShowGiftMenu", "AddDependentAnimatedObjectReference", "ForceMovementDirection", "GetPositionY", "SetAnimationVariableInt", "SetPlayerAIDriven", "UnequipShout", "AddPerk", "SetFootIK", "ForceAV", "GetAnimationVariableInt", "ModAV", "SetInvulnerable", "ToggleMenus", "CenterOnCell", "ForceLocationTo", "GetAnimationVariableFloat", "DumpAliasData", "GetAngleZ", "SetAllowFlying", "AddToMap", "RemoveSpell", "GetStolenItemValueCrime", "BlockActivation", "GetAssociatedSkill", "SetINIBool", "SetAngle", "SetPlayerReportCrime", "SendTrespassAlarm", "RemoveItem", "TryToReset", "ShowBarterMenu", "FindRandomReferenceOfAnyTypeInList", "ForceRefTo", "SplineTranslateToRefNode", "TrapSoul", "IsUnique", "Lock", "ModReaction", "GetPositionZ", "ShakeCamera", "SendStealAlarm", "GetHeadingAngle", "GetInfamy", "PlaceActorAtMe", "ClearExpressionOverride", "ClearKeepOffsetFromActor", "Notification", "SetOpen", "GetDialogueTarget", "Delete", "IsAllowedToFly", "IsActivationBlocked", "EnableNoWait", "GetDeadCount", "UnregisterForUpdate", "Pause", "SetPlayerControls", "DrawWeapon", "RemoveFromAllFactions", "GetNoBleedoutRecovery", "GetPlatformName", "IsCleared", "SetOutfit", "IsInCombat", "FindRandomReferenceOfType", "SetFogPlanes", "AdvanceSkill", "IsPlayerTeammate", "WillIntimidateSucceed", "FindRandomReferenceOfTypeFromRef", "Reset", "UnregisterForLOS", "IsPlayerSungazing", "GetAngleX", "OpenInventory", "HasEffectKeyword", "Clear", "GetConfigName", "IsLocked", "TraceConditional", "ShowAsHelpMessage", "FindRandomActorFromRef", "FindRandomActor", "LearnAllEffects", "UnregisterForUpdateGameTime", "IsEquipped", "IsDead", "AttachAshPile", "HasAssociation", "IsActivateChild", "GetFactionRank", "GetHighestRelationshipRank", "LearnEffect", "LearnNextEffect", "GetForm", "FadeOutGame", "TraceUser", "PathToReference", "GetEquippedShout", "IsInKillMove", "GetAverageFrameRate", "SetPlayerExpelled", "UnLockOwnedDoorsInCell", "SetActorCause", "GetCurrentScene", "SetVehicle", "OverBudget", "GetSunPositionZ", "GetCurrentPackage", "SetPosition", "GameTimeToString", "GetLowestRelationshipRank", "Play", "AddHavokBallAndSocketConstraint", "IsInLocation", "ClearExtraArrows", "EquipItem", "GetMinFrameRate", "RegisterForUpdate", "SetHudCartMode", "IsInMenuMode", "PushActorAway", "IsActivateControlsEnabled", "StopInstance", "GetSitState", "SetEssential", "DisableLinkChain", "HasSpell", "ForceTargetSpeed", "IsNearPlayer", "ResetHelpMessage", "Start", "IsDetectedBy", "TakeScreenshot", "CalculateFavorCost", "SetINIString", "RemoveInventoryEventFilter", "ClearPrison", "GetStolenItemValueNoCrime", "RegisterForAnimationEvent", "Floor", "StartObjectProfiling", "Mod", "EquipSpell", "GetSkyMode", "IsFastTravelEnabled", "SendAnimationEvent", "AddToFaction", "GetOutgoingWeather", "GetItemHealthPercent", "GetKeywordData", "GetClassification", "SetEyeTexture", "FindWeather", "ForceActive", "ReleaseOverride", "ForceThirdPerson", "IgnoreFriendlyHits", "Fire", "IsPlayersLastRiddenHorse", "GetBudgetName", "GetCurrentBudget", "GetCurrentMemory", "HasKeyword", "IsLoaded", "GetTriggerObjectCount", "CreateDetectionEvent", "GetNthLinkedRef", "GetGameSettingInt", "GetCombatTarget", "GetPlayersLastRiddenHorse", "UnequipItemSlot", "SetINIInt", "GetCasterActor", "PlayTerrainEffect", "RandomInt", "SetLookAt", "GetCurrentGameTime", "SendWereWolfTransformation", "GetKey", "GetCurrentRealTime", "Unload", "Remove", "Preload", "IncrementStat", "ModCrimeGold", "TetherToHorse", "RemoteCast", "RemoveAllInventoryEventFilters", "RegisterForLOS", "SetFrequency", "GetCurrentWeather", "UnMute", "IsEssential", "Mute", "MoveTo", "GetPlayerControls", "SetInstanceVolume", "PlayAndWait", "PlayerMoveToAndWait", "MoveToMyEditorLocation", "IsActionComplete", "IsPlaying", "TryToEnableNoWait", "TryToEnable", "TryToMoveTo", "TryToKill", "ForceStart", "TryToDisableNoWait", "GetBaseAV", "TryToDisable", "IsAttached", "TryToStopCombat", "TryToAddToFaction", "IsProtected", "GetActorRef", "GetWorldSpace", "GetWidth", "PlayAnimation", "GetLinkedRef", "ModFactionRank", "ForceRefIfEmpty", "GetReference", "IsJournalControlsEnabled", "IsFastTravelControlsEnabled", "HideTitleSequenceMenu", "InterruptCast", "UnregisterForSleep", "SetIntimidated", "StartSneaking", "IsChild", "SetBeastForm", "IsSprinting", "IsSneaking", "ShowRaceMenu", "UnPause", "SetPlayerEnemy", "GetCurrentDestructionStage", "IsMenuControlsEnabled", "UpdateCurrentInstanceGlobal", "GetDistance", "GetCurrentStageID", "SetObjectiveFailed", "SetObjectiveCompleted", "GetActorReference", "SetActive", "IsStopped", "GetItemCount", "IsStageDone", "IsObjectiveFailed", "PrecacheCharGenClear", "IsDeleted", "DebugChannelNotify", "IsObjectiveDisplayed", "FindClosestActorFromRef", "SetExpressionOverride", "IsObjectiveCompleted", "PlayAnimationAndWait", "IsCompleted", "RemoveCrossFade", "IsDisabled", "GetInfamyViolent", "Enable", "GetStageDone", "GetStage", "SetStage", "IsAlerted", "RestoreActorValue", "CompleteQuest", "IsGuard", "StopScriptProfiling", "UnregisterForTrackedStatsEvent", "GetOpenState", "countLinkedRefChain", "SetValue", "GetTemplate", "WaitForAnimationEvent", "GetPlayer", "TranslateToRef", "StopTranslation", "RadiansToDegrees", "StopCombatAlarm", "SplineTranslateTo", "MakePlayerFriend", "RemoveAllItems", "TranslateTo", "IsMovementControlsEnabled", "GetOwningQuest", "UnregisterForAnimationEvent", "AllowBleedoutDialogue", "SetNoFavorAllowed", "acos", "GetParentCell", "ForceMovementSpeed", "GetRefTypeDeadCount", "SetAnimationVariableFloat", "GetCurrentLocation", "GetGameSettingFloat", "DisableNoWait", "ProcessTrapHit", "RandomFloat", "SetBribed", "GetBaseActorValue", "atan", "PlayGamebryoAnimation", "AddSpell", "GetRef", "IsFactionInCrimeGroup", "DropObject", "PlaceAtMe", "MoveToNode", "MoveToInteractionLocation", "KnockAreaEffect", "RemovePerk", "IsIgnoringFriendlyHits", "IsLockBroken", "IsInDialogueWithPlayer", "IsFurnitureInUse", "rampRumble", "IsEnabled", "HasRefType", "GetReaction", "FindClosestReferenceOfType", "HasNode", "EquipShout", "GetPositionX", "SetAlpha", "IsIntimidated", "EndFrameRateCapture", "QueryStat", "IsDoingFavor", "GetScale", "DBSendPlayerPosition", "SetReaction", "ToggleAI", "SendPlayerToJail", "ForceMovementSpeedRamp", "GetSelfAsActor", "GetMass", "EnableLinkChain", "ForceAddRagdollToWorld", "StartFrameRateCapture", "GetTargetActor", "SetCurrentStageID", "SetUnconscious", "GetLength", "SetVolume", "IsStarting", "GetHeight", "SetVoiceRecoveryTime", "SetAnimationVariableBool", "ClearDestruction", "UnequipAll", "DamageObject", "SetRelationshipRank", "GetEquippedSpell", "RegisterForSingleLOSGain", "ForceRemoveRagdollFromWorld", "Disable", "GetAngleY", "GetVoiceRecoveryTime", "GetAnimationVariableBool", "CompleteAllObjectives", "RequestSave", "StopCombat", "GetRelationshipRank", "CalculateEncounterLevel", "AddShout", "GetAV", "SetCriticalStage", "RestoreAV", "ApplyHavokImpulse", "GetClass", "ForceMovementDirectionRamp", "ForceTargetDirection", "Activate", "GetFactionReaction", "IsUnconscious", "AddKeyIfNeeded", "ModActorValue", "DeleteWhenAble", "MoveToWhenUnloaded", "GetForcedLandingMarker", "IsWeaponDrawn", "MoveToIfUnloaded", "IsAlarmed", "GetCrimeFaction", "GetEquippedShield", "ApplyCrossFade", "PlayIdle", "SetAllowFlyingEx", "set", "DamageActorValue", "GetActorValue", "Add", "RemoveFromFaction", "ClearForcedMovement", "tan", "IsBribed", "sqrt", "GetSleepState", "get", "pow", "DegreesToRadians", "Kill", "GetSex", "IsPlayerExpelled", "HasPerk", "cos", "GetMaxFrameRate", "PlaySyncedAnimationSS", "SetActorValue", "asin", "GetFormID", "IsArrestingTarget", "abs", "GetLightLevel", "EnableAI", "GetVersionNumber", "RequestModel", "StartCannibal", "SetGodMode", "SetKeywordData", "SetDoingFavor", "Find", "IsSameLocation", "Is3DLoaded", "GetRefTypeAliveCount", "PopTo", "Apply", "GetInfamyNonViolent", "IsGhost", "SendAssaultAlarm", "ModObjectiveGlobal", "ModFavorPointsWithGlobal", "EndDeferredKill", "SetGhost", "RegisterForTrackedStatsEvent", "WaitGameTime", "UsingGamepad", "ClearArrested", "IsInterior", "HasFamilyRelationship", "GetCrimeGoldViolent", "RegisterForSleep", "TeachWord", "ShowTrainingMenu", "SetSunGazeImageSpaceModifier", "SetAllowFlyingMountLandingRequests", "PlayerPayCrimeGold", "IsFlying", "StartTitleSequence", "ShakeController", "SetSittingRotation", "SetInChargen", "SetPlayerResistingArrest", "SetCameraTarget", "ServeTime", "GetBaseObject", "IsOnMount", "GetActorBase", "RequestAutoSave", "DamageAV", "IsBleedingOut", "EnableFastTravel", "SetNotShowOnStealthMeter", "PrecacheCharGen", "PlayIdleWithTarget", "IsWordUnlocked", "ForceMovementRotationSpeed", "ModFavorPoints", "GetGoldAmount", "ResetHealthAndLimbs", "SetPlayerTeammate", "IsCamSwitchControlsEnabled", "IncrementSkillBy", "IsArrested", "GetSunPositionY", "IsRunning", "SplineTranslateToRef", "GetGameSettingString", "WaitMenuMode", "GetFactionOwner", "ForceActorValue", "Say", "GetFormFromFile", "SetFactionRank", "sin", "FindClosestReferenceOfAnyTypeInList", "GetFlyingState", "IsHostileToActor", "RegisterForSingleLOSLost", "RemoveHavokConstraints", "GetActorValuePercentage", "ClearForcedLandingMarker", "Trace", "DispelSpell", "CanFastTravelToMarker", "FastTravel", "HasMagicEffect", "KillEssential", "QuitToMainMenu", "StopStackProfiling", "IsTrespassing", "AddPerkPoints", "RegisterForSingleUpdateGameTime", "GetVoiceType", "SetRace", "AddForm", "CloseUserLog", "GetRealHoursPassed", "SetForcedLandingMarker", "SetCrimeGoldViolent", "ShowFirstPersonGeometry", "GetEquippedItemType", "SetAlly", "PlaySubGraphAnimation", "GetCrimeGold", "ForceTargetAngle", "IsHostile", "EvaluatePackage", "ShowRefPosition", "OpenUserLog", "SetNoBleedoutRecovery", "RegisterForSingleUpdate", "GetLevel", "Cast", "RemoveAddedForm", "GetCombatState", "SetFactionOwner", "IsInvulnerable", "UnlockWord", "GetCrimeGoldNonViolent", "DispelAllSpells", "SetScale", "ForceFirstPerson", "GetValue", "StartVampireFeed", "IsLookingControlsEnabled", "StartCombat", "Wait", "SetRestrained", "IsCommandedActor", "Stop", "SetAlert", "AllowPCDialogue", "Revert", -- Generated data for SkyUI "AddMenuOptionST", "SetKeyMapOptionValue", "SetCursorFillMode", "SetTextOptionValueST", "SetTextOptionValue", "SetTitleText", "SetSliderOptionValue", "AddKeyMapOptionST", "UnloadCustomContent", "SetKeyMapOptionValueST", "SetCursorPosition", "SetSliderDialogStartValue", "CheckVersion", "SetInfoText", "SetMenuDialogOptions", "SetSliderDialogDefaultValue", "AddEmptyOption", "SetColorOptionValueST", "SetSliderDialogRange", "SetMenuDialogDefaultIndex", "AddToggleOptionST", "GetCustomControl", "Guard", "AddHeaderOption", "SetMenuOptionValueST", "SetSliderOptionValueST", "SetToggleOptionValueST", "SetOptionFlagsST", "AddColorOptionST", "AddSliderOptionST", "SetSliderDialogInterval", "ShowMessage", "AddSliderOption", "AddToggleOption", "AddTextOptionST", "AddMenuOption", "SetOptionFlags", "LoadCustomContent", "GetVersion", "AddTextOption", "SetColorDialogStartColor", "AddColorOption", "SetColorDialogDefaultColor", "SetMenuDialogStartIndex", "SetMenuOptionValue", "SetToggleOptionValue", "ForcePageReset", "AddKeyMapOption", "SetColorOptionValue", -- Generated data for SKSE "GetNumHeadParts", "SetNthEffectMagnitude", "GetNthLevel", "ModPerkPoints", "GetMeleePowerAttackStaggeredMult", "GetNthPlayableRace", "GetDescriptor", "SaveGame", "GetNthAdditionalRace", "GetWornForm", "GetNumParts", "GetIndexOfExtraPart", "GetNthPart", "SetMagicMult", "EquipItemById", "IsImmobile", "UpdateWeight", "GetMagicMult", "CanWalk", "LoadGame", "SetNthSpell", "GetIconPath", "GetNumTexturePaths", "SetIconPath", "GetFrequencyVariance", "SetNthLevel", "SetAllowPickpocket", "GetNthModDependency", "SetSkillLevel", "ResetInventory", "GetSpellCount", "LogicalAnd", "OpenCustomMenu", "GetVersionRelease", "PushStringA", "Release", "SetOffensiveMult", "GetNthSpell", "GetNthEntryText", "SetQuality", "IsLightArmor", "SetNthEntryText", "GetQuality", "GetNumIngredients", "GetNthCount", "TempClone", "MakeCanSwim", "GetNthEffectMagnitude", "ClearRaceFlag", "ClearAllowPCDialogue", "PushInt", "RegisterForCrosshairRef", "IsClothingHands", "SetArmorRating", "UnregisterForActorAction", "GetNthParent", "GetModName", "SetCloseRangeFlankingFlankDistance", "NoKnockdowns", "GetNthReferenceAlias", "UpdateTintMaskColors", "SetNthTintMaskTexturePath", "SetNthEffectDuration", "GetEquipAbility", "SetMeleeBashMult", "IsWarAxe", "SetEquipAbility", "GetMeleeBashMult", "GetNthEffectDuration", "GetNthTintMaskTexturePath", "SetPlayerKnows", "GetResult", "GetAllowDualWielding", "QueueNiNodeUpdate", "GetSkillLevel", "GetArmorRating", "GetCloseRangeFlankingStalkTime", "GetPerkPoints", "GetImpactDataSet", "IsStaff", "SetSlotMask", "GetIngredient", "GetNthEntrySpell", "GetCritMultiplier", "SetFrequencyVariance", "SetImpactDataSet", "GetINIFloat", "GetIsNthEffectKnown", "GetSlotMask", "GetSoulSize", "GetNthWordOfPower", "GetVersionBeta", "IsTakeable", "GetFormEx", "SetPerkPoints", "SetEnchantmentValue", "SetNthWordOfPower", "UnregisterForAllMenus", "GetModelNthTextureSet", "GetNumParents", "Substring", "GetAvoidThreatChance", "SetNthEntrySpell", "SetIngredient", "UnregisterForAllKeys", "SetEffectFlag", "SetArea", "GetNthTintMaskType", "MakeNonWalking", "SetAllowPCDialogue", "ClearNoKNockdowns", "GetString", "GetModByName", "SetString", "LogicalXor", "NoShadow", "GetChanceGlobal", "UnbindObjectHotkey", "GetType", "SetNthTintMaskColor", "SetAssociatedSkill", "TapKey", "GetActorValueInfoByID", "IsPrintable", "GetCloseRangeDuelingFallbackMult", "IsBattleaxe", "GetWeightClass", "AddSlotToMask", "CloseCustomMenu", "GetWornItemId", "HasKeywordString", "IsHarvested", "Invoke", "GetNextPerk", "SetNthTexturePath", "SetSkillImproveMult", "IsClothingBody", "IsMenuOpen", "GetID", "SetItemHealthPercent", "SetMeleeBashRecoiledMult", "UnregisterForCameraState", "SetNoShadow", "IsRaceFlagSet", "GetSunDamage", "RegenerateHead", "IsEffectFlagSet", "SetFlightDiveBombChance", "GetMeleeBashRecoiledMult", "UnregisterForAllModEvents", "GetAVIByName", "GetMaxRange", "GetActorValueInfoByName", "GetNthEntryValue", "SetMaxRange", "GetINIBool", "GetNumItems", "SetSkillOffsetMult", "SetFlightFlyingAttackChance", "GetGemSize", "GetNthTintMaskColor", "SetRed", "SetNthEntryValue", "SetMiscStat", "GetNthKeyword", "GetNumKeysPressed", "SetNthEntryPriority", "GetSkillOffsetMult", "GetArea", "SetDisplayName", "GetOutfit", "MakePushable", "GetRed", "GetValidRaces", "InvokeNumberA", "GetPerk", "SetEquippedModel", "ClearNoShadow", "GetNumber", "GetNthKeyPressed", "IsClothingRich", "SetNthEntryLeveledList", "GetNodePositionY", "GetEnchantShader", "SetChanceNone", "GetEquippedModel", "GetWindDirection", "AsChar", "SetEnchantShader", "GetLight", "IsCuirass", "GetGroupOffensiveMult", "SetGroupOffensiveMult", "UpdateHairColor", "IsGauntlets", "SetWorkbenchKeyword", "GetINIInt", "GetNthEntryRank", "SetSkin", "GetWorkbenchKeyword", "GetSkin", "GetNumAdditionalRaces", "IsShield", "IsTextInputEnabled", "GetDefaultVoiceType", "RegisterForModEvent", "IsHelmet", "GetSkillExperience", "GetStaffMult", "GetSkillImproveMult", "ClearEffectFlag", "SetWeightClass", "SetMeleeBashAttackMult", "IsJewelry", "IsClothing", "Send", "RemoveSlotFromMask", "GetAVIByID", "GetNthEntryLeveledList", "GetMappedControl", "SetValidRaces", "SetResist", "SetDefaultVoiceType", "LogicalNot", "SetNumber", "SetSkillExperience", "GetFlightHoverChance", "GetImageSpaceMod", "SetNthEntryQuest", "GetInt", "LeftShift", "SetNthIngredientQuantity", "SetFlightHoverChance", "IsFood", "GetNthEntryQuest", "GetFaceMorph", "SetInt", "GetNumForms", "SetTintMaskColor", "UnregisterForModEvent", "GetNumTintsByType", "SetFaceMorph", "SetImageSpaceMod", "GetSpell", "UnregisterForKey", "GetFacePreset", "IsMace", "SetHitEffectArt", "UpdateThirdPerson", "IsPunctuation", "SetWeight", "SetItemMaxCharge", "UnregisterForMenu", "GetPluginVersion", "InvokeString", "GetINIString", "SetCritEffectOnDeath", "SetStaffMult", "GetNthForm", "GetWeight", "GetTimeElapsed", "SetFacePreset", "SetForm", "GetBaseCost", "GetEnchantment", "SetRaceFlag", "GetNumExtraParts", "SetCritDamage", "GetName", "GetCritDamage", "SetName", "GetItemMaxCharge", "SetDecibelVariance", "SetPlayersLastRiddenHorse", "GetPlayerExperience", "GetTintMaskColor", "IsObjectFavorited", "IsChildRace", "GetReach", "GetExplosion", "GetNthAlias", "GetNthExtraPart", "SetBaseCost", "GetNthIngredientQuantity", "IsSword", "SetPlayerExperience", "SetEnchantment", "PushIntA", "SetCombatStyle", "UnregisterForAllControls", "GetCombatStyle", "CanSwim", "SetMeleePowerAttackBlockingMult", "Create", "GetSkillImproveOffset", "GetMeleePowerAttackBlockingMult", "GetFlightFlyingAttackChance", "SetCastingArt", "SetMeleeSpecialAttackMult", "IsClothingRing", "Log", "SetResistance", "SetNodeTextureSet", "GetPlayerMovementMode", "GetMeleeSpecialAttackMult", "GetModDescription", "SetResultQuantity", "GetModelPath", "SetCloseRangeDuelingCircleMult", "MakeNonSwimming", "GetResultQuantity", "GetSkinFar", "GetNodePositionX", "SetMinRange", "UnregisterForControl", "PushBool", "GetPerkTree", "IsSwimming", "GetDuration", "ClearNoCombatInWater", "GetSaturation", "MakeCanWalk", "SetSaturation", "IsKeyPressed", "GetCameraState", "SendModEvent", "MakeCanFly", "GetMaskForSlot", "GetBaseDamage", "GetNumArmorAddons", "SetNodeScale", "GetModAuthor", "GetCastingArt", "GetMessageIconPath", "GetNodeScale", "GetNumEffects", "GetNumOverlayHeadParts", "GetUnarmedMult", "GetFogDistance", "GetMeleeAttackStaggeredMult", "SetGameSettingBool", "GetColor", "GetDefensiveMult", "SetMeleeAttackStaggeredMult", "SetDefensiveMult", "InvokeInt", "MakeChildRace", "GetWindDirectionRange", "GetSunGlare", "IsWarhammer", "IsGreatsword", "IsDagger", "SetUnarmedMult", "SetAvoidThreatChance", "SetCritMultiplier", "GetCritEffectOnDeath", "SetCritEffect", "GetCritEffect", "GetResist", "GetNumEntries", "SetMeleeMult", "GetEnchantmentValue", "SetCloseRangeDuelingFallbackMult", "SetProjectile", "AvoidsRoads", "GetWeaponType", "GetBool", "SetNthHeadPart", "EquipItemEx", "GetModDependencyCount", "GetEnchantArt", "GetMeleeMult", "RegisterForControl", "GetIndexOfHeadPartByType", "SetEnchantArt", "SetStagger", "GetStagger", "SetSpeed", "GetSpeed", "GetMinRange", "AddSkillExperience", "GetMagnitude", "SetReach", "SetGameSettingInt", "SetBaseDamage", "UnregisterForCrosshairRef", "SetColor", "GetHue", "PushFloatA", "PushBoolA", "InvokeForm", "InvokeStringA", "InvokeFloatA", "AllowPickpocket", "InvokeIntA", "PushForm", "InvokeBoolA", "InvokeNumber", "InvokeFloat", "SetFaceTextureSet", "InvokeBool", "GetFloat", "SetFloat", "SetSkillUsageMult", "GetNthTexturePath", "SetMeleePowerAttackStaggeredMult", "SetLongRangeStrafeMult", "SetGoldValue", "IsLetter", "IsClothingHead", "GetTotalItemWeight", "GetEnableParent", "GetNthChar", "GetMeleeBashAttackMult", "SetHue", "PushString", "GetHitEffectArt", "IsDigit", "AsOrd", "GetCostliestEffectIndex", "SetNthEffectArea", "GetNthRef", "GetEffectiveMagickaCost", "GetNumTintMasks", "SetFrequencyShift", "SetNthEntryStage", "IsAIEnabled", "GetFrequencyShift", "SetSkill", "GetDecibelVariance", "SetDecibelAttenuation", "GetDecibelAttenuation", "GetResistance", "IsClothingPoor", "GetQuest", "GetScriptVersionRelease", "GetNthEntryStage", "GetAlpha", "HasExtraPart", "GetHotkeyBoundObject", "SetNthRecoveryTime", "GetVersionMinor", "GetNthRecoveryTime", "RegisterForActorAction", "SetChanceGlobal", "SetEquipType", "SetSkillImproveOffset", "GetSkill", "GetIndexOfOverlayHeadPartByType", "SetHitShader", "SetCantOpenDoors", "SetTintMaskTexturePath", "SetResult", "RegisterForCameraState", "ReplaceHeadPart", "IsSkill", "GetNumPlayableRaces", "GetCloseRangeFlankingFlankDistance", "ClearAvoidsRoads", "GetHarvestSound", "SetAvoidsRoads", "SetAR", "GetNumAliases", "SetNoCombatInWater", "NoCombatInWater", "SetPerk", "GetNumKeywords", "SetHeight", "GetNthArmorAddon", "SetCloseRangeFlankingStalkTime", "IsBow", "GetTintMaskTexturePath", "MakeNotPushable", "GetAR", "GetMagickaCost", "IsNotPushable", "MakeMobile", "MakeImmobile", "IsClothingFeet", "ClearCantOpenDoors", "SetModelNthTextureSet", "SetNthIngredient", "SetHairColor", "SetModelPath", "GetBaseEnchantment", "GetModCount", "CantOpenDoors", "SetSkinFar", "GetLongRangeStrafeMult", "IsOffLimits", "GetOffensiveMult", "RegisterForKey", "MakeNonFlying", "CanFly", "SetGameSettingString", "CreateEnchantment", "SetSkillLegendaryLevel", "GetCloseRangeDuelingCircleMult", "SetCastTime", "MakePlayable", "SetAllowDualWielding", "GetNthIngredient", "SetShoutMult", "IsPlayable", "GetExperienceForLevel", "GetRangedMult", "GetShoutMult", "UnequipItemEx", "GetFaceTextureSet", "GetProjectile", "HoldKey", "SetHarvestSound", "PushFloat", "MakeUnplayable", "SetBlue", "GetSkillLegendaryLevel", "SetGreen", "GetNthEffectMagicEffect", "SetMessageIconPath", "GetMappedKey", "GetGreen", "SetNthCount", "GetCastTime", "GetNthEntryPriority", "SetNthEntryRank", "GetNthHeadPart", "GetAliasByName", "IsRead", "GetEquippedObject", "GetDisplayName", "GetNumRefs", "ModArmorRating", "IsHeavyArmor", "SetHarvested", "GetSkillUseMult", "ModAR", "GetTotalArmorWeight", "GetSkillUsageMult", "SetSkillUseMult", "GetNumReferenceAliases", "GetNodePositionZ", "SetExplosion", "SetWeaponType", "SetBool", "GetPriority", "SetMeleeBashPowerAttackMult", "GetEquippedItemId", "SetClass", "GetBlue", "SetGameSettingFloat", "GetItemCharge", "LogicalOr", "RightShift", "GetFlightDiveBombChance", "SetItemCharge", "GetHeadPart", "ReleaseKey", "GetMeleeBashPowerAttackMult", "SetVoiceType", "GetEquipType", "GetHitShader", "GetNthOverlayHeadPart", "RegisterForMenu", "SetLight", "IsBoots", "GetModelNumTextureSets", "SheatheWeapon", "MakeNonChildRace", "GetChanceNone", "GetNthEffectArea", "GetKeyword", "MakeNoKnockdowns", "SetRangedMult", "GetHairColor", "ChangeHeadPart", "ClearAllowPickpocket", } -- The following used to be generated from the Creation Kit wiki -- http://www.creationkit.com/Category:Events -- -- Now generated from a collection of Papyrus files EventData = CaseType { -- Generated data for Skyrim "OnSell", "OnObjectUnequipped", "OnStoryIncreaseLevel", "OnPackageChange", "OnTranslationFailed", "OnUpdate", "OnRelease", "OnUpdateGameTime", "OnMagicEffectApply", "OnDestructionStageChanged", "OnDying", "OnStoryCraftItem", "OnPackageStart", "OnAnimationEventUnregistered", "OnGetUp", "OnClose", "OnTriggerLeave", "OnPackageEnd", "OnStoryIncreaseSkill", "OnItemAdded", "OnTranslationComplete", "OnWardHit", "OnTrigger", "OnDeath", "OnItemRemoved", "OnStoryFlatterNPC", "OnDetachedFromCell", "OnStoryPickLock", "OnCellDetach", "OnCellLoad", "OnOpen", "OnUnequipped", "OnSleepStop", "OnSpellCast", "OnTriggerEnter", "OnStoryNewVoicePower", "OnStoryInfection", "OnCombatStateChanged", "OnEffectFinish", "OnStoryEscapeJail", "OnStoryDialogue", "OnLocationChange", "OnRaceSwitchComplete", "OnEquipped", "OnTranslationAlmostComplete", "OnCellAttach", "OnStoryHello", "OnActivate", "OnStoryCure", "OnSleepStart", "OnLoad", "OnTrackedStatsEvent", "OnAnimationEvent", "OnPlayerBowShot", "OnStoryPlayerGetsFavor", "OnEffectStart", "OnPlayerLoadGame", "OnAttachedToCell", "OnSit", "OnEnterBleedout", "OnObjectEquipped", "OnLostLOS", "OnGrab", "OnTrapHitStop", "OnStoryBribeNPC", "OnStoryIntimidateNPC", "OnUnload", "OnRead", "OnLockStateChanged", "OnStoryActivateActor", "OnHit", "OnContainerChanged", "OnReset", "OnGainLOS", -- Generated data for SkyUI "OnHighlightST", "OnConfigInit", "OnSelectST", "OnColorOpenST", "OnPageReset", "OnSliderAcceptST", "OnKeyMapChangeST", "OnOptionKeyMapChange", "OnColorAcceptST", "OnOptionColorOpen", "OnConfigOpen", "OnGameReload", "OnInit", "OnOptionMenuOpen", "OnOptionColorAccept", "OnOptionDefault", "OnOptionMenuAccept", "OnMenuOpenST", "OnVersionUpdate", "OnOptionSliderAccept", "OnSliderOpenST", "OnOptionSelect", "OnMenuAcceptST", "OnConfigRegister", "OnDefaultST", "OnConfigClose", "OnOptionSliderOpen", "OnOptionHighlight", -- Generated data for SKSE "OnActorAction", "OnMenuOpen", "OnCrosshairRefChange", "OnMenuClose", "OnControlDown", "OnKeyUp", "OnKeyDown", "OnControlUp", "OnPlayerCameraState", } IndentData = {} IndentData[TokenData.LEFTPAREN] = IndentRight IndentData[TokenData.LEFTBRACKET] = IndentRight IndentData[TokenData.LEFTWING] = IndentRight IndentData[TokenData.RIGHTPAREN] = IndentLeft IndentData[TokenData.RIGHTBRACKET] = IndentLeft IndentData[TokenData.RIGHTWING] = IndentLeft -- -- -- function Lexer.NumberExponent(text, pos) local function IntExponent(text, pos) while true do local byte = StrByte(text, pos) if not byte then return TokenData.NUMBER, pos end if byte >= ByteData.NUM_0 and byte <= ByteData.NUM_9 then pos = pos + 1 else return TokenData.NUMBER, pos end end end local byte = StrByte(text, pos) if not byte then return TokenData.NUMBER, pos end if byte == ByteData.MINUS then byte = StrByte(text, pos + 1) if byte == ByteData.MINUS then return TokenData.NUMBER, pos end return IntExponent(text, pos + 1) end return IntExponent(text, pos) end function Lexer.NumberFraction(text, pos) while true do local byte = StrByte(text, pos) if not byte then return TokenData.NUMBER, pos end if byte >= ByteData.NUM_0 and byte <= ByteData.NUM_9 then pos = pos + 1 elseif byte == ByteData.E or byte == ByteData.e then return Lexer.NumberExponent(text, pos + 1) else return TokenData.NUMBER, pos end end end function Lexer.Number(text, pos) while true do local byte = StrByte(text, pos) if not byte then return TokenData.NUMBER, pos end if byte >= ByteData.NUM_0 and byte <= ByteData.NUM_9 then pos = pos + 1 elseif byte == ByteData.PERIOD then return Lexer.NumberFraction(text, pos + 1) elseif byte == ByteData.E or byte == ByteData.e then return Lexer.NumberExponent(text, pos + 1) else return TokenData.NUMBER, pos end end end function Lexer.Identifier(text, pos) while true do local byte = StrByte(text, pos) if not byte or newline[byte] or whitespaces[byte] or SymbolData[byte] then return TokenData.IDENTIFIER, pos end pos = pos + 1 end end function Lexer.Comment(text, pos) local byte = StrByte(text, pos) while true do byte = StrByte(text, pos) if not byte then return TokenData.COMMENT_SHORT, pos end if newline[byte] then return TokenData.COMMENT_SHORT, pos end pos = pos + 1 end end function Lexer.String(text, pos, character) local even = true while true do local byte = StrByte(text, pos) if not byte then return TokenData.STRING, pos end if byte == character then if even then return TokenData.STRING, pos + 1 end end if byte == ByteData.BACKSLASH then even = not even else even = true end pos = pos + 1 end end function Lexer.GetToken(text, pos) local byte = StrByte(text, pos) if not byte then return nil end if newline[byte] then return TokenData.LINEBREAK, pos + 1 end if whitespaces[byte] then while true do pos = pos + 1 byte = StrByte(text, pos) if not byte or not whitespaces[byte] then return TokenData.WHITESPACE, pos end end end local token = SymbolData[byte] if token then if token ~= -1 then return token, pos + 1 end if byte == ByteData.OR then byte = StrByte(text, pos + 1) if byte == ByteData.OR then return TokenData.OR, pos + 2 end return TokenData.UNKNOWN, pos + 1 end if byte == ByteData.AND then byte = StrByte(text, pos + 1) if byte == ByteData.AND then return TokenData.AND, pos + 2 end return TokenData.UNKNOWN, pos + 1 end if byte == ByteData.SEMICOLON then return Lexer.Comment(text, pos + 1) end if byte == ByteData.SINGLE_QUOTE then return Lexer.String(text, pos + 1, ByteData.SINGLE_QUOTE) end if byte == ByteData.DOUBLE_QUOTE then return Lexer.String(text, pos + 1, ByteData.DOUBLE_QUOTE) end if byte == ByteData.LEFTBRACKET then return TokenData.LEFTBRACKET, pos + 1 end if byte == ByteData.EQUALS then byte = StrByte(text, pos + 1) if not byte then return TokenData.ASSIGNMENT, pos + 1 end if byte == ByteData.EQUALS then return TokenData.EQUALITY, pos + 2 end return TokenData.ASSIGNMENT, pos + 1 end if byte == ByteData.PERIOD then byte = StrByte(text, pos + 1) if not byte then return TokenData.PERIOD, pos + 1 end if byte >= ByteData.NUM_0 and byte <= ByteData.NUM_9 then return Lexer.NumberFraction(text, pos + 2) end return TokenData.PERIOD, pos + 1 end if byte == ByteData.LESSTHAN then byte = StrByte(text, pos + 1) if byte == ByteData.EQUALS then return TokenData.LTE, pos + 2 end return TokenData.LT, pos + 1 end if byte == ByteData.GREATERTHAN then byte = StrByte(text, pos + 1) if byte == ByteData.EQUALS then return TokenData.GTE, pos + 2 end return TokenData.GT, pos + 1 end if byte == ByteData.EXCLAMATIONMARK then byte = StrByte(text, pos + 1) if byte == ByteData.EQUALS then return TokenData.NE, pos + 2 end return TokenData.NOT, pos + 1 end return TokenData.UNKNOWN, pos + 1 elseif byte >= ByteData.NUM_0 and byte <= ByteData.NUM_9 then return Lexer.Number(text, pos + 1) else return Lexer.Identifier(text, pos + 1) end end -- -- -- local function IndentTabs(n, unused) return StrRep("\t", n) end local function IndentSpaces(a, b) return StrRep(" ", a*b) end function IndentCode(code, width, position) local Indentfunction local tsize2 = 0 local totalLen2 = 0 local newPosition local bNewPosition = false local prevTokenWidth = 0 local pos = 1 local IndentLevel = 0 local bNonWhitespace = false local bIndentRight = false local preIndent = 0 local postIndent = 0 local tsize = 0 local totalLen = 0 if width == nil then width = defaultTabWidth end if width then Indentfunction = IndentSpaces else Indentfunction = IndentTabs end EraseTable(codeTable01) EraseTable(codeTable02) while true do if position and not newPosition and pos >= position then if pos == position then newPosition = totalLen + totalLen2 else newPosition = totalLen + totalLen2 local diff = pos - position if diff > prevTokenWidth then diff = prevTokenWidth end newPosition = newPosition - diff end end prevTokenWasColored = false prevTokenWidth = 0 local tokenType, nextPos = Lexer.GetToken(code, pos) if not tokenType or tokenType == TokenData.LINEBREAK then IndentLevel = IndentLevel + preIndent if IndentLevel < 0 then IndentLevel = 0 end local s = Indentfunction(IndentLevel, width) tsize = tsize + 1 codeTable01[tsize] = s totalLen = totalLen + StrLen(s) if newPosition and not bNewPosition then newPosition = newPosition + StrLen(s) bNewPosition = true end for k, v in next,codeTable02 do tsize = tsize + 1 codeTable01[tsize] = v totalLen = totalLen + StrLen(v) end if not tokenType then break end tsize = tsize + 1 codeTable01[tsize] = StrSub(code, pos, nextPos - 1) totalLen = totalLen + nextPos - pos IndentLevel = IndentLevel + postIndent if IndentLevel < 0 then IndentLevel = 0 end EraseTable(codeTable02) tsize2 = 0 totalLen2 = 0 bNonWhitespace = false bIndentRight = false preIndent = 0 postIndent = 0 elseif tokenType == TokenData.WHITESPACE then if bNonWhitespace then prevTokenWidth = nextPos - pos tsize2 = tsize2 + 1 local s = StrSub(code, pos, nextPos - 1) codeTable02[tsize2] = s totalLen2 = totalLen2 + StrLen(s) end else bNonWhitespace = true local str = StrSub(code, pos, nextPos - 1) prevTokenWidth = nextPos - pos local indentTable if tokenType == TokenData.IDENTIFIER then local tempstr = string.lower(str) local RefName,RefOrig,RefType = FindKeywordReference(tempstr) indentTable = RefType if ApiData[tempstr] then str = ApiData[tempstr] elseif RefName then str = RefOrig elseif ScriptObjects[tempstr] then str = ScriptObjects[tempstr] elseif EventData[tempstr] then str = EventData[tempstr] end else indentTable = IndentData[tokenType] end if indentTable then if bIndentRight then postIndent = postIndent + indentTable[1] + indentTable[2] else local pre = indentTable[1] local post = indentTable[2] if post > 0 then bIndentRight = true end preIndent = preIndent + pre postIndent = postIndent + post end end if FindKeywordReference(str) then tokenType = TokenData.KEYWORD end tsize2 = tsize2 + 1 codeTable02[tsize2] = str totalLen2 = totalLen2 + nextPos - pos end pos = nextPos end return table.concat(codeTable01), newPosition end local function PrintUsage() io.stderr:write(StrFormat( "Usage %s [options] [script.psc]\n".. "Available options are:\n".. " -s[number] Spacing to indent, TAB spacing is default\n".. " -b Backup the Papyrus Script\n" , program)) io.stderr:flush() end if _G.arg and _G.arg[0] and #_G.arg[0] > 0 then program = _G.arg[0] end local argv = {...} local function CollectArgs(argv,p) local i = 1 while i <= #argv do if StrSub(argv[i],1,1) ~= '-' then return i end local option = StrSub(argv[i],2,2) if option == 'b' then if #argv[i] > 2 then return -1 end p[option] = true elseif option == 's' then local spacing = tonumber(StrSub(argv[i],3,7)) if type(spacing) ~= 'number' then return -1 end p['spacing'] = spacing p[option] = true else return -1 end i = i + 1 end return 0 end HasOptions = { b = false, s = false } local PapyrusScript = CollectArgs(argv,HasOptions) if PapyrusScript <= 0 then PrintUsage() OsExit(1) end local script = argv[PapyrusScript] local spacing = HasOptions['spacing'] or nil local TempFileName = os.tmpname() local PapyrusFile = io.open(script, "r") if PapyrusFile == nil then OsError('Could not open file for reading "'..script..'"') end local TempFile = io.open(TempFileName,"w") if TempFile == nil then OsError('Could not open file for reading "'..TempFileName..'"') end local Code = PapyrusFile:read("*a") if HasOptions.b then local BackupFile = io.open(script..'.backup',"w") if BackupFile == nil then OsError('Could not open file for reading "'..script..'.backup'..'"') end BackupFile:write(Code) BackupFile:close() end local IndentedCode = IndentCode(Code, spacing) TempFile:write(IndentedCode) PapyrusFile:close() TempFile:close() os.remove(script) os.rename(TempFileName,script)