TimThe7th Posted August 29, 2021 Posted August 29, 2021 I'm pretty new to papyrus, so I'm sure I'm making some rookie mistake. Trying to show certain messages based on race--I have race properties and for the most part it seems to work right. But regardless of what race I am, it shows Dark Elf. I suspect it's just using the first if statement, ignoring the ElseIfs, as when I swap the Nord for the Dark Elf it shows the message box for the Nord. Obviously this only really works for Dunmer/Nords, any other race will show Imperial (I'll add them eventually), but even noting that it's not functioning correctly. Any clue what's wrong with the first If in the function? Scriptname SkillAssign extends ObjectReference Import Game Import Actor Import Utility ; Message Boxes Message Property ccDunmerInfo Auto Message Property ccImperialInfo Auto Message Property ccNordInfo Auto ; Races Race Property ArgonianRace Auto Race Property BretonRace Auto Race Property DarkElfRace Auto Race Property HighElfRace Auto Race Property ImperialRace Auto Race Property KhajiitRace Auto Race Property NordRace auto Race Property OrcRace Auto Race Property RedguardRace Auto Race Property WoodElfRace Auto ; Other Actor Property PlayerRef Auto ; Events Event OnActivate(ObjectReference akActionRef) RaceMenu() EndEvent ; Functions Function RaceMenu(int aiButton = 0) Race pRace = PlayerRef.GetRace() If pRace == DarkElfRace aiButton = ccDunmerInfo.show() ElseIf pRace == NordRace aiButton = ccNordInfo.show() Else aiButton = ccImperialInfo.show() EndIf If aiButton == 0 ElseIf aiButton == 1 ShowRaceMenu() EndIf EndFunction Edit: Tried replacing it with this much simpler function and it still shows "Dunmer": ; Functions Function RaceMenu() Race pRace = PlayerRef.GetRace() If pRace == DarkElfRace Debug.MessageBox("Dunmer") ElseIf pRace == NordRace Debug.MessageBox("Nord") Else Debug.MessageBox("Other") EndIf EndFunction
IsharaMeradin Posted August 29, 2021 Posted August 29, 2021 Did you make sure to assign the correct data to the properties? If not, it will assign a NONE value. Then when the script runs it will assign pRace a NONE value because getting the race from a NONE value is a NONE value. And then that in turn will always be equal to the first condition as it too will have a NONE value. TLDR: Open up the record(s) holding the script, highlight the script, click on the property button and assign the correct data to the variables.
TimThe7th Posted August 29, 2021 Author Posted August 29, 2021 That worked. I knew it was a stupid rookie mistake. I specifically recall auto-filling all properties (which is what was needed), but I tend to cancel out instead of clicking ok on every box. I ran into this issue several times when doing tutorials. Hopefully my muscle memory gets better as I continue to code. Thanks for your help, canât believe I spent two hours trying to troubleshoot this.
Recommended Posts