Adding Perk On Reading a book

Post » Thu Jun 21, 2012 6:49 am

Ok, so i have set up a book and a Perk. And I have set up an armor set that needs this perk to be smithed and tempered.

I want the player to get the perk on reading the book. So this is what I came up with but it is not working. Anybody able to help?

Scriptname OA01AddPerk extends ObjectReference  Perk Property OASmithing AutoBook Property OAQ01DunmerLore  Auto  Event OnRead(OAQ01DunmerLore)    if (Game.GetPlayer().HasPerk(OASmithing) != 1)        Game.GetPlayer().AddPerk OASmithing    endIfendEvent
User avatar
Daniel Brown
 
Posts: 3463
Joined: Fri May 04, 2007 11:21 am

Post » Thu Jun 21, 2012 2:37 am

Event OnRead() shouldn't have any parameters. http://www.creationkit.com/OnRead_-_ObjectReference


HasPerk returns a boolean. Not exactly sure how papyrus works but your line looks a bit wrong to me. You should be checking vs a boolean value such as true/false if nothing else, then for readability. Another common way to phrase it in programming would be

if !(Game.GetPlayer().HasPerk(0ASmithing))
.....
endIf

AddPerk line doesn't have paranthesis around 0ASmithing. Correct line would be Game.GetPlayer().AddPerk(0ASmithing)
User avatar
Jerry Cox
 
Posts: 3409
Joined: Wed Oct 10, 2007 1:21 pm

Post » Thu Jun 21, 2012 3:35 pm

ah, ok. Well, i know practically zero about coding so thats where all the problem really lies.

But your sugestions worked.

Thanks for the help
User avatar
Naomi Lastname
 
Posts: 3390
Joined: Mon Sep 25, 2006 9:21 am


Return to V - Skyrim