AngelDeath82 Posted February 23, 2017 Share Posted February 23, 2017 The goal of my mod script: a book with an OnRead script call which will both advance skill levels for certain skills, as well as add a few traits, but doing so based on matching the character's name. This will tie into a pair of PC presets I've built (and tested) based on the Nord Race. ScriptName _LearnStuff extends ObjectReference Actor Property pPlayerRef Auto Perk Property Regeneration Auto Perk Property Recovery30 Auto Perk Property Recovery50 Auto Perk Property MagicResistance30 Auto Perk Property MageArmor30 Auto Perk Property DestructionDualCasting Auto String SFTarget = akTarget.GetLeveledActorBase().GetName() ;Return character name based on https://forums.nexusmods.com/index.php?/topic/817658-player-name-capture/ ;Below commands are based on https://forums.nexusmods.com/index.php?/topic/2207184-add-player-perks-with-book-script/ Event OnRead() If (SFTarget == "CharName1") Game.AdvanceSkill("Sneak",5) Game.AdvanceSkill("Speechcraft",5) Game.AdvanceSkill("Alteration",5) Game.AdvanceSkill("Conjuration",5) Game.AdvanceSkill("Destruction",15) Game.AdvanceSkill("Restoration",10) Game.GetPlayer().AddPerk(Regeneration) Game.GetPlayer().AddPerk(Recovery30) Game.GetPlayer().AddPerk(Recovery50) Game.GetPlayer().AddPerk(MagicResistance30) Game.GetPlayer().AddPerk(MageArmor30) Game.GetPlayer().AddPerk(DestructionDualCasting) ElseIf (SFTarget == "CharName2") Game.AdvanceSkill("OneHanded",10) Game.AdvanceSkill("Marksman",15) Game.AdvanceSkill("Block",5) Game.AdvanceSkill("LightArmor",10) Game.AdvanceSkill("Sneak",10) Game.AdvanceSkill("Speechcraft",10) Game.GetPlayer().AddPerk(Regeneration) Game.GetPlayer().AddPerk(Recovery30) Game.GetPlayer().AddPerk(Recovery50) Game.GetPlayer().AddPerk(MagicResistance30) EndIf endEvent What I get when I attempt to compile the script using Creation Kit v1.9.32.0, however, is: Starting 1 compile threads for 1 files... Compiling "_LearnStuff"... E:\Steam\SteamApps\common\Skyrim\Data\Scripts\Source\_LearnStuff.psc(11,18): no viable alternative at input 'akTarget' E:\Steam\SteamApps\common\Skyrim\Data\Scripts\Source\_LearnStuff.psc(11,26): required (...)+ loop did not match anything at input '.' E:\Steam\SteamApps\common\Skyrim\Data\Scripts\Source\_LearnStuff.psc(11,7): Unknown user flag akTarget No output generated for _LearnStuff.psc, compilation failed. Batch compile of 1 files finished. 0 succeeded, 1 failed. Failed on _LearnStuff.psc I've also tried using pPlayerRef in place of akTarget on line 11, but to no avail.I've tried looking up the errors in question, but they presently have me stymied. Any assistance in helping to resolve this issue would be greatly appreciated. Thank you. Link to comment Share on other sites More sharing options...
IsharaMeradin Posted February 23, 2017 Share Posted February 23, 2017 You need to set the SFTarget string inside of an event. Assuming you want the player's name, your script slightly modified: ScriptName _LearnStuff extends ObjectReference Actor Property PlayerRef Auto Perk Property Regeneration Auto Perk Property Recovery30 Auto Perk Property Recovery50 Auto Perk Property MagicResistance30 Auto Perk Property MageArmor30 Auto Perk Property DestructionDualCasting Auto ;Below commands are based on https://forums.nexusmods.com/index.php?/topic/2207184-add-player-perks-with-book-script/ Event OnRead() SFTarget = PlayerRef.GetBaseObject().GetName() If (SFTarget == "CharName1") Game.AdvanceSkill("Sneak",5) Game.AdvanceSkill("Speechcraft",5) Game.AdvanceSkill("Alteration",5) Game.AdvanceSkill("Conjuration",5) Game.AdvanceSkill("Destruction",15) Game.AdvanceSkill("Restoration",10) PlayerRef.AddPerk(Regeneration) PlayerRef.AddPerk(Recovery30) PlayerRef.AddPerk(Recovery50) PlayerRef.AddPerk(MagicResistance30) PlayerRef.AddPerk(MageArmor30) PlayerRef.AddPerk(DestructionDualCasting) ElseIf (SFTarget == "CharName2") Game.AdvanceSkill("OneHanded",10) Game.AdvanceSkill("Marksman",15) Game.AdvanceSkill("Block",5) Game.AdvanceSkill("LightArmor",10) Game.AdvanceSkill("Sneak",10) Game.AdvanceSkill("Speechcraft",10) PlayerRef.AddPerk(Regeneration) PlayerRef.AddPerk(Recovery30) PlayerRef.AddPerk(Recovery50) PlayerRef.AddPerk(MagicResistance30) EndIf endEvent Link to comment Share on other sites More sharing options...
AngelDeath82 Posted February 24, 2017 Author Share Posted February 24, 2017 Thanks for the input. I've now gotten to where the script compiles, but I'm getting a crash to desktop upon reading the book. I've added: Debug.Trace("Character name = " + SFTarget,1) and updated my Skyrim.ini file to enable Papyrus logging, but I'm not getting any output from that Debug call in the logs. I've even tried removing the entire set of If statements from it to test, and still get a crash to desktop on reading it. Link to comment Share on other sites More sharing options...
IsharaMeradin Posted February 24, 2017 Share Posted February 24, 2017 If you take the script off the book, does it still crash? There is always the chance that there is a problem with the mesh and/or animation opening. Ensure that the book itself works before adding the script to it. Link to comment Share on other sites More sharing options...
AngelDeath82 Posted February 24, 2017 Author Share Posted February 24, 2017 (edited) Aha, no more crash to desktop. Note to self: if you need to clone a book, DO NOT clone the DummyBook... :sad: Edited February 24, 2017 by AngelDeath82 Link to comment Share on other sites More sharing options...
Recommended Posts