Jump to content

Photo

Papyrus Convert Hex String to Int

papyrus scripting

  • Please log in to reply
1 reply to this topic

#1
skyrimisokiguess

skyrimisokiguess

    Enthusiast

  • Members
  • PipPip
  • 123 posts

Hello everyone,

 

I'm relatively new to Skyrim modding and Papyrus, but sometimes I feel like I just can't find reference info about some really basic things. I'm trying to parse a string that contains a Hexadecimal number into an int value (eg. "0x10" -> 16). Basically, I'm reading Form ID values from a config file, and I want to use them for Game.GetFormFromFile but I just can't figure out how to parse the string as a hex int.

I've tried casting to int, but that just seems to parse it as 0 (maybe because of the leading 0? If I pass "123" to sampleText it makes it to the message properly):

String sampleText = "0xF"
Debug.MessageBox(sampleText as int) ; Outputs 0

I'm running out of ideas about how to handle this, and I really don't want to write my own parser. Does anyone know of a string hex number parser either built in or in SKSE or PapyrusUtil? I'm hoping this is just a noob question with a really simple answer.

 

Thanks,

v

 



#2
skyrimisokiguess

skyrimisokiguess

    Enthusiast

  • Members
  • PipPip
  • 123 posts

For anyone visiting from the future, I just wrote it myself. I uploaded it on Nexus as HexUtil, if anyone ever needs this functionality too and is feeling a bit lazy.







Also tagged with one or more of these keywords: papyrus, scripting

IPB skins by Skinbox
Page loaded in: 0.796 seconds