Jump to content

Using SkyUILib but cannot get integer from textinput


Recommended Posts

I'm trying to use the textinput function in SkyUiLib to input a formid and then get the form, GetForm() requites an Int but casting a string in the form ff00009cd dosen't work, but casting a string like 123456 does.

What is odd is that the creationkit shows that the Int required by GetForm() (and presumably by GetFormEx() ) is in the form 0xNNNNNNNN.

Is there a way to get my string - either in form 0xNNNNNNNN or just NNNNNNNN - into an Int that Getform() will accept?

 

diziet

Link to comment
Share on other sites

Here is the relevant code:

UILIB_1 uilib = ((Self as Form) as UILIB_1)
String input_formid = uilib.ShowTextInput("Type the FormId in 0xNNNNNNNN format", "")
debug.trace("input_formid is "+input_formid+". as int is "+(input_formid As Int))
Int myInt = ("0x"+input_formid) as Int
debug.trace("myInt is "+myInt)

here is the result if the input is FF0009CD:

[04/19/2022 - 08:38:20PM] input_formid is ff0009cd. as int is 0
[04/19/2022 - 08:38:20PM] myInt is 0

 

if I convert the hex to decimal first:

[04/19/2022 - 08:40:51PM] input_formid is 4278192589. as int is 2147483647
[04/19/2022 - 08:40:51PM] myInt is 0

 

how 4278192589 becomes 2147483647 I'm ot sure unless it's one of these 32bit wrap around thing I read about and never understand?

 

diziet

Link to comment
Share on other sites

String input_formid = uilib.ShowTextInput("Type the FormId in 0xNNNNNNNN format", "")

Can that line be done as

Int input_formid = uilib.ShowTextInput("Type the FormId in 0xNNNNNNNN format", "")

provided that the user includes the 0x when typing in the Form ID?

 

I really haven't a clue, just tossing out some ideas that you may or may not have thought about. I, personally, have not used any of the SkyUILib stuff. I am not sure what tricks will work here and what won't.

Link to comment
Share on other sites

For GetForm, you replace the first two characters of the hex id with 0x. So in your example FF0009CD should become 0x0009CD.

 

Edit:

NVM that's for GetFormFromFile.

 

What you can try is use to use Papyrus Extender's StringToInt function.

Link to comment
Share on other sites

GetForm is for Skyrim.esm. What you likely are wanting is GetFormEx() which can be stored as string and read as Int

 

Tends to be useful in relative situations where it can read a reliably available ID relative to the entity we have stored or are reading

Link to comment
Share on other sites

The issue for me here is getting the Int in the first place from a string that says NNNNNNNN or 0xNNNNNNNN, the Papyrus Extender functions sounds interesting.

I have tried using GetFormEx as such:

Form akForm = Game.GetFormEx(aiFormID)

where aiFormID is in fact the string, Can you give a few examples of what you mean by:

"GetFormEx() which can be stored as string and read as Int"

since the CK wiki does not have a page for GetFormEx()

 

diziet

Link to comment
Share on other sites

This is from one of the source files of Papyrus Extender:

;STRINGS
;----------------------------------------------------------------------------------------------------------
;Converts string to hex value if valid
String Function IntToString(int aiValue, bool abHex) global native

;Converts string to int. Returns -1 for out of bound values.
int Function StringToInt(String asString) global native

now the description of the first function sound brill, but the function doesn't seem to match:)

using the second function every result is -1

I have used the strings "FF0009CD", "0xFF0009CD" and "4278192589", for the record this formid is real, it is the refid in my game of Miraak's Boots!

 

diziet

Link to comment
Share on other sites

NVM I think I follow what you are doing now at least partly. Appears you are providing a literal hex at runtime but the problem is at runtime you need the actual decimal

 

SKSE has the ability to convert this and in a roundabout way does so in the MCM when resolving key codes to what the keyboard character equates to. Short version is that particular piece was hidden from us, as far as I have determined, so youd have to basically attempt to ask them how they do that or try to figure it out. Aside though, once you get the right decimal you would actually do Game.GetFormFromFile() and you need to resolve the mod name unless you provide it. Theres a RightShift call to resolve mod name from a baseobject but cant seem to locate it :\

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...