[Closed] Scritpting: missing functions

¡Feliz Navidad!

There is somthing I’m missing in the scrpting language of NWN.

I’m missing a function that returns the code of Character. (VBA-Equivalent is “asc”)
i.e. A call of this function with the parameter “A” should return the value 64.

How to convert an Hex-String into an int?
int i = StringToInt (“0xDDDD”) fails. i is 0 after that call.

I already found workarounds for this missing functions, but I wonder if somebody could tell me if they are really not there.

Hex string to int isn’t built into the game but here is an efficient implementation of it; https://github.com/Finaldeath/nwscript_utility_scripts/blob/master/maths/utl_i_maths.nss#L104

Thanks. It’s just a bit confusing, that the reverse function (IntToHexString) is there.

There’s plenty of other times a function needs to be made up, mainly around math and strings, from other ones. Adding functions that are easily made just takes time away from adding more useful stuff you can’t make.

For now I will assume, that functions to convert a Character in into it’s code - number and back aren’t implemented. Case Closed.

I mean you can define ascii codes in nwn directly now, or search along a line them for a specific one (string to its int) I guess. Or use functions available in sqlite to do it.

It really depends on your use case, I’ve never heard of someone needing the raw ascii codes of text before.

Example of using the ascii codes available in nwscript to do color codes; https://github.com/Finaldeath/nwscript_utility_scripts/blob/master/strings/utl_i_strings.nss

Does that help?

Yes, of course. Seemingly later versions of the EE are a bit advanced, now “escaped” hex-values are allowed. “\x22” should be a single ". This also points out, that there is nothing similar in 1.69.

1.69 used something similar look at x3_inc_string and the StringToRGBString function, or the past edit of that file.

If you’re stuck on 1.69 I can’t point out sqlite and other things with various ascii and text functions alas.

I already said in my original post, I already found a workaround for my problem. I’m just curious.

I’ll have a close look on the StringToRGB function.


edit: StringToRGB just picks single characters from a “color-string” with the GetSubString-Function. The “color-string” is given as literal in the code.