Truncate String, and convert to Float?

Post » Mon Apr 28, 2014 1:12 am

So, bear with me on this crazy thing I want to do...

What I need to do is:

1) Get a String that equals the Editor ID of a given Object;

2) Truncate that String to the first 2 characters*

3) Convert that string to a Float.

What I want to do is, for example, have an item with a name such as 20ShortSword, and have the game work out the value '20' from that name.

According to the Wiki, Casting will convert a String to its Float/Int representation, but I do not know if what will be produced (i.e., is the representation of the characters '20' or is it something else? I'm inclined to think the latter, but... Can't test just yet :/ )

According to the Cast-to-string example, "x = 15 as String" produces the string, 15, but I don't know if that works in reverse; and I still need to truncate the rest...

Any help would be really useful, because I'm at a blank :/

*Does Skyrim have the same issue as Oblivion with Numbers at the beginning of an Editor ID? And if so, can I truncate the opposite way, so I can cut off a few characters at the start?

User avatar
Yvonne Gruening
 
Posts: 3503
Joined: Mon Apr 23, 2007 7:31 pm

Return to V - Skyrim