Papyrus Formlist Declaration Question

Post » Sat Aug 17, 2013 1:51 pm

If I write the following code:

Function BaseKeys(actor akTarget)   OMZkey = 50   OMZform = akTarget.GetRace() as form   If (RacesBeast.HasForm(OMZform) == True)      OMZkey += 10 * playerREF.GetRelationshipRank(akTarget)   endIf   OMZstage = 7endFunction

I use a formlist that is defined in the creation kit "RacesBeast" but even though it is defined in the creation kit, I still need to declare it as if it is a new formlists that papyrus knows nothing about. (Please correct me if that is not true)

Now that I have declared it, does papyrus see the elements of the formlist in the creation kit (KhajiitRace and ArgonianRace) or do I need to define those as well and tell papyrus that they are in the RacesBeast formlist?

User avatar
Lindsay Dunn
 
Posts: 3247
Joined: Sun Sep 10, 2006 9:34 am

Post » Sat Aug 17, 2013 9:23 pm

Post your whole script.

When you say you "declared" your formlist, do you mean to say you made a property (and filled that property in the CK). You do need to make a property to the formlist in order to use it. You do not have to make race properties for the HasForm to work. Here are a couple examples below...

This code works fine and compiles.

Formlist Property RacesBeast AutoFunction SomeFunction(Actor akTarget)    Race kTargetRace = akTarget.GetRace()    if RacesBeast.HasForm(kTargetRace)        ;do stuff    endIfendFunction

This code does not work. Although the Argonian race is in the formlist, papyrus cannot see it.

Formlist Property RacesBeast AutoFunction SomeFunction(Actor akTarget)    Race kTargetRace = akTarget.GetRace()    if kTargetRace == ArgonianRace ;does NOT work - argonian race undefined        ;do stuff    endIfendFunction

This code works because we used the GetAt function and the respective index to get the Argonian race

Formlist Property RacesBeast AutoFunction SomeFunction(Actor akTarget)    Race kTargetRace = akTarget.GetRace()    Race ArgonianRace = RacesBeast.GetAt(0) as Race    if kTargetRace == ArgonianRace        ;do stuff    endIfendFunction

Hope that clears some stuff up. But again, posting your whole script rather than a fragment is very useful :smile:

Also, you can name your properties and variables anything you'd like - they don't have to match the CK name. The only advantage of using the exact CK name for properties is that you can auto-fill them.

User avatar
Racheal Robertson
 
Posts: 3370
Joined: Thu Aug 16, 2007 6:03 pm


Return to V - Skyrim