Jump to content

Converting Object to String


Xander9009

Recommended Posts

MiscObjectREF as String returns "[MiscObject" or something similar. How can I get the name of a MiscObject property in a script as a string?

 

 

I'm trying to write a script which replaces the default mining script. I want to give the player a number of ores each time ore is given based on their smithing skill. That part is fine. But I also want the mine to be depleted only after a set number of hits based on what type of ore it produces. So, if the mine produces iron ore, you can harvest ore 6 times. If it produces gold, ebony, or orichalcum, then it'll only produce ore once (but the number it produces is still based on your smithing).

 

Now that the idea is outlined, here's the problem: each mine in the game has its own activator object with its own editor id and none are based on a base object to which I can attach the script. (That's an exaggeration, I know. There isn't actually one per mine in the game, but scrolling through the list certainly makes it seem that way.) Anyway, there are hundreds of mines and no base object. So, to check the ore type by comparing it to the actual references to ore types would require using "MiscObject Property OreNameHere Auto", one for each ore type, and then to set the properties. That wouldn't be so bad except the properties would need set (autofilled, at least) for each of the hundreds of mines separately.

 

I figured if I compared the ore's name to a string, the string could be set as a normal variable instead of a property, meaning it wouldn't need set anywhere.

 

After all of that, I remembered there was an SKSE function GetName() which worked. And thanks to SKSE's StringUtil.Find() function, it'll even work whether Better Sorting or a similar mod is installed or not (unless they completely remove "Iron" from iron ore, etc.). I thought I'd go ahead and post it in case anyone else doesn't know about it.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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