Advertisement
Guest User

Untitled

a guest
Dec 19th, 2023
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 53.26 KB | None | 0 0
  1. --
  2. --
  3. -- Sky Indent PROXiCiDE aka Taewon
  4. -- Version 0.5
  5. --
  6. -- Allows you to beautify Papyrus source code
  7. --
  8. -- Steam: http://steamcommunity.com/id/PROXiCiDE
  9. -- Nexus: http://skyrim.nexusmods.com/users/3018315
  10. -- Bethesda: http://forums.bethsoft.com/user/425376-taewon/
  11. --
  12. --
  13. -- Version History
  14. -- 0.5 Support for SKSE 1.7.0, SkyUI 4.1
  15. -- 0.4
  16. -- Keywords for Functions and Events used to be generated from the Creation Kit WIKI
  17. -- Functions and Events are now parsed from a collection of Papyrus source code
  18. -- Alot eaiser to keep SkyIndent updated
  19. --
  20. -- Reason was because there are undocumented functions and shortcuts
  21. -- Example GetRef() -> GetReference()
  22. --
  23. -- *.PSC
  24. -- Skyrim default
  25. -- SkyUI
  26. -- SKSE
  27. -- 0.3
  28. -- Optimizations, supports SKSE Events / Functions
  29. -- File size of SkyIndent.lua has been reduced significantly
  30. -- 0.2b
  31. -- Fixed array indentation
  32. -- 0.2a
  33. -- Tab spacing is the default if no option -s# passed in the command line arguments
  34. -- 0.1a
  35. -- Initial Release
  36. --
  37. --
  38.  
  39.  
  40. local StrLen = string.len
  41. local StrSub = string.sub
  42. local StrByte = string.byte
  43. local StrChar = string.char
  44. local StrRep = string.rep
  45. local StrFormat = string.format
  46. local OsExit = os.exit
  47.  
  48.  
  49. local function OsError(str)
  50. print('Error: '..StrFormat(str))
  51. os.execute("pause")
  52. OsExit(1)
  53. end
  54.  
  55. local program = nil
  56.  
  57. local codeTable01 = {}
  58. local codeTable02 = {}
  59. local function EraseTable(t)
  60. for k in next,t do
  61. t[k] = nil
  62. end
  63. end
  64.  
  65. local function StrIns(s, pos, insertStr)
  66. return StrSub(s, 1, pos) .. insertStr .. StrSub(s, pos + 1)
  67. end
  68.  
  69. local function StrDel(s, pos1, pos2)
  70. return StrSub(s, 1, pos1 - 1) .. StrSub(s, pos2 + 1)
  71. end
  72.  
  73. local Lexer = {}
  74. local TokenData = {}
  75. TokenData.AND = 1
  76. TokenData.ASSIGNMENT = 2
  77. TokenData.ASTERISK = 3
  78. TokenData.CIRCUMFLEX = 4
  79. TokenData.COLON = 5
  80. TokenData.COMMA = 6
  81. TokenData.COMMENT_LONG = 7
  82. TokenData.COMMENT_SHORT = 8
  83. TokenData.DOUBLEPERIOD = 9
  84. TokenData.EQUALITY = 10
  85. TokenData.GT = 11
  86. TokenData.GTE = 12
  87. TokenData.IDENTIFIER = 13
  88. TokenData.KEYWORD = 14
  89. TokenData.LEFTBRACKET = 15
  90. TokenData.LEFTPAREN = 16
  91. TokenData.LEFTWING = 17
  92. TokenData.LINEBREAK = 18
  93. TokenData.LT = 19
  94. TokenData.LTE = 20
  95. TokenData.MINUS = 21
  96. TokenData.NOT = 22
  97. TokenData.NE = 23
  98. TokenData.NUMBER = 24
  99. TokenData.OR = 25
  100. TokenData.MODULO = 26
  101. TokenData.PERIOD = 27
  102. TokenData.PLUS = 28
  103. TokenData.RIGHTBRACKET = 29
  104. TokenData.RIGHTPAREN = 30
  105. TokenData.RIGHTWING = 31
  106. TokenData.SEMICOLON = 32
  107. TokenData.SLASH = 33
  108. TokenData.SPECIAL = 34
  109. TokenData.STRING = 35
  110. TokenData.TRIPLEPERIOD = 37
  111. TokenData.UNKNOWN = 38
  112. TokenData.VERTICAL = 39
  113. TokenData.WHITESPACE = 40
  114.  
  115.  
  116. -- ascii codes
  117. local ByteData = {}
  118. ByteData.LINEBREAK_UNIX = StrByte("\n")
  119. ByteData.LINEBREAK_MAC = StrByte("\r")
  120. ByteData.SINGLE_QUOTE = StrByte("'")
  121. ByteData.DOUBLE_QUOTE = StrByte('"')
  122. ByteData.NUM_0 = StrByte("0")
  123. ByteData.NUM_9 = StrByte("9")
  124. ByteData.PERIOD = StrByte(".")
  125. ByteData.SPACE = StrByte(" ")
  126. ByteData.TAB = StrByte("\t")
  127. ByteData.E = StrByte("E")
  128. ByteData.e = StrByte("e")
  129. ByteData.MINUS = StrByte("-")
  130. ByteData.EQUALS = StrByte("=")
  131. ByteData.LEFTBRACKET = StrByte("[")
  132. ByteData.RIGHTBRACKET = StrByte("]")
  133. ByteData.BACKSLASH = StrByte("\\")
  134. ByteData.COMMA = StrByte(",")
  135. ByteData.SEMICOLON = StrByte(";")
  136. ByteData.COLON = StrByte(":")
  137. ByteData.LEFTPAREN = StrByte("(")
  138. ByteData.RIGHTPAREN = StrByte(")")
  139. ByteData.EXCLAMATIONMARK = StrByte("!")
  140. ByteData.PLUS = StrByte("+")
  141. ByteData.SLASH = StrByte("/")
  142. ByteData.LEFTWING = StrByte("{")
  143. ByteData.RIGHTWING = StrByte("}")
  144. ByteData.CIRCUMFLEX = StrByte("^")
  145. ByteData.ASTERISK = StrByte("*")
  146. ByteData.LESSTHAN = StrByte("<")
  147. ByteData.GREATERTHAN = StrByte(">")
  148. ByteData.AND = StrByte("&")
  149. ByteData.OR = StrByte("|")
  150. ByteData.MODULO = StrByte("%")
  151.  
  152. local newline = {}
  153. newline[ByteData.LINEBREAK_UNIX] = 1
  154. newline[ByteData.LINEBREAK_MAC] = 1
  155.  
  156. local whitespaces = {}
  157. whitespaces[ByteData.SPACE] = 1
  158. whitespaces[ByteData.TAB] = 1
  159.  
  160. local SymbolData = {}
  161. SymbolData[ByteData.PERIOD] = -1
  162. SymbolData[ByteData.LESSTHAN] = -1
  163. SymbolData[ByteData.GREATERTHAN] = -1
  164. SymbolData[ByteData.LEFTBRACKET] = -1
  165. SymbolData[ByteData.EQUALS] = -1
  166. SymbolData[ByteData.MINUS] = -1
  167. SymbolData[ByteData.SINGLE_QUOTE] = -1
  168. SymbolData[ByteData.DOUBLE_QUOTE] = -1
  169. SymbolData[ByteData.EXCLAMATIONMARK] = -1
  170. SymbolData[ByteData.SEMICOLON] = -1
  171. SymbolData[ByteData.RIGHTBRACKET] = TokenData.RIGHTBRACKET
  172. SymbolData[ByteData.COMMA] = TokenData.COMMA
  173. SymbolData[ByteData.COLON] = TokenData.COLON
  174. SymbolData[ByteData.LEFTPAREN] = TokenData.LEFTPAREN
  175. SymbolData[ByteData.RIGHTPAREN] = TokenData.RIGHTPAREN
  176. SymbolData[ByteData.PLUS] = TokenData.PLUS
  177. SymbolData[ByteData.SLASH] = TokenData.SLASH
  178. SymbolData[ByteData.LEFTWING] = TokenData.LEFTWING
  179. SymbolData[ByteData.RIGHTWING] = TokenData.RIGHTWING
  180. SymbolData[ByteData.CIRCUMFLEX] = TokenData.CIRCUMFLEX
  181. SymbolData[ByteData.ASTERISK] = TokenData.ASTERISK
  182. SymbolData[ByteData.OR] = -1
  183. SymbolData[ByteData.AND] = -1
  184. SymbolData[ByteData.MODULO] = TokenData.MODULO
  185.  
  186. -- The following was generated from the Creation Kit wiki
  187. -- http://www.creationkit.com/Keyword_Reference
  188.  
  189. local IndentIgnore = {0, 0}
  190. local IndentLeft = {-1, 0}
  191. local IndentRight = {0, 1}
  192. local IndentBoth = {-1, 1}
  193.  
  194.  
  195. function IndentType(t)
  196. local s={}
  197. table.insert(s, {
  198. name = string.lower(t[1]),
  199. orig = t[1],
  200. type = t[2]
  201. })
  202. return s
  203. end
  204.  
  205. KeywordReferenceData = {
  206. IndentType {"Else",IndentBoth},
  207. IndentType {"ElseIf",IndentBoth},
  208.  
  209. IndentType {"Native",IndentIgnore},
  210. IndentType {"New",IndentIgnore},
  211. IndentType {"As",IndentIgnore},
  212. IndentType {"Int",IndentIgnore},
  213. IndentType {"Length",IndentIgnore},
  214. IndentType {"Import",IndentIgnore},
  215. IndentType {"None",IndentIgnore},
  216. IndentType {"Parent",IndentIgnore},
  217. IndentType {"Property",IndentIgnore},
  218. IndentType {"String",IndentIgnore},
  219. IndentType {"Hidden",IndentIgnore},
  220. IndentType {"Self",IndentIgnore},
  221. IndentType {"Return",IndentIgnore},
  222. IndentType {"ScriptName",IndentIgnore},
  223. IndentType {"True",IndentIgnore},
  224. IndentType {"Global",IndentIgnore},
  225. IndentType {"Float",IndentIgnore},
  226. IndentType {"Bool",IndentIgnore},
  227. IndentType {"AutoReadOnly",IndentIgnore},
  228. IndentType {"Extends",IndentIgnore},
  229. IndentType {"False",IndentIgnore},
  230. IndentType {"Auto",IndentIgnore},
  231.  
  232. IndentType {"EndEvent",IndentLeft},
  233. IndentType {"EndFunction",IndentLeft},
  234. IndentType {"EndIf",IndentLeft},
  235. IndentType {"EndProperty",IndentLeft},
  236. IndentType {"EndState",IndentLeft},
  237. IndentType {"EndWhile",IndentLeft},
  238.  
  239. IndentType {"If",IndentRight},
  240. IndentType {"State",IndentRight},
  241. IndentType {"Event",IndentRight},
  242. IndentType {"Function",IndentRight},
  243. IndentType {"While",IndentRight},
  244. }
  245.  
  246. function FindKeywordReference(name)
  247. for k,v in ipairs(KeywordReferenceData) do
  248. if string.lower(name) == v[1].name then
  249. return v[1].name,v[1].orig,v[1].type
  250. end
  251. end
  252. return nil,nil,nil
  253. end
  254.  
  255. -- The following was generated from the Creation Kit wiki
  256. -- http://www.creationkit.com/Category:Script_Objects
  257.  
  258. function CaseType(t)
  259. local s={}
  260. for i,v in ipairs(t) do
  261. s[string.lower(v)]=v
  262. end
  263. return s
  264. end
  265.  
  266. ScriptObjects = CaseType {
  267. "Action", "Activator", "ActiveMagicEffect", "Actor",
  268. "ActorBase", "ActorValueInfo", "Alias", "Ammo",
  269. "Apparatus", "Armor", "ArmorAddon", "Art",
  270. "AssociationType", "Book", "Cell", "Class",
  271. "ColorForm", "CombatStyle", "ConstructibleObject", "Container",
  272. "Debug", "DefaultObjectManager", "Door", "EffectShader",
  273. "Enchantment", "EncounterZone", "EquipSlot", "Explosion",
  274. "Faction", "Flora", "Form", "FormList",
  275. "Furniture", "Game", "GlobalVariable", "Hazard",
  276. "HeadPart", "Idle", "ImageSpaceModifier", "ImpactDataSet",
  277. "Ingredient", "Input", "Key", "Keyword",
  278. "LeveledActor", "LeveledItem", "LeveledSpell", "Light",
  279. "Location", "LocationAlias", "LocationRefType", "MagicEffect",
  280. "Math", "Message", "MiscObject", "ModEvent",
  281. "MusicType", "NetImmerse", "ObjectReference", "Outfit",
  282. "Package", "Perk", "Potion", "Projectile",
  283. "Quest", "Race", "ReferenceAlias", "Scene",
  284. "Scroll", "Shout", "SKSE", "SoulGem",
  285. "Sound", "SoundCategory", "SoundDescriptor", "Spell",
  286. "Static", "StringUtil", "TalkingActivator", "TextureSet",
  287. "Topic", "TopicInfo", "Tree", "UI",
  288. "UICallback", "Utility", "VisualEffect", "VoiceType",
  289. "Weapon", "Weather", "WordOfPower", "WorldSpace",
  290. "WornObject",
  291. }
  292.  
  293. -- The following used to be generated from the Creation Kit wiki
  294. -- http://www.creationkit.com/Category:Papyrus
  295. --
  296. -- Now generated from a collection of Papyrus files
  297. ApiData = CaseType {
  298. -- Generated data for Skyrim
  299. "IsFurnitureMarkerInUse", "GetSunPositionX", "Dismount", "ToggleCollisions",
  300. "CanFlyHere", "ShowLimitedRaceMenu", "SetAV", "GetPlayerGrabbedRef",
  301. "SetFogPower", "SetDestroyed", "KillSilent", "TryToClear",
  302. "RemoveShout", "ClearTempEffects", "KeepOffsetFromActor", "HasForm",
  303. "SetProtected", "IsInInterior", "SetCrimeGold", "GetGiftFilter",
  304. "Resurrect", "StopObjectProfiling", "CanPayCrimeGold", "GetRace",
  305. "Dispel", "FindRandomReferenceOfAnyTypeInListFromRef", "TraceAndBox", "ForceMovementRotationSpeedRamp",
  306. "HasCommonParent", "StartScriptProfiling", "IsFightingControlsEnabled", "SetCrimeFaction",
  307. "GetValueInt", "RegisterForUpdateGameTime", "IsStopping", "SetActorOwner",
  308. "GetEquippedWeapon", "ShowTitleSequenceMenu", "GetAlias", "HasLOS",
  309. "IsMapMarkerVisible", "GetActorOwner", "CenterOnCellAndWait", "GetLeveledActorBase",
  310. "TryToEvaluatePackage", "HasParentRelationship", "SetCleared", "SetValueInt",
  311. "SetEnemy", "GetKiller", "TryToRemoveFromFaction", "UnequipItem",
  312. "CaptureFrameRate", "GetEditorLocation", "StartStackProfiling", "FailAllObjectives",
  313. "SetSubGraphFloatVariable", "IsActive", "HasMagicEffectWithKeyword", "AddItem",
  314. "PlaySyncedAnimationAndWaitSS", "FindClosestReferenceOfAnyTypeInListFromRef", "FindClosestReferenceOfTypeFromRef", "SetMotionType",
  315. "MoveToPackageLocation", "GetCurrentWeatherTransition", "IsSneakingControlsEnabled", "AddInventoryEventFilter",
  316. "GetAt", "GetSize", "GetBudgetCount", "IncrementSkill",
  317. "ClearLookAt", "Show", "IsInFaction", "QuitGame",
  318. "PlayerKnows", "TriggerScreenBlood", "WornHasKeyword", "GetGoldValue",
  319. "IsBeingRidden", "GetAVPercentage", "SetObjectiveDisplayed", "TraceStack",
  320. "SetPublic", "GetLockLevel", "Ceiling", "RemoveDependentAnimatedObjectReference",
  321. "DoCombatSpellApply", "SetLockLevel", "FindClosestActor", "PlayImpactEffect",
  322. "StartDeferredKill", "AddAchievement", "GetBribeAmount", "SetINIFloat",
  323. "GetLocation", "MessageBox", "SetDontMove", "SetAttackActorOnSight",
  324. "SetHeadTracking", "UnequipSpell", "ShowGiftMenu", "AddDependentAnimatedObjectReference",
  325. "ForceMovementDirection", "GetPositionY", "SetAnimationVariableInt", "SetPlayerAIDriven",
  326. "UnequipShout", "AddPerk", "SetFootIK", "ForceAV",
  327. "GetAnimationVariableInt", "ModAV", "SetInvulnerable", "ToggleMenus",
  328. "CenterOnCell", "ForceLocationTo", "GetAnimationVariableFloat", "DumpAliasData",
  329. "GetAngleZ", "SetAllowFlying", "AddToMap", "RemoveSpell",
  330. "GetStolenItemValueCrime", "BlockActivation", "GetAssociatedSkill", "SetINIBool",
  331. "SetAngle", "SetPlayerReportCrime", "SendTrespassAlarm", "RemoveItem",
  332. "TryToReset", "ShowBarterMenu", "FindRandomReferenceOfAnyTypeInList", "ForceRefTo",
  333. "SplineTranslateToRefNode", "TrapSoul", "IsUnique", "Lock",
  334. "ModReaction", "GetPositionZ", "ShakeCamera", "SendStealAlarm",
  335. "GetHeadingAngle", "GetInfamy", "PlaceActorAtMe", "ClearExpressionOverride",
  336. "ClearKeepOffsetFromActor", "Notification", "SetOpen", "GetDialogueTarget",
  337. "Delete", "IsAllowedToFly", "IsActivationBlocked", "EnableNoWait",
  338. "GetDeadCount", "UnregisterForUpdate", "Pause", "SetPlayerControls",
  339. "DrawWeapon", "RemoveFromAllFactions", "GetNoBleedoutRecovery", "GetPlatformName",
  340. "IsCleared", "SetOutfit", "IsInCombat", "FindRandomReferenceOfType",
  341. "SetFogPlanes", "AdvanceSkill", "IsPlayerTeammate", "WillIntimidateSucceed",
  342. "FindRandomReferenceOfTypeFromRef", "Reset", "UnregisterForLOS", "IsPlayerSungazing",
  343. "GetAngleX", "OpenInventory", "HasEffectKeyword", "Clear",
  344. "GetConfigName", "IsLocked", "TraceConditional", "ShowAsHelpMessage",
  345. "FindRandomActorFromRef", "FindRandomActor", "LearnAllEffects", "UnregisterForUpdateGameTime",
  346. "IsEquipped", "IsDead", "AttachAshPile", "HasAssociation",
  347. "IsActivateChild", "GetFactionRank", "GetHighestRelationshipRank", "LearnEffect",
  348. "LearnNextEffect", "GetForm", "FadeOutGame", "TraceUser",
  349. "PathToReference", "GetEquippedShout", "IsInKillMove", "GetAverageFrameRate",
  350. "SetPlayerExpelled", "UnLockOwnedDoorsInCell", "SetActorCause", "GetCurrentScene",
  351. "SetVehicle", "OverBudget", "GetSunPositionZ", "GetCurrentPackage",
  352. "SetPosition", "GameTimeToString", "GetLowestRelationshipRank", "Play",
  353. "AddHavokBallAndSocketConstraint", "IsInLocation", "ClearExtraArrows", "EquipItem",
  354. "GetMinFrameRate", "RegisterForUpdate", "SetHudCartMode", "IsInMenuMode",
  355. "PushActorAway", "IsActivateControlsEnabled", "StopInstance", "GetSitState",
  356. "SetEssential", "DisableLinkChain", "HasSpell", "ForceTargetSpeed",
  357. "IsNearPlayer", "ResetHelpMessage", "Start", "IsDetectedBy",
  358. "TakeScreenshot", "CalculateFavorCost", "SetINIString", "RemoveInventoryEventFilter",
  359. "ClearPrison", "GetStolenItemValueNoCrime", "RegisterForAnimationEvent", "Floor",
  360. "StartObjectProfiling", "Mod", "EquipSpell", "GetSkyMode",
  361. "IsFastTravelEnabled", "SendAnimationEvent", "AddToFaction", "GetOutgoingWeather",
  362. "GetItemHealthPercent", "GetKeywordData", "GetClassification", "SetEyeTexture",
  363. "FindWeather", "ForceActive", "ReleaseOverride", "ForceThirdPerson",
  364. "IgnoreFriendlyHits", "Fire", "IsPlayersLastRiddenHorse", "GetBudgetName",
  365. "GetCurrentBudget", "GetCurrentMemory", "HasKeyword", "IsLoaded",
  366. "GetTriggerObjectCount", "CreateDetectionEvent", "GetNthLinkedRef", "GetGameSettingInt",
  367. "GetCombatTarget", "GetPlayersLastRiddenHorse", "UnequipItemSlot", "SetINIInt",
  368. "GetCasterActor", "PlayTerrainEffect", "RandomInt", "SetLookAt",
  369. "GetCurrentGameTime", "SendWereWolfTransformation", "GetKey", "GetCurrentRealTime",
  370. "Unload", "Remove", "Preload", "IncrementStat",
  371. "ModCrimeGold", "TetherToHorse", "RemoteCast", "RemoveAllInventoryEventFilters",
  372. "RegisterForLOS", "SetFrequency", "GetCurrentWeather", "UnMute",
  373. "IsEssential", "Mute", "MoveTo", "GetPlayerControls",
  374. "SetInstanceVolume", "PlayAndWait", "PlayerMoveToAndWait", "MoveToMyEditorLocation",
  375. "IsActionComplete", "IsPlaying", "TryToEnableNoWait", "TryToEnable",
  376. "TryToMoveTo", "TryToKill", "ForceStart", "TryToDisableNoWait",
  377. "GetBaseAV", "TryToDisable", "IsAttached", "TryToStopCombat",
  378. "TryToAddToFaction", "IsProtected", "GetActorRef", "GetWorldSpace",
  379. "GetWidth", "PlayAnimation", "GetLinkedRef", "ModFactionRank",
  380. "ForceRefIfEmpty", "GetReference", "IsJournalControlsEnabled", "IsFastTravelControlsEnabled",
  381. "HideTitleSequenceMenu", "InterruptCast", "UnregisterForSleep", "SetIntimidated",
  382. "StartSneaking", "IsChild", "SetBeastForm", "IsSprinting",
  383. "IsSneaking", "ShowRaceMenu", "UnPause", "SetPlayerEnemy",
  384. "GetCurrentDestructionStage", "IsMenuControlsEnabled", "UpdateCurrentInstanceGlobal", "GetDistance",
  385. "GetCurrentStageID", "SetObjectiveFailed", "SetObjectiveCompleted", "GetActorReference",
  386. "SetActive", "IsStopped", "GetItemCount", "IsStageDone",
  387. "IsObjectiveFailed", "PrecacheCharGenClear", "IsDeleted", "DebugChannelNotify",
  388. "IsObjectiveDisplayed", "FindClosestActorFromRef", "SetExpressionOverride", "IsObjectiveCompleted",
  389. "PlayAnimationAndWait", "IsCompleted", "RemoveCrossFade", "IsDisabled",
  390. "GetInfamyViolent", "Enable", "GetStageDone", "GetStage",
  391. "SetStage", "IsAlerted", "RestoreActorValue", "CompleteQuest",
  392. "IsGuard", "StopScriptProfiling", "UnregisterForTrackedStatsEvent", "GetOpenState",
  393. "countLinkedRefChain", "SetValue", "GetTemplate", "WaitForAnimationEvent",
  394. "GetPlayer", "TranslateToRef", "StopTranslation", "RadiansToDegrees",
  395. "StopCombatAlarm", "SplineTranslateTo", "MakePlayerFriend", "RemoveAllItems",
  396. "TranslateTo", "IsMovementControlsEnabled", "GetOwningQuest", "UnregisterForAnimationEvent",
  397. "AllowBleedoutDialogue", "SetNoFavorAllowed", "acos", "GetParentCell",
  398. "ForceMovementSpeed", "GetRefTypeDeadCount", "SetAnimationVariableFloat", "GetCurrentLocation",
  399. "GetGameSettingFloat", "DisableNoWait", "ProcessTrapHit", "RandomFloat",
  400. "SetBribed", "GetBaseActorValue", "atan", "PlayGamebryoAnimation",
  401. "AddSpell", "GetRef", "IsFactionInCrimeGroup", "DropObject",
  402. "PlaceAtMe", "MoveToNode", "MoveToInteractionLocation", "KnockAreaEffect",
  403. "RemovePerk", "IsIgnoringFriendlyHits", "IsLockBroken", "IsInDialogueWithPlayer",
  404. "IsFurnitureInUse", "rampRumble", "IsEnabled", "HasRefType",
  405. "GetReaction", "FindClosestReferenceOfType", "HasNode", "EquipShout",
  406. "GetPositionX", "SetAlpha", "IsIntimidated", "EndFrameRateCapture",
  407. "QueryStat", "IsDoingFavor", "GetScale", "DBSendPlayerPosition",
  408. "SetReaction", "ToggleAI", "SendPlayerToJail", "ForceMovementSpeedRamp",
  409. "GetSelfAsActor", "GetMass", "EnableLinkChain", "ForceAddRagdollToWorld",
  410. "StartFrameRateCapture", "GetTargetActor", "SetCurrentStageID", "SetUnconscious",
  411. "GetLength", "SetVolume", "IsStarting", "GetHeight",
  412. "SetVoiceRecoveryTime", "SetAnimationVariableBool", "ClearDestruction", "UnequipAll",
  413. "DamageObject", "SetRelationshipRank", "GetEquippedSpell", "RegisterForSingleLOSGain",
  414. "ForceRemoveRagdollFromWorld", "Disable", "GetAngleY", "GetVoiceRecoveryTime",
  415. "GetAnimationVariableBool", "CompleteAllObjectives", "RequestSave", "StopCombat",
  416. "GetRelationshipRank", "CalculateEncounterLevel", "AddShout", "GetAV",
  417. "SetCriticalStage", "RestoreAV", "ApplyHavokImpulse", "GetClass",
  418. "ForceMovementDirectionRamp", "ForceTargetDirection", "Activate", "GetFactionReaction",
  419. "IsUnconscious", "AddKeyIfNeeded", "ModActorValue", "DeleteWhenAble",
  420. "MoveToWhenUnloaded", "GetForcedLandingMarker", "IsWeaponDrawn", "MoveToIfUnloaded",
  421. "IsAlarmed", "GetCrimeFaction", "GetEquippedShield", "ApplyCrossFade",
  422. "PlayIdle", "SetAllowFlyingEx", "set", "DamageActorValue",
  423. "GetActorValue", "Add", "RemoveFromFaction", "ClearForcedMovement",
  424. "tan", "IsBribed", "sqrt", "GetSleepState",
  425. "get", "pow", "DegreesToRadians", "Kill",
  426. "GetSex", "IsPlayerExpelled", "HasPerk", "cos",
  427. "GetMaxFrameRate", "PlaySyncedAnimationSS", "SetActorValue", "asin",
  428. "GetFormID", "IsArrestingTarget", "abs", "GetLightLevel",
  429. "EnableAI", "GetVersionNumber", "RequestModel", "StartCannibal",
  430. "SetGodMode", "SetKeywordData", "SetDoingFavor", "Find",
  431. "IsSameLocation", "Is3DLoaded", "GetRefTypeAliveCount", "PopTo",
  432. "Apply", "GetInfamyNonViolent", "IsGhost", "SendAssaultAlarm",
  433. "ModObjectiveGlobal", "ModFavorPointsWithGlobal", "EndDeferredKill", "SetGhost",
  434. "RegisterForTrackedStatsEvent", "WaitGameTime", "UsingGamepad", "ClearArrested",
  435. "IsInterior", "HasFamilyRelationship", "GetCrimeGoldViolent", "RegisterForSleep",
  436. "TeachWord", "ShowTrainingMenu", "SetSunGazeImageSpaceModifier", "SetAllowFlyingMountLandingRequests",
  437. "PlayerPayCrimeGold", "IsFlying", "StartTitleSequence", "ShakeController",
  438. "SetSittingRotation", "SetInChargen", "SetPlayerResistingArrest", "SetCameraTarget",
  439. "ServeTime", "GetBaseObject", "IsOnMount", "GetActorBase",
  440. "RequestAutoSave", "DamageAV", "IsBleedingOut", "EnableFastTravel",
  441. "SetNotShowOnStealthMeter", "PrecacheCharGen", "PlayIdleWithTarget", "IsWordUnlocked",
  442. "ForceMovementRotationSpeed", "ModFavorPoints", "GetGoldAmount", "ResetHealthAndLimbs",
  443. "SetPlayerTeammate", "IsCamSwitchControlsEnabled", "IncrementSkillBy", "IsArrested",
  444. "GetSunPositionY", "IsRunning", "SplineTranslateToRef", "GetGameSettingString",
  445. "WaitMenuMode", "GetFactionOwner", "ForceActorValue", "Say",
  446. "GetFormFromFile", "SetFactionRank", "sin", "FindClosestReferenceOfAnyTypeInList",
  447. "GetFlyingState", "IsHostileToActor", "RegisterForSingleLOSLost", "RemoveHavokConstraints",
  448. "GetActorValuePercentage", "ClearForcedLandingMarker", "Trace", "DispelSpell",
  449. "CanFastTravelToMarker", "FastTravel", "HasMagicEffect", "KillEssential",
  450. "QuitToMainMenu", "StopStackProfiling", "IsTrespassing", "AddPerkPoints",
  451. "RegisterForSingleUpdateGameTime", "GetVoiceType", "SetRace", "AddForm",
  452. "CloseUserLog", "GetRealHoursPassed", "SetForcedLandingMarker", "SetCrimeGoldViolent",
  453. "ShowFirstPersonGeometry", "GetEquippedItemType", "SetAlly", "PlaySubGraphAnimation",
  454. "GetCrimeGold", "ForceTargetAngle", "IsHostile", "EvaluatePackage",
  455. "ShowRefPosition", "OpenUserLog", "SetNoBleedoutRecovery", "RegisterForSingleUpdate",
  456. "GetLevel", "Cast", "RemoveAddedForm", "GetCombatState",
  457. "SetFactionOwner", "IsInvulnerable", "UnlockWord", "GetCrimeGoldNonViolent",
  458. "DispelAllSpells", "SetScale", "ForceFirstPerson", "GetValue",
  459. "StartVampireFeed", "IsLookingControlsEnabled", "StartCombat", "Wait",
  460. "SetRestrained", "IsCommandedActor", "Stop", "SetAlert",
  461. "AllowPCDialogue", "Revert",
  462.  
  463. -- Generated data for SkyUI
  464. "AddMenuOptionST", "SetKeyMapOptionValue", "SetCursorFillMode", "SetTextOptionValueST",
  465. "SetTextOptionValue", "SetTitleText", "SetSliderOptionValue", "AddKeyMapOptionST",
  466. "UnloadCustomContent", "SetKeyMapOptionValueST", "SetCursorPosition", "SetSliderDialogStartValue",
  467. "CheckVersion", "SetInfoText", "SetMenuDialogOptions", "SetSliderDialogDefaultValue",
  468. "AddEmptyOption", "SetColorOptionValueST", "SetSliderDialogRange", "SetMenuDialogDefaultIndex",
  469. "AddToggleOptionST", "GetCustomControl", "Guard", "AddHeaderOption",
  470. "SetMenuOptionValueST", "SetSliderOptionValueST", "SetToggleOptionValueST", "SetOptionFlagsST",
  471. "AddColorOptionST", "AddSliderOptionST", "SetSliderDialogInterval", "ShowMessage",
  472. "AddSliderOption", "AddToggleOption", "AddTextOptionST", "AddMenuOption",
  473. "SetOptionFlags", "LoadCustomContent", "GetVersion", "AddTextOption",
  474. "SetColorDialogStartColor", "AddColorOption", "SetColorDialogDefaultColor", "SetMenuDialogStartIndex",
  475. "SetMenuOptionValue", "SetToggleOptionValue", "ForcePageReset", "AddKeyMapOption",
  476. "SetColorOptionValue",
  477.  
  478. -- Generated data for SKSE
  479. "GetNumHeadParts", "SetNthEffectMagnitude", "GetNthLevel", "ModPerkPoints",
  480. "GetMeleePowerAttackStaggeredMult", "GetNthPlayableRace", "GetDescriptor", "SaveGame",
  481. "GetNthAdditionalRace", "GetWornForm", "GetNumParts", "GetIndexOfExtraPart",
  482. "GetNthPart", "SetMagicMult", "EquipItemById", "IsImmobile",
  483. "UpdateWeight", "GetMagicMult", "CanWalk", "LoadGame",
  484. "SetNthSpell", "GetIconPath", "GetNumTexturePaths", "SetIconPath",
  485. "GetFrequencyVariance", "SetNthLevel", "SetAllowPickpocket", "GetNthModDependency",
  486. "SetSkillLevel", "ResetInventory", "GetSpellCount", "LogicalAnd",
  487. "OpenCustomMenu", "GetVersionRelease", "PushStringA", "Release",
  488. "SetOffensiveMult", "GetNthSpell", "GetNthEntryText", "SetQuality",
  489. "IsLightArmor", "SetNthEntryText", "GetQuality", "GetNumIngredients",
  490. "GetNthCount", "TempClone", "MakeCanSwim", "GetNthEffectMagnitude",
  491. "ClearRaceFlag", "ClearAllowPCDialogue", "PushInt", "RegisterForCrosshairRef",
  492. "IsClothingHands", "SetArmorRating", "UnregisterForActorAction", "GetNthParent",
  493. "GetModName", "SetCloseRangeFlankingFlankDistance", "NoKnockdowns", "GetNthReferenceAlias",
  494. "UpdateTintMaskColors", "SetNthTintMaskTexturePath", "SetNthEffectDuration", "GetEquipAbility",
  495. "SetMeleeBashMult", "IsWarAxe", "SetEquipAbility", "GetMeleeBashMult",
  496. "GetNthEffectDuration", "GetNthTintMaskTexturePath", "SetPlayerKnows", "GetResult",
  497. "GetAllowDualWielding", "QueueNiNodeUpdate", "GetSkillLevel", "GetArmorRating",
  498. "GetCloseRangeFlankingStalkTime", "GetPerkPoints", "GetImpactDataSet", "IsStaff",
  499. "SetSlotMask", "GetIngredient", "GetNthEntrySpell", "GetCritMultiplier",
  500. "SetFrequencyVariance", "SetImpactDataSet", "GetINIFloat", "GetIsNthEffectKnown",
  501. "GetSlotMask", "GetSoulSize", "GetNthWordOfPower", "GetVersionBeta",
  502. "IsTakeable", "GetFormEx", "SetPerkPoints", "SetEnchantmentValue",
  503. "SetNthWordOfPower", "UnregisterForAllMenus", "GetModelNthTextureSet", "GetNumParents",
  504. "Substring", "GetAvoidThreatChance", "SetNthEntrySpell", "SetIngredient",
  505. "UnregisterForAllKeys", "SetEffectFlag", "SetArea", "GetNthTintMaskType",
  506. "MakeNonWalking", "SetAllowPCDialogue", "ClearNoKNockdowns", "GetString",
  507. "GetModByName", "SetString", "LogicalXor", "NoShadow",
  508. "GetChanceGlobal", "UnbindObjectHotkey", "GetType", "SetNthTintMaskColor",
  509. "SetAssociatedSkill", "TapKey", "GetActorValueInfoByID", "IsPrintable",
  510. "GetCloseRangeDuelingFallbackMult", "IsBattleaxe", "GetWeightClass", "AddSlotToMask",
  511. "CloseCustomMenu", "GetWornItemId", "HasKeywordString", "IsHarvested",
  512. "Invoke", "GetNextPerk", "SetNthTexturePath", "SetSkillImproveMult",
  513. "IsClothingBody", "IsMenuOpen", "GetID", "SetItemHealthPercent",
  514. "SetMeleeBashRecoiledMult", "UnregisterForCameraState", "SetNoShadow", "IsRaceFlagSet",
  515. "GetSunDamage", "RegenerateHead", "IsEffectFlagSet", "SetFlightDiveBombChance",
  516. "GetMeleeBashRecoiledMult", "UnregisterForAllModEvents", "GetAVIByName", "GetMaxRange",
  517. "GetActorValueInfoByName", "GetNthEntryValue", "SetMaxRange", "GetINIBool",
  518. "GetNumItems", "SetSkillOffsetMult", "SetFlightFlyingAttackChance", "GetGemSize",
  519. "GetNthTintMaskColor", "SetRed", "SetNthEntryValue", "SetMiscStat",
  520. "GetNthKeyword", "GetNumKeysPressed", "SetNthEntryPriority", "GetSkillOffsetMult",
  521. "GetArea", "SetDisplayName", "GetOutfit", "MakePushable",
  522. "GetRed", "GetValidRaces", "InvokeNumberA", "GetPerk",
  523. "SetEquippedModel", "ClearNoShadow", "GetNumber", "GetNthKeyPressed",
  524. "IsClothingRich", "SetNthEntryLeveledList", "GetNodePositionY", "GetEnchantShader",
  525. "SetChanceNone", "GetEquippedModel", "GetWindDirection", "AsChar",
  526. "SetEnchantShader", "GetLight", "IsCuirass", "GetGroupOffensiveMult",
  527. "SetGroupOffensiveMult", "UpdateHairColor", "IsGauntlets", "SetWorkbenchKeyword",
  528. "GetINIInt", "GetNthEntryRank", "SetSkin", "GetWorkbenchKeyword",
  529. "GetSkin", "GetNumAdditionalRaces", "IsShield", "IsTextInputEnabled",
  530. "GetDefaultVoiceType", "RegisterForModEvent", "IsHelmet", "GetSkillExperience",
  531. "GetStaffMult", "GetSkillImproveMult", "ClearEffectFlag", "SetWeightClass",
  532. "SetMeleeBashAttackMult", "IsJewelry", "IsClothing", "Send",
  533. "RemoveSlotFromMask", "GetAVIByID", "GetNthEntryLeveledList", "GetMappedControl",
  534. "SetValidRaces", "SetResist", "SetDefaultVoiceType", "LogicalNot",
  535. "SetNumber", "SetSkillExperience", "GetFlightHoverChance", "GetImageSpaceMod",
  536. "SetNthEntryQuest", "GetInt", "LeftShift", "SetNthIngredientQuantity",
  537. "SetFlightHoverChance", "IsFood", "GetNthEntryQuest", "GetFaceMorph",
  538. "SetInt", "GetNumForms", "SetTintMaskColor", "UnregisterForModEvent",
  539. "GetNumTintsByType", "SetFaceMorph", "SetImageSpaceMod", "GetSpell",
  540. "UnregisterForKey", "GetFacePreset", "IsMace", "SetHitEffectArt",
  541. "UpdateThirdPerson", "IsPunctuation", "SetWeight", "SetItemMaxCharge",
  542. "UnregisterForMenu", "GetPluginVersion", "InvokeString", "GetINIString",
  543. "SetCritEffectOnDeath", "SetStaffMult", "GetNthForm", "GetWeight",
  544. "GetTimeElapsed", "SetFacePreset", "SetForm", "GetBaseCost",
  545. "GetEnchantment", "SetRaceFlag", "GetNumExtraParts", "SetCritDamage",
  546. "GetName", "GetCritDamage", "SetName", "GetItemMaxCharge",
  547. "SetDecibelVariance", "SetPlayersLastRiddenHorse", "GetPlayerExperience", "GetTintMaskColor",
  548. "IsObjectFavorited", "IsChildRace", "GetReach", "GetExplosion",
  549. "GetNthAlias", "GetNthExtraPart", "SetBaseCost", "GetNthIngredientQuantity",
  550. "IsSword", "SetPlayerExperience", "SetEnchantment", "PushIntA",
  551. "SetCombatStyle", "UnregisterForAllControls", "GetCombatStyle", "CanSwim",
  552. "SetMeleePowerAttackBlockingMult", "Create", "GetSkillImproveOffset", "GetMeleePowerAttackBlockingMult",
  553. "GetFlightFlyingAttackChance", "SetCastingArt", "SetMeleeSpecialAttackMult", "IsClothingRing",
  554. "Log", "SetResistance", "SetNodeTextureSet", "GetPlayerMovementMode",
  555. "GetMeleeSpecialAttackMult", "GetModDescription", "SetResultQuantity", "GetModelPath",
  556. "SetCloseRangeDuelingCircleMult", "MakeNonSwimming", "GetResultQuantity", "GetSkinFar",
  557. "GetNodePositionX", "SetMinRange", "UnregisterForControl", "PushBool",
  558. "GetPerkTree", "IsSwimming", "GetDuration", "ClearNoCombatInWater",
  559. "GetSaturation", "MakeCanWalk", "SetSaturation", "IsKeyPressed",
  560. "GetCameraState", "SendModEvent", "MakeCanFly", "GetMaskForSlot",
  561. "GetBaseDamage", "GetNumArmorAddons", "SetNodeScale", "GetModAuthor",
  562. "GetCastingArt", "GetMessageIconPath", "GetNodeScale", "GetNumEffects",
  563. "GetNumOverlayHeadParts", "GetUnarmedMult", "GetFogDistance", "GetMeleeAttackStaggeredMult",
  564. "SetGameSettingBool", "GetColor", "GetDefensiveMult", "SetMeleeAttackStaggeredMult",
  565. "SetDefensiveMult", "InvokeInt", "MakeChildRace", "GetWindDirectionRange",
  566. "GetSunGlare", "IsWarhammer", "IsGreatsword", "IsDagger",
  567. "SetUnarmedMult", "SetAvoidThreatChance", "SetCritMultiplier", "GetCritEffectOnDeath",
  568. "SetCritEffect", "GetCritEffect", "GetResist", "GetNumEntries",
  569. "SetMeleeMult", "GetEnchantmentValue", "SetCloseRangeDuelingFallbackMult", "SetProjectile",
  570. "AvoidsRoads", "GetWeaponType", "GetBool", "SetNthHeadPart",
  571. "EquipItemEx", "GetModDependencyCount", "GetEnchantArt", "GetMeleeMult",
  572. "RegisterForControl", "GetIndexOfHeadPartByType", "SetEnchantArt", "SetStagger",
  573. "GetStagger", "SetSpeed", "GetSpeed", "GetMinRange",
  574. "AddSkillExperience", "GetMagnitude", "SetReach", "SetGameSettingInt",
  575. "SetBaseDamage", "UnregisterForCrosshairRef", "SetColor", "GetHue",
  576. "PushFloatA", "PushBoolA", "InvokeForm", "InvokeStringA",
  577. "InvokeFloatA", "AllowPickpocket", "InvokeIntA", "PushForm",
  578. "InvokeBoolA", "InvokeNumber", "InvokeFloat", "SetFaceTextureSet",
  579. "InvokeBool", "GetFloat", "SetFloat", "SetSkillUsageMult",
  580. "GetNthTexturePath", "SetMeleePowerAttackStaggeredMult", "SetLongRangeStrafeMult", "SetGoldValue",
  581. "IsLetter", "IsClothingHead", "GetTotalItemWeight", "GetEnableParent",
  582. "GetNthChar", "GetMeleeBashAttackMult", "SetHue", "PushString",
  583. "GetHitEffectArt", "IsDigit", "AsOrd", "GetCostliestEffectIndex",
  584. "SetNthEffectArea", "GetNthRef", "GetEffectiveMagickaCost", "GetNumTintMasks",
  585. "SetFrequencyShift", "SetNthEntryStage", "IsAIEnabled", "GetFrequencyShift",
  586. "SetSkill", "GetDecibelVariance", "SetDecibelAttenuation", "GetDecibelAttenuation",
  587. "GetResistance", "IsClothingPoor", "GetQuest", "GetScriptVersionRelease",
  588. "GetNthEntryStage", "GetAlpha", "HasExtraPart", "GetHotkeyBoundObject",
  589. "SetNthRecoveryTime", "GetVersionMinor", "GetNthRecoveryTime", "RegisterForActorAction",
  590. "SetChanceGlobal", "SetEquipType", "SetSkillImproveOffset", "GetSkill",
  591. "GetIndexOfOverlayHeadPartByType", "SetHitShader", "SetCantOpenDoors", "SetTintMaskTexturePath",
  592. "SetResult", "RegisterForCameraState", "ReplaceHeadPart", "IsSkill",
  593. "GetNumPlayableRaces", "GetCloseRangeFlankingFlankDistance", "ClearAvoidsRoads", "GetHarvestSound",
  594. "SetAvoidsRoads", "SetAR", "GetNumAliases", "SetNoCombatInWater",
  595. "NoCombatInWater", "SetPerk", "GetNumKeywords", "SetHeight",
  596. "GetNthArmorAddon", "SetCloseRangeFlankingStalkTime", "IsBow", "GetTintMaskTexturePath",
  597. "MakeNotPushable", "GetAR", "GetMagickaCost", "IsNotPushable",
  598. "MakeMobile", "MakeImmobile", "IsClothingFeet", "ClearCantOpenDoors",
  599. "SetModelNthTextureSet", "SetNthIngredient", "SetHairColor", "SetModelPath",
  600. "GetBaseEnchantment", "GetModCount", "CantOpenDoors", "SetSkinFar",
  601. "GetLongRangeStrafeMult", "IsOffLimits", "GetOffensiveMult", "RegisterForKey",
  602. "MakeNonFlying", "CanFly", "SetGameSettingString", "CreateEnchantment",
  603. "SetSkillLegendaryLevel", "GetCloseRangeDuelingCircleMult", "SetCastTime", "MakePlayable",
  604. "SetAllowDualWielding", "GetNthIngredient", "SetShoutMult", "IsPlayable",
  605. "GetExperienceForLevel", "GetRangedMult", "GetShoutMult", "UnequipItemEx",
  606. "GetFaceTextureSet", "GetProjectile", "HoldKey", "SetHarvestSound",
  607. "PushFloat", "MakeUnplayable", "SetBlue", "GetSkillLegendaryLevel",
  608. "SetGreen", "GetNthEffectMagicEffect", "SetMessageIconPath", "GetMappedKey",
  609. "GetGreen", "SetNthCount", "GetCastTime", "GetNthEntryPriority",
  610. "SetNthEntryRank", "GetNthHeadPart", "GetAliasByName", "IsRead",
  611. "GetEquippedObject", "GetDisplayName", "GetNumRefs", "ModArmorRating",
  612. "IsHeavyArmor", "SetHarvested", "GetSkillUseMult", "ModAR",
  613. "GetTotalArmorWeight", "GetSkillUsageMult", "SetSkillUseMult", "GetNumReferenceAliases",
  614. "GetNodePositionZ", "SetExplosion", "SetWeaponType", "SetBool",
  615. "GetPriority", "SetMeleeBashPowerAttackMult", "GetEquippedItemId", "SetClass",
  616. "GetBlue", "SetGameSettingFloat", "GetItemCharge", "LogicalOr",
  617. "RightShift", "GetFlightDiveBombChance", "SetItemCharge", "GetHeadPart",
  618. "ReleaseKey", "GetMeleeBashPowerAttackMult", "SetVoiceType", "GetEquipType",
  619. "GetHitShader", "GetNthOverlayHeadPart", "RegisterForMenu", "SetLight",
  620. "IsBoots", "GetModelNumTextureSets", "SheatheWeapon", "MakeNonChildRace",
  621. "GetChanceNone", "GetNthEffectArea", "GetKeyword", "MakeNoKnockdowns",
  622. "SetRangedMult", "GetHairColor", "ChangeHeadPart", "ClearAllowPickpocket",
  623. }
  624.  
  625.  
  626. -- The following used to be generated from the Creation Kit wiki
  627. -- http://www.creationkit.com/Category:Events
  628. --
  629. -- Now generated from a collection of Papyrus files
  630. EventData = CaseType {
  631. -- Generated data for Skyrim
  632. "OnSell", "OnObjectUnequipped", "OnStoryIncreaseLevel", "OnPackageChange",
  633. "OnTranslationFailed", "OnUpdate", "OnRelease", "OnUpdateGameTime",
  634. "OnMagicEffectApply", "OnDestructionStageChanged", "OnDying", "OnStoryCraftItem",
  635. "OnPackageStart", "OnAnimationEventUnregistered", "OnGetUp", "OnClose",
  636. "OnTriggerLeave", "OnPackageEnd", "OnStoryIncreaseSkill", "OnItemAdded",
  637. "OnTranslationComplete", "OnWardHit", "OnTrigger", "OnDeath",
  638. "OnItemRemoved", "OnStoryFlatterNPC", "OnDetachedFromCell", "OnStoryPickLock",
  639. "OnCellDetach", "OnCellLoad", "OnOpen", "OnUnequipped",
  640. "OnSleepStop", "OnSpellCast", "OnTriggerEnter", "OnStoryNewVoicePower",
  641. "OnStoryInfection", "OnCombatStateChanged", "OnEffectFinish", "OnStoryEscapeJail",
  642. "OnStoryDialogue", "OnLocationChange", "OnRaceSwitchComplete", "OnEquipped",
  643. "OnTranslationAlmostComplete", "OnCellAttach", "OnStoryHello", "OnActivate",
  644. "OnStoryCure", "OnSleepStart", "OnLoad", "OnTrackedStatsEvent",
  645. "OnAnimationEvent", "OnPlayerBowShot", "OnStoryPlayerGetsFavor", "OnEffectStart",
  646. "OnPlayerLoadGame", "OnAttachedToCell", "OnSit", "OnEnterBleedout",
  647. "OnObjectEquipped", "OnLostLOS", "OnGrab", "OnTrapHitStop",
  648. "OnStoryBribeNPC", "OnStoryIntimidateNPC", "OnUnload", "OnRead",
  649. "OnLockStateChanged", "OnStoryActivateActor", "OnHit", "OnContainerChanged",
  650. "OnReset", "OnGainLOS",
  651.  
  652. -- Generated data for SkyUI
  653. "OnHighlightST", "OnConfigInit", "OnSelectST", "OnColorOpenST",
  654. "OnPageReset", "OnSliderAcceptST", "OnKeyMapChangeST", "OnOptionKeyMapChange",
  655. "OnColorAcceptST", "OnOptionColorOpen", "OnConfigOpen", "OnGameReload",
  656. "OnInit", "OnOptionMenuOpen", "OnOptionColorAccept", "OnOptionDefault",
  657. "OnOptionMenuAccept", "OnMenuOpenST", "OnVersionUpdate", "OnOptionSliderAccept",
  658. "OnSliderOpenST", "OnOptionSelect", "OnMenuAcceptST", "OnConfigRegister",
  659. "OnDefaultST", "OnConfigClose", "OnOptionSliderOpen", "OnOptionHighlight",
  660.  
  661. -- Generated data for SKSE
  662. "OnActorAction", "OnMenuOpen", "OnCrosshairRefChange", "OnMenuClose",
  663. "OnControlDown", "OnKeyUp", "OnKeyDown", "OnControlUp",
  664. "OnPlayerCameraState",
  665. }
  666.  
  667. IndentData = {}
  668. IndentData[TokenData.LEFTPAREN] = IndentRight
  669. IndentData[TokenData.LEFTBRACKET] = IndentRight
  670. IndentData[TokenData.LEFTWING] = IndentRight
  671.  
  672. IndentData[TokenData.RIGHTPAREN] = IndentLeft
  673. IndentData[TokenData.RIGHTBRACKET] = IndentLeft
  674. IndentData[TokenData.RIGHTWING] = IndentLeft
  675. --
  676. --
  677. --
  678.  
  679. function Lexer.NumberExponent(text, pos)
  680. local function IntExponent(text, pos)
  681. while true do
  682. local byte = StrByte(text, pos)
  683. if not byte then
  684. return TokenData.NUMBER, pos
  685. end
  686.  
  687. if byte >= ByteData.NUM_0 and byte <= ByteData.NUM_9 then
  688. pos = pos + 1
  689. else
  690. return TokenData.NUMBER, pos
  691. end
  692. end
  693. end
  694.  
  695.  
  696. local byte = StrByte(text, pos)
  697. if not byte then
  698. return TokenData.NUMBER, pos
  699. end
  700.  
  701. if byte == ByteData.MINUS then
  702. byte = StrByte(text, pos + 1)
  703. if byte == ByteData.MINUS then
  704. return TokenData.NUMBER, pos
  705. end
  706. return IntExponent(text, pos + 1)
  707. end
  708.  
  709. return IntExponent(text, pos)
  710. end
  711.  
  712. function Lexer.NumberFraction(text, pos)
  713. while true do
  714. local byte = StrByte(text, pos)
  715. if not byte then
  716. return TokenData.NUMBER, pos
  717. end
  718.  
  719. if byte >= ByteData.NUM_0 and byte <= ByteData.NUM_9 then
  720. pos = pos + 1
  721. elseif byte == ByteData.E or byte == ByteData.e then
  722. return Lexer.NumberExponent(text, pos + 1)
  723. else
  724. return TokenData.NUMBER, pos
  725. end
  726. end
  727. end
  728.  
  729. function Lexer.Number(text, pos)
  730. while true do
  731. local byte = StrByte(text, pos)
  732. if not byte then
  733. return TokenData.NUMBER, pos
  734. end
  735.  
  736. if byte >= ByteData.NUM_0 and byte <= ByteData.NUM_9 then
  737. pos = pos + 1
  738. elseif byte == ByteData.PERIOD then
  739. return Lexer.NumberFraction(text, pos + 1)
  740. elseif byte == ByteData.E or byte == ByteData.e then
  741. return Lexer.NumberExponent(text, pos + 1)
  742. else
  743. return TokenData.NUMBER, pos
  744. end
  745. end
  746. end
  747.  
  748. function Lexer.Identifier(text, pos)
  749. while true do
  750. local byte = StrByte(text, pos)
  751.  
  752. if not byte or
  753. newline[byte] or
  754. whitespaces[byte] or
  755. SymbolData[byte] then
  756. return TokenData.IDENTIFIER, pos
  757. end
  758. pos = pos + 1
  759. end
  760. end
  761.  
  762.  
  763. function Lexer.Comment(text, pos)
  764. local byte = StrByte(text, pos)
  765.  
  766. while true do
  767. byte = StrByte(text, pos)
  768. if not byte then
  769. return TokenData.COMMENT_SHORT, pos
  770. end
  771. if newline[byte] then
  772. return TokenData.COMMENT_SHORT, pos
  773. end
  774. pos = pos + 1
  775. end
  776. end
  777.  
  778. function Lexer.String(text, pos, character)
  779. local even = true
  780. while true do
  781. local byte = StrByte(text, pos)
  782. if not byte then
  783. return TokenData.STRING, pos
  784. end
  785.  
  786. if byte == character then
  787. if even then
  788. return TokenData.STRING, pos + 1
  789. end
  790. end
  791. if byte == ByteData.BACKSLASH then
  792. even = not even
  793. else
  794. even = true
  795. end
  796.  
  797. pos = pos + 1
  798. end
  799. end
  800.  
  801. function Lexer.GetToken(text, pos)
  802. local byte = StrByte(text, pos)
  803. if not byte then
  804. return nil
  805. end
  806.  
  807. if newline[byte] then
  808. return TokenData.LINEBREAK, pos + 1
  809. end
  810.  
  811. if whitespaces[byte] then
  812. while true do
  813. pos = pos + 1
  814. byte = StrByte(text, pos)
  815. if not byte or not whitespaces[byte] then
  816. return TokenData.WHITESPACE, pos
  817. end
  818. end
  819. end
  820.  
  821. local token = SymbolData[byte]
  822. if token then
  823. if token ~= -1 then
  824. return token, pos + 1
  825. end
  826.  
  827. if byte == ByteData.OR then
  828. byte = StrByte(text, pos + 1)
  829. if byte == ByteData.OR then
  830. return TokenData.OR, pos + 2
  831. end
  832. return TokenData.UNKNOWN, pos + 1
  833. end
  834.  
  835. if byte == ByteData.AND then
  836. byte = StrByte(text, pos + 1)
  837. if byte == ByteData.AND then
  838. return TokenData.AND, pos + 2
  839. end
  840. return TokenData.UNKNOWN, pos + 1
  841. end
  842.  
  843. if byte == ByteData.SEMICOLON then
  844. return Lexer.Comment(text, pos + 1)
  845. end
  846.  
  847. if byte == ByteData.SINGLE_QUOTE then
  848. return Lexer.String(text, pos + 1, ByteData.SINGLE_QUOTE)
  849. end
  850.  
  851. if byte == ByteData.DOUBLE_QUOTE then
  852. return Lexer.String(text, pos + 1, ByteData.DOUBLE_QUOTE)
  853. end
  854.  
  855. if byte == ByteData.LEFTBRACKET then
  856. return TokenData.LEFTBRACKET, pos + 1
  857. end
  858.  
  859. if byte == ByteData.EQUALS then
  860. byte = StrByte(text, pos + 1)
  861. if not byte then
  862. return TokenData.ASSIGNMENT, pos + 1
  863. end
  864. if byte == ByteData.EQUALS then
  865. return TokenData.EQUALITY, pos + 2
  866. end
  867. return TokenData.ASSIGNMENT, pos + 1
  868. end
  869.  
  870. if byte == ByteData.PERIOD then
  871. byte = StrByte(text, pos + 1)
  872. if not byte then
  873. return TokenData.PERIOD, pos + 1
  874. end
  875. if byte >= ByteData.NUM_0 and byte <= ByteData.NUM_9 then
  876. return Lexer.NumberFraction(text, pos + 2)
  877. end
  878. return TokenData.PERIOD, pos + 1
  879. end
  880.  
  881. if byte == ByteData.LESSTHAN then
  882. byte = StrByte(text, pos + 1)
  883. if byte == ByteData.EQUALS then
  884. return TokenData.LTE, pos + 2
  885. end
  886. return TokenData.LT, pos + 1
  887. end
  888.  
  889. if byte == ByteData.GREATERTHAN then
  890. byte = StrByte(text, pos + 1)
  891. if byte == ByteData.EQUALS then
  892. return TokenData.GTE, pos + 2
  893. end
  894. return TokenData.GT, pos + 1
  895. end
  896.  
  897. if byte == ByteData.EXCLAMATIONMARK then
  898. byte = StrByte(text, pos + 1)
  899. if byte == ByteData.EQUALS then
  900. return TokenData.NE, pos + 2
  901. end
  902. return TokenData.NOT, pos + 1
  903. end
  904.  
  905. return TokenData.UNKNOWN, pos + 1
  906. elseif byte >= ByteData.NUM_0 and byte <= ByteData.NUM_9 then
  907. return Lexer.Number(text, pos + 1)
  908. else
  909. return Lexer.Identifier(text, pos + 1)
  910. end
  911. end
  912.  
  913. --
  914. --
  915. --
  916.  
  917. local function IndentTabs(n, unused)
  918. return StrRep("\t", n)
  919. end
  920.  
  921. local function IndentSpaces(a, b)
  922. return StrRep(" ", a*b)
  923. end
  924.  
  925. function IndentCode(code, width, position)
  926. local Indentfunction
  927.  
  928.  
  929. local tsize2 = 0
  930. local totalLen2 = 0
  931.  
  932. local newPosition
  933. local bNewPosition = false
  934. local prevTokenWidth = 0
  935.  
  936. local pos = 1
  937. local IndentLevel = 0
  938.  
  939. local bNonWhitespace = false
  940. local bIndentRight = false
  941. local preIndent = 0
  942. local postIndent = 0
  943.  
  944. local tsize = 0
  945. local totalLen = 0
  946.  
  947. if width == nil then
  948. width = defaultTabWidth
  949. end
  950. if width then
  951. Indentfunction = IndentSpaces
  952. else
  953. Indentfunction = IndentTabs
  954. end
  955.  
  956. EraseTable(codeTable01)
  957. EraseTable(codeTable02)
  958.  
  959. while true do
  960. if position and not newPosition and pos >= position then
  961. if pos == position then
  962. newPosition = totalLen + totalLen2
  963. else
  964. newPosition = totalLen + totalLen2
  965. local diff = pos - position
  966. if diff > prevTokenWidth then
  967. diff = prevTokenWidth
  968. end
  969. newPosition = newPosition - diff
  970. end
  971. end
  972.  
  973. prevTokenWasColored = false
  974. prevTokenWidth = 0
  975.  
  976. local tokenType, nextPos = Lexer.GetToken(code, pos)
  977.  
  978. if not tokenType or tokenType == TokenData.LINEBREAK then
  979. IndentLevel = IndentLevel + preIndent
  980. if IndentLevel < 0 then IndentLevel = 0 end
  981.  
  982. local s = Indentfunction(IndentLevel, width)
  983.  
  984. tsize = tsize + 1
  985. codeTable01[tsize] = s
  986. totalLen = totalLen + StrLen(s)
  987.  
  988. if newPosition and not bNewPosition then
  989. newPosition = newPosition + StrLen(s)
  990. bNewPosition = true
  991. end
  992.  
  993.  
  994. for k, v in next,codeTable02 do
  995. tsize = tsize + 1
  996. codeTable01[tsize] = v
  997. totalLen = totalLen + StrLen(v)
  998. end
  999.  
  1000. if not tokenType then
  1001. break
  1002. end
  1003.  
  1004. tsize = tsize + 1
  1005. codeTable01[tsize] = StrSub(code, pos, nextPos - 1)
  1006. totalLen = totalLen + nextPos - pos
  1007.  
  1008. IndentLevel = IndentLevel + postIndent
  1009. if IndentLevel < 0 then IndentLevel = 0 end
  1010.  
  1011. EraseTable(codeTable02)
  1012. tsize2 = 0
  1013. totalLen2 = 0
  1014.  
  1015. bNonWhitespace = false
  1016. bIndentRight = false
  1017. preIndent = 0
  1018. postIndent = 0
  1019. elseif tokenType == TokenData.WHITESPACE then
  1020. if bNonWhitespace then
  1021. prevTokenWidth = nextPos - pos
  1022.  
  1023. tsize2 = tsize2 + 1
  1024. local s = StrSub(code, pos, nextPos - 1)
  1025. codeTable02[tsize2] = s
  1026. totalLen2 = totalLen2 + StrLen(s)
  1027. end
  1028. else
  1029. bNonWhitespace = true
  1030.  
  1031. local str = StrSub(code, pos, nextPos - 1)
  1032.  
  1033. prevTokenWidth = nextPos - pos
  1034.  
  1035. local indentTable
  1036. if tokenType == TokenData.IDENTIFIER then
  1037. local tempstr = string.lower(str)
  1038.  
  1039. local RefName,RefOrig,RefType = FindKeywordReference(tempstr)
  1040. indentTable = RefType
  1041.  
  1042. if ApiData[tempstr] then
  1043. str = ApiData[tempstr]
  1044. elseif RefName then
  1045. str = RefOrig
  1046. elseif ScriptObjects[tempstr] then
  1047. str = ScriptObjects[tempstr]
  1048. elseif EventData[tempstr] then
  1049. str = EventData[tempstr]
  1050. end
  1051. else
  1052. indentTable = IndentData[tokenType]
  1053. end
  1054.  
  1055. if indentTable then
  1056. if bIndentRight then
  1057. postIndent = postIndent + indentTable[1] + indentTable[2]
  1058. else
  1059. local pre = indentTable[1]
  1060. local post = indentTable[2]
  1061. if post > 0 then
  1062. bIndentRight = true
  1063. end
  1064. preIndent = preIndent + pre
  1065. postIndent = postIndent + post
  1066. end
  1067. end
  1068.  
  1069. if FindKeywordReference(str) then
  1070. tokenType = TokenData.KEYWORD
  1071. end
  1072.  
  1073. tsize2 = tsize2 + 1
  1074. codeTable02[tsize2] = str
  1075. totalLen2 = totalLen2 + nextPos - pos
  1076. end
  1077. pos = nextPos
  1078. end
  1079. return table.concat(codeTable01), newPosition
  1080. end
  1081.  
  1082. local function PrintUsage()
  1083. io.stderr:write(StrFormat(
  1084. "Usage %s [options] [script.psc]\n"..
  1085. "Available options are:\n"..
  1086. " -s[number] Spacing to indent, TAB spacing is default\n"..
  1087. " -b Backup the Papyrus Script\n"
  1088. , program))
  1089. io.stderr:flush()
  1090. end
  1091.  
  1092. if _G.arg and _G.arg[0] and #_G.arg[0] > 0 then
  1093. program = _G.arg[0]
  1094. end
  1095.  
  1096. local argv = {...}
  1097.  
  1098.  
  1099. local function CollectArgs(argv,p)
  1100. local i = 1
  1101. while i <= #argv do
  1102. if StrSub(argv[i],1,1) ~= '-' then
  1103. return i
  1104. end
  1105.  
  1106. local option = StrSub(argv[i],2,2)
  1107. if option == 'b' then
  1108. if #argv[i] > 2 then return -1 end
  1109. p[option] = true
  1110. elseif option == 's' then
  1111. local spacing = tonumber(StrSub(argv[i],3,7))
  1112. if type(spacing) ~= 'number' then return -1 end
  1113. p['spacing'] = spacing
  1114. p[option] = true
  1115. else
  1116. return -1
  1117. end
  1118. i = i + 1
  1119. end
  1120. return 0
  1121. end
  1122.  
  1123. HasOptions = {
  1124. b = false,
  1125. s = false
  1126. }
  1127.  
  1128. local PapyrusScript = CollectArgs(argv,HasOptions)
  1129.  
  1130. if PapyrusScript <= 0 then
  1131. PrintUsage()
  1132. OsExit(1)
  1133. end
  1134.  
  1135. local script = argv[PapyrusScript]
  1136. local spacing = HasOptions['spacing'] or nil
  1137.  
  1138. local TempFileName = os.tmpname()
  1139. local PapyrusFile = io.open(script, "r")
  1140.  
  1141. if PapyrusFile == nil then
  1142. OsError('Could not open file for reading "'..script..'"')
  1143. end
  1144.  
  1145. local TempFile = io.open(TempFileName,"w")
  1146. if TempFile == nil then
  1147. OsError('Could not open file for reading "'..TempFileName..'"')
  1148. end
  1149.  
  1150. local Code = PapyrusFile:read("*a")
  1151.  
  1152. if HasOptions.b then
  1153. local BackupFile = io.open(script..'.backup',"w")
  1154. if BackupFile == nil then
  1155. OsError('Could not open file for reading "'..script..'.backup'..'"')
  1156. end
  1157. BackupFile:write(Code)
  1158. BackupFile:close()
  1159. end
  1160.  
  1161. local IndentedCode = IndentCode(Code, spacing)
  1162.  
  1163. TempFile:write(IndentedCode)
  1164. PapyrusFile:close()
  1165. TempFile:close()
  1166.  
  1167. os.remove(script)
  1168. os.rename(TempFileName,script)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement