nexusMods3 Posted July 19, 2014 Share Posted July 19, 2014 I have a script attached to a player, and a script attached to a quest. How can I make the script attached to the quest access a variable/function on the script attached to the player? I've been trying to do that for hours now and I just can't. If someone can give me a detailed explanation, I would appreciate very much. I made a mod, the mod is done, but I want to make it compatible with MCM. The config option the user would be able to tweak is the letter to activate the mod. So I'm using the OnOptionKeyMapChange to do that, but on that event, I want to have access to the variable/function in the script attached to the player. The quest has the player as an alias, if that helps. Thank you. Link to comment Share on other sites More sharing options...
Xander9009 Posted July 19, 2014 Share Posted July 19, 2014 (edited) I explained this once before in great detail, but unfortunately I can't find that post. This assumes the player's script is named PlayerScript and that it is attached to an alias named PlayerAlias on the same quest.Scriptname PlayerScript extends ReferenceAlias Float Function GetSomeInformation() Return GetActorRef().GetAV("Health") EndFunctionScriptname QuestScript extends Quest ReferenceAlias Property PlayerAlias Auto Event OnInit() Debug.Notification((PlayerAlias as PlayerScript).GetSomeInformation()) EndEventThe thing to note is that you have to cast the property or variable containing the alias reference as the script name with the function. This will make the functions and variables available for use because it forced the variable to extend the script. See, when you use "GetRef as Actor", "Actor" is literally just a script, and you're doing the exact same thing, except the script you're extending in your case is a custom one.EDIT: I managed to find it. http://forums.nexusmods.com/index.php?/topic/1264015-a-question-answered-completing-a-quest-objective-when-player-levels-up-and-other-scripts/?p=10575817 It's not much better than what I already posted, but it does have a small explanation. Edited July 20, 2014 by Xander9009 Link to comment Share on other sites More sharing options...
nexusMods3 Posted July 20, 2014 Author Share Posted July 20, 2014 Thanks for the reply. Good to know there is another way. After reading in the creation kit website: "A Property is essentially a variable that other scripts can access", I realized I could just create a property of the script type that had the functions and variables I wanted to use...and it worked lol :p Link to comment Share on other sites More sharing options...
Recommended Posts