Skip to content

Instantly share code, notes, and snippets.

@mrowrpurr
Created August 19, 2021 21:16
Show Gist options
  • Save mrowrpurr/3a8ff90e78482a6a24498fc0e7c4eedb to your computer and use it in GitHub Desktop.
Save mrowrpurr/3a8ff90e78482a6a24498fc0e7c4eedb to your computer and use it in GitHub Desktop.
string characters = "0123456789abcdef"
int[] characterValues = new int[16]
; 0 - 9
characterValues[0] = 48 ; 0
characterValues[1] = 49 ; 1
characterValues[2] = 50 ; 2
characterValues[3] = 51 ; 3
characterValues[4] = 52 ; 4
characterValues[5] = 53 ; 5
characterValues[6] = 54 ; 6
characterValues[7] = 55 ; 7
characterValues[8] = 56 ; 8
characterValues[9] = 57 ; 9
; A - F
characterValues[10] = 65 ; A
characterValues[11] = 66 ; B
characterValues[12] = 67 ; C
characterValues[13] = 68 ; D
characterValues[14] = 69 ; E
characterValues[15] = 70 ; F
string hex = "000800"
int decimal
int base = 1
int index = 5
while index >= 0
string character = StringUtil.Substring(hex, index, 1)
int characterIndex = StringUtil.Find(characters, character)
int characterValue = characterValues[characterIndex]
if characterValue >= 48 && characterValue <= 57 ; 0 - 9
decimal = decimal + (characterValue - 48) * base
base = base * 16
elseIf characterValue >= 65 && characterValue <= 70 ; A - F
decimal = decimal + (characterValue - 55) * base
base = base * 16
endIf
index -= 1
endWhile
Debug.MessageBox("hex: " + hex + " is " + decimal)
Debug.MessageBox(Game.GetFormFromFile(decimal, "Foo.esp"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment