Fredas Posted April 3, 2014 Posted April 3, 2014 This should be quick and easy. Let's say I'm trying to ping the property PlayerIsVampire from Skyrim's own PlayerVampireQuestScript. PlayerVampireQuest = Game.GetFormFromFile(0x000EAFD5, "Skyrim.esm") as PlayerVampireQuestScript debug.notification("PlayerIsVampire: " + PlayerVampireQuest.PlayerIsVampire) Compile result: "PlayerIsVampire is not a property on script form or one of its parents". Why is it lying to me? ;p I can see quite clearly that it is a property. What'd I mess up? (Please don't suggest making PlayerVampireQuest a property because there's a good reason why that's not an option in this case.)
Ashal Posted April 3, 2014 Posted April 3, 2014 PlayerVampireQuest needs to be defined as the script. Quest PlayerVampireQuest = Game.GetFormFromFile(0x000EAFD5, "Skyrim.esm") as PlayerVampireQuestScript Would make the variable a Quest variable, and thus only have access to the functions/properties of the Quest script and it's parents. Because PlayerVampireQuestScript extends the quest script, it seen as compatible and casting it as PlayerVampireQuestScript works, but it gets cast again down a level to match with the Quest type declaration. PlayerVampireQuestScript PlayerVampireQuest = Game.GetFormFromFile(0x000EAFD5, "Skyrim.esm") as PlayerVampireQuestScript Would make the variable a PlayerVampireQuestScript variable, and thus only have access to the functions/properties of the PlayerVampireQuestScript script and it's parents PlayerVampireQuestScript PlayerVampireQuest = Game.GetFormFromFile(0x000EAFD5, "Skyrim.esm") as PlayerVampireQuestScript debug.notification("PlayerIsVampire: " + PlayerVampireQuest.PlayerIsVampire) Compiles without issue.
Ashal Posted April 3, 2014 Posted April 3, 2014 Also if SKSE dependence isn't an issue for you, I'd suggest Quest.GetQuest() instead of Game.GetFormFromFile() It's a matter of preference, but it's a helluva lot easier and an applicable option in this scenario. PlayerVampireQuestScript PlayerVampireQuest = Quest.GetQuest("PlayerVampireQuest") as PlayerVampireQuestScript ; // Versus PlayerVampireQuestScript PlayerVampireQuest = Game.GetFormFromFile(0x000EAFD5, "Skyrim.esm") as PlayerVampireQuestScript
Fredas Posted April 4, 2014 Author Posted April 4, 2014 Also if SKSE dependence isn't an issue for you, I'd suggest Quest.GetQuest() instead of Game.GetFormFromFile() It's a matter of preference, but it's a helluva lot easier and an applicable option in this scenario. PlayerVampireQuestScript PlayerVampireQuest = Quest.GetQuest("PlayerVampireQuest") as PlayerVampireQuestScript ; // Versus PlayerVampireQuestScript PlayerVampireQuest = Game.GetFormFromFile(0x000EAFD5, "Skyrim.esm") as PlayerVampireQuestScript Thanks. It does compile and that's another hurdle cleared. I made the foolish assumption of expecting this functionality to operate universally, but it's proving not to be the case. What are the options when the script/properties in question are part of something that isn't a quest? In my current case, the script is attached to an activemagiceffect. Probably because of this, the above syntax doesn't happily compile. (Obviously the Quest.GetQuest is off the menu, so I'm referring to the Game.GetFormFromFile approach.)
Fredas Posted April 4, 2014 Author Posted April 4, 2014 Edit: If it helps or matters, here is an example of me trying to define a script variable from a script that's attached to a magic effect rather than a quest: rnd_checkneedsscript PM_CheckNeedsScript PM_CheckNeedsScript = Game.GetFormFromFile(0x0002E0C9, "RealisticNeedsandDiseases.esp") as rnd_checkneedsscript And the error returned is "cannot cast a form to a rnd_checkneedsscript, types are incompatible". Same methods as in the above vampire quest example; only difference is the script being attached to something besides a quest.
Fredas Posted April 4, 2014 Author Posted April 4, 2014 Gonna guess at this point that it's not possible, since I can't find a single working example anywhere.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.