Asterra Posted February 16, 2015 Share Posted February 16, 2015 (edited) Surprising difficulty with this. Let's take Muiri, for example. She's a Breton. GetRace().GetName() gives the following: "Breton". This is not any use to me, because it's too general. If I do the same thing wth Sybille, I also get "Breton", but Sybille is in fact a Breton Vampire. So how about just GetRace()? Well, for Muiri, we get "[Race <BretonRace (00013741)>]". For Sybille, we get "[Race <BretonRaceVampire (0008883C)>]". The "BretonRace" and "BretonRaceVampire" are what I am after, but the given strings are all but worthless to me with the unneeded brackets, numbers and such. Is there a function that will return the actual race ID as shown in the CK? ("BretonRaceVampire", etc.) Edit: It can be done with StringUtil, I know. I'm just poking around for a more elegant method, if it exists. Edited February 16, 2015 by Asterra Link to comment Share on other sites More sharing options...
heromaster Posted February 16, 2015 Share Posted February 16, 2015 (edited) Did you tried Actor.GetActorBase().GetRace().GetName()? Edited February 16, 2015 by heromaster Link to comment Share on other sites More sharing options...
theimmersion Posted April 4, 2015 Share Posted April 4, 2015 Maybe it needs those separated? I never knew you could call two or more different functions at once.I mean, how do you translate that into a variable?Id do like: String sVarNameString sVarRacesVarName = TargetActor.GetName()sVarRace = TargetActor.GetRace()Debug.Notification("Name: "+(sVarName)+" Race: "+(sVarRace)+"") Tho, im new to scripting skyrim so i might be wrong. Do tell how it works for others with similar problems in future. Link to comment Share on other sites More sharing options...
Arocide Posted April 4, 2015 Share Posted April 4, 2015 (edited) Sadly no, I don't think you can get editor IDs directly outside of Quests (Which has a SKSE function to do that). I found using the 'Vampire' keyword was easiest to distinguish the two when using name since all vampire races run with the vampire keyword. EDIT: Just realised this is a month and a half old whoops. You've probably already figured out what you can do :D Edited April 4, 2015 by Arocide Link to comment Share on other sites More sharing options...
theimmersion Posted April 4, 2015 Share Posted April 4, 2015 EDIT: Just realised this is a month and a half old whoops. You've probably already figured out what you can do :DWould be nice if he shared how he made it work tho for future modders and such. xD I guess he did it manually perhaps? like, if its a breton, rather than printing out the race variable, he wrote it.Like: If TargetActor.GetRace() == ArgonianRace sVarName = TargetActor.GetName() Debug.Notification("Race: ArgonianRace Name: "+(sVarName)+"")elseIf TargetActor.GetRace() == ArgonianRaceVamire sVarName = TargetActor.GetName() Debug.Notification("Race: ArgonianRaceVampire Name: "+(sVarName)+"")elseIf TargetActor.GetRace() == BretonRace etc endif Link to comment Share on other sites More sharing options...
Arocide Posted April 4, 2015 Share Posted April 4, 2015 (edited) Possibly, that could get a little long winded though. I would think he probably went with StringUtils as he mentioned he could use which could be pretty compact and not overly complex something like: string fullID = TargetActor.GetRace() int temp = StringUtil.Find(fullID,"<",0) int subLength = StringUtil.Find(fullID," ", temp) - temp string EditorID = StringUtil.SubString(fullID, temp + 1, subLength ) I think that would get what he wanted, and at least wouldn't have to write out all those long winded if statements :wink:. Edited April 4, 2015 by Arocide Link to comment Share on other sites More sharing options...
theimmersion Posted April 4, 2015 Share Posted April 4, 2015 (edited) But that would make it mod dependant when it doenst really need to? It gets wrote once and its not a constant check. It gets checked on demand and otherwise the big code is inactive. xD if PlayerRef.GetRace() == ArgonianRace elseif PlayerRef.GetRace() == ArgonianRaceVampire elseif PlayerRef.GetRace() == BretonRace elseif PlayerRef.GetRace() == BretonRaceVampire elseif PlayerRef.GetRace() == BretonRaceChild elseif PlayerRef.GetRace() == BretonRaceChildVampire elseif PlayerRef.GetRace() == DarkElfRace elseif PlayerRef.GetRace() == DarkElfRaceVampire elseif PlayerRef.GetRace() == HighElfRace elseif PlayerRef.GetRace() == HighElfRaceVampire elseif PlayerRef.GetRace() == ImperialRace elseif PlayerRef.GetRace() == ImperialRaceVampire elseif PlayerRef.GetRace() == ImperialRaceChild elseif PlayerRef.GetRace() == KhajiitRace elseif PlayerRef.GetRace() == KhajiitRaceVampire elseif PlayerRef.GetRace() == NordRace elseif PlayerRef.GetRace() == NordRaceVampire elseif PlayerRef.GetRace() == NordRaceChild elseif PlayerRef.GetRace() == OrcRace elseif PlayerRef.GetRace() == OrcRaceVampire elseif PlayerRef.GetRace() == RedGuardRace elseif PlayerRef.GetRace() == RedGuardRaceVampire elseif PlayerRef.GetRace() == RedGuardRaceChild elseif PlayerRef.GetRace() == WoodElfRace elseif PlayerRef.GetRace() == WoodElfRaceVampire else ;custom unknown race or form? debug.Notification("NOT A NORD? BLASPHEMY!") ; xD endif Copy paste from my mod. D*mn, if theres an easier way tho, with avoiding mod dependancy like StringUtil, id very much appretiante it. xD Edited April 4, 2015 by theimmersion Link to comment Share on other sites More sharing options...
Arocide Posted April 4, 2015 Share Posted April 4, 2015 (edited) Personally I don't think of depending on SKSE as an issue, it's pretty general purpose what I wrote it could get any editorID of any form (Assuming you changed it to a function) eg: string Function GetEditorID(Form akForm) Global string fullID = akForm int temp = StringUtil.Find(fullID,"<",0) int subLength = StringUtil.Find(fullID," ", temp) - temp return StringUtil.SubString(fullID, temp + 1, subLength ) EndFunction It would work just fine for all forms unlike if blocks, but you are entirely right it would be calculating it each time so it is definitely the more intensive option depending on what the OP was intending to do with the editorID once they had it. EDIT: incase it isn't painfully obvious I am a pretty lazy scripter if I can get away with writing less (providing it doesn't massively increase overhead / hog cpu time) I'll usually do it :sweat:. EDIT2: That would depend on why you are checking my friend. If you had specific code to run depending on the race you maybe able to condense it but you might not, if it was just to see if it is any of those I could see it condensed greatly, or if you were just checking for vampirism that could also be condensed greatly. I guess you could say it all comes down to why you are doing it. Edited April 4, 2015 by Arocide Link to comment Share on other sites More sharing options...
theimmersion Posted April 4, 2015 Share Posted April 4, 2015 Wait, im ok with SKSE, its part of patching for me like the skyrim update and USKP but out side of that, i like to keep it minimum, i was thinking it would be dependant on StringUtil. Isnt that a suplement for SKSE or a mod? or is it incorporated? I always wanted an .xml support for my mods but they require mods that add that function separately and this making it dependable on even more mods than just SKSE in general. Ppl do it for the custom mods via SKSE.dll and such but im not that advanced to make my own SKSE plugin that can export strings and settings from my scripts to a external .xml file. T.TAlso, your mod and my mod does a check but it depends on what initiates it. Right? Like, your code wont be exectued until told to or is that how it works??Like:Event OnCrosshairChange() code to get the race and nameEndEvent Or something like that? or on button press etc... or even set on OnUpdate but thats stretching it a bit for this kind of functionality.If we knew what the purpose of getting the name and race name is, might have a totally different approach. Link to comment Share on other sites More sharing options...
Arocide Posted April 4, 2015 Share Posted April 4, 2015 (edited) Don't worry, StringUtil was introduced by SKSE a long while ago so as long as you have SKSE you'll have access to StringUtil. All the functions are global though so you either have to import or to prefix. If you ever do want to use external config files I would suggest JContainers it only supports JSON files but it also has a very nice Papyrus API (not to mention the author is quite helpful) which helps greatly. I've been using it for awhile so I might be a bit bias there. My function would still have to be called so it would be something like (if I was to use your example): Event OnCrosshairChange() GetEditorID({FormToCalcFor}) EndEvent You would have to prefix it of course if it wasn't in the same script or since it has the global flag you could put it in a separate utilities script not attached to anything and still call it (Providing you use a prefix) so it's a little bit of versatile, re-usable code. Edited April 4, 2015 by Arocide Link to comment Share on other sites More sharing options...
Recommended Posts