Jump to content

(SOLVED) Need some help with accessing properties from an external script


Recommended Posts

Hi!


So I've been trying to make some tweaks to a few of the mods I use. A lot of the things I want to do requires me to have one script access properties from another. I believed I found the way to do it, and I managed to get it working in one instance. However when I try to replicate it in another script, it simply fails to work as expected.

 


Below is the script that works:

 

Scriptname RDS_PlayerApproachScript extends Quest


<snip>


PAHCore Property PAH hidden
    PAHCore function Get()
        return Quest.GetQuest("PAH") as PAHCore
    endFunction
endProperty


<snip>


if !PAH.IsPAHSlave(thisNPC) ; NPS is not a PAH slave <--- This executes correctly

 

Scriptname PAHCore extends Quest Conditional


<snip>


Bool Function IsPAHSlave(Actor _actor)
    Int i = 0
    While i < slave_aliases.length
        If slave_aliases[i] && slave_aliases[i].GetActorRef() == _actor
            return true
        EndIf
        i += 1
    EndWhile
    return false
EndFunction

 

 

This, however, does not give the expected results:
 

Scriptname sla_SexlabPlugin Extends sla_PluginBase


<snip>


PlayerSuccubusQuestScript Property PSQ hidden
    PlayerSuccubusQuestScript function Get()
        return Quest.GetQuest("PSQ") as PlayerSuccubusQuestScript
    endFunction
endProperty


<snip>


float maxenergy = PSQ.GetMaxEnergy() ; <--- This returns 0, should be well above 100

 

Scriptname PlayerSuccubusQuestScript Extends Quest


<snip>


Float Property MaxEnergy Auto Hidden


<snip>


Float Function GetMaxEnergy()
    return MaxEnergy
EndFunction


I can't tell why the first code would work while the second wouldn't.

Any help would be appreciated.

Edited by hurtifrej
Link to comment

Ok so I just figured it out!
Going to post it here if anyone would happen to have a similar issue.

 

What I was doing wrong was the parameter for the SKSE function Quest.GetQuest()

In the examples I found when I searched for a way to access properties of another script, they always put the name of the property as the same string in the SKSE function, like so:

 

PlayerSuccubusQuestScript Property PSQ hidden
    PlayerSuccubusQuestScript function Get()
        return Quest.GetQuest("PSQ") as PlayerSuccubusQuestScript
    endFunction
endProperty

 

However, what I failed to realize was that the parameter had nothing to do with the name of the property; the two are completely separate. It just happens that every example I found put it as above. The correct way to do it is to send the quest name as the parameter, i.e. the quest which the script is attached to. In the case above the code SHOULD look like this:

PlayerSuccubusQuestScript Property PSQ hidden
    PlayerSuccubusQuestScript function Get()
        return Quest.GetQuest("PlayerSuccubusQuest") as PlayerSuccubusQuestScript
    endFunction
endProperty

 

In retrospect I should have understood this earlier but it just happened to be that the first script I tried this on, the PAHcore script, the property name and the quest name happened to be the same by coincidence. So, when I wrote "PAH" instead of "ParadiseHallsQuest" or anything that you might expect the actual quest to be named, the script worked and so I assumed that was how you were supposed to do it.

 

Yeah, I am a dumdum.

 

Anyway, I got it to work now. Hopefully this post might help some other poor sod who's also learning the basics of Papyrus.

Link to comment
  • hurtifrej changed the title to (SOLVED) Need some help with accessing properties from an external script

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more information, see our Privacy Policy & Terms of Use