BlackShruikan Posted November 12, 2018 Share Posted November 12, 2018 I need to add or remove a perk any time I read the same book but it works only a once: Message Property ANV_LearnCraftingRecipesMessage Auto Message Property ANV_ChoiceForgetCraftingRecipesMessage Auto Message Property ANV_ForgetCraftingRecipesMessage Auto Perk Property CraftingPerk Auto Actor Property PlayerRef Auto Event OnRead() Utility.WaitMenuMode(1.0) If (!PlayerRef.HasPerk(CraftingPerk)) PlayerRef.AddPerk(CraftingPerk) ANV_LearnCraftingRecipesMessage.Show() Else int choice = ANV_ChoiceForgetCraftingRecipesMessage.Show() If (choice == 1) PlayerRef.RemovePerk(CraftingPerk) ANV_ForgetCraftingRecipesMessage.Show() EndIf EndIf EndEvent Any tips? Thank you. Link to comment Share on other sites More sharing options...
SeraphimKensai Posted November 13, 2018 Share Posted November 13, 2018 Does OnRead only work when the book hasn't been read ever? What about OnActivate or such? Would that trigger when you read a book? Link to comment Share on other sites More sharing options...
ReDragon2013 Posted November 13, 2018 Share Posted November 13, 2018 (edited) anvCraftingPerkScript Scriptname anvCraftingPerkScript extends ObjectReference ; https://forums.nexusmods.com/index.php?/topic/7148211-event-onread-multiple-times-on-a-book/ Perk PROPERTY CraftingPerk auto Bool bHasPerk ; [default=False] Message PROPERTY ANV_LearnCraftingRecipesMessage auto ; learn Message PROPERTY ANV_ForgetCraftingRecipesMessage auto ; forget Message PROPERTY ANV_ChoiceForgetCraftingRecipesMessage auto ; forget by choice ; -- EVENT -- EVENT OnRead() ; received when this object, if a book, is read, (we assume game mechanic only the player may read a book!) Utility.WaitMenuMode(1.0) IF ( bHasPerk ) myF_Action(False) ; remove, if choiced ELSE myF_Action(TRUE) ; add perk ENDIF ENDEVENT ; -- FUNCTION -- ;---------------------------- FUNCTION myF_Action(Bool bOK) ;---------------------------- IF ( bOK ) bHasPerk = TRUE Game.GetPlayer().AddPerk(CraftingPerk) ANV_LearnCraftingRecipesMessage.Show() ELSEIF (ANV_ChoiceForgetCraftingRecipesMessage.Show() == 1) ; make sure 1 is the right option, not 0 bHasPerk = False Game.GetPlayer().RemovePerk(CraftingPerk) ANV_ForgetCraftingRecipesMessage.Show() ENDIF ENDFUNCTION Edited November 13, 2018 by ReDragon2013 Link to comment Share on other sites More sharing options...
BlackShruikan Posted November 13, 2018 Author Share Posted November 13, 2018 Does OnRead only work when the book hasn't been read ever? What about OnActivate or such? Would that trigger when you read a book?I've tried both OnActivate and OnOpen. Doesn't work neither. Link to comment Share on other sites More sharing options...
BlackShruikan Posted November 13, 2018 Author Share Posted November 13, 2018 anvCraftingPerkScript Scriptname anvCraftingPerkScript extends ObjectReference ; https://forums.nexusmods.com/index.php?/topic/7148211-event-onread-multiple-times-on-a-book/ Perk PROPERTY CraftingPerk auto Bool bHasPerk ; [default=False] Message PROPERTY ANV_LearnCraftingRecipesMessage auto ; learn Message PROPERTY ANV_ForgetCraftingRecipesMessage auto ; forget Message PROPERTY ANV_ChoiceForgetCraftingRecipesMessage auto ; forget by choice ; -- EVENT -- EVENT OnRead() ; received when this object, if a book, is read, (we assume game mechanic only the player may read a book!) Utility.WaitMenuMode(1.0) IF ( bHasPerk ) myF_Action(False) ; remove, if choiced ELSE myF_Action(TRUE) ; add perk ENDIF ENDEVENT ; -- FUNCTION -- ;---------------------------- FUNCTION myF_Action(Bool bOK) ;---------------------------- IF ( bOK ) bHasPerk = TRUE Game.GetPlayer().AddPerk(CraftingPerk) ANV_LearnCraftingRecipesMessage.Show() ELSEIF (ANV_ChoiceForgetCraftingRecipesMessage.Show() == 1) ; make sure 1 is the right option, not 0 bHasPerk = False Game.GetPlayer().RemovePerk(CraftingPerk) ANV_ForgetCraftingRecipesMessage.Show() ENDIF ENDFUNCTION It worked! So PlayerRef.HasPerk(Perk) returns true even if the perk has been removed from the player? Link to comment Share on other sites More sharing options...
Recommended Posts