AddPerk Script Help

Post » Tue Oct 22, 2013 1:51 am

I've made some changes to the Smithing perk tree and need to make sure the player has the first perk in the tree if/when they do the blacksmithing tutorial. I've managed to make the tutorial give the player the necessary perk if they don't have it.

Game.GetPlayer().AddPerk(SimpleCrafting)
SimpleCraftingAdded.Show()
but I'd like to be able to give the player a replacement perk point in the event they've already spent a perk point on this perk. The following is the script I'm trying to use but it's giving me errors still.
l133 ;give player needed perk or replacement point
l132 if Game.GetPlayer().HasPerk(SimpleCrafting) == 1
l133 then Game.AddPerkPoints(1)
l134 SimpleCraftingAlready.Show()
l135 else Game.GetPlayer().AddPerk(SimpleCrafting)
l136 SimpleCraftingAdded.Show()
l137 endif

I get an error at lines 133 and 135. The errors are pasted below.

Starting 1 compile threads for 1 files...
Compiling "QF_TutorialBlacksmithing_00105385"...
C:\Steam\ . . . \QF_TutorialBlacksmithing_00105385.psc(169,14): required (...)+ loop did not match anything at input '.'
C:\Steam\. . . \QF_TutorialBlacksmithing_00105385.psc(171,10): required (...)+ loop did not match anything at input 'Game'
No output generated for QF_TutorialBlacksmithing_00105385, compilation failed.
Batch compile of 1 files finished. 0 succeeded, 1 failed.
Failed on QF_TutorialBlacksmithing_00105385

Here's where I got the AddPerkPoints information:

http://www.creationkit.com/AddPerkPoints_-_Game

User avatar
Sarah Bishop
 
Posts: 3387
Joined: Wed Oct 04, 2006 9:59 pm

Post » Tue Oct 22, 2013 6:29 am

The If syntax is wrong;

l133   ;give player needed perk or replacement pointl132   if Game.GetPlayer().HasPerk(SimpleCrafting) == 1l133        Game.AddPerkPoints(1)l134        SimpleCraftingAlready.Show()l135   elsel136         Game.GetPlayer().AddPerk(SimpleCrafting)l137         SimpleCraftingAdded.Show()l138   endif

And a small suggested optimization:

l132   Actor Player = Game.GetPlayer()l133   ;give player needed perk or replacement pointl132   if Player.HasPerk(SimpleCrafting) == 1l133        Game.AddPerkPoints(1)l134        SimpleCraftingAlready.Show()l135   elsel136         Player.AddPerk(SimpleCrafting)l137         SimpleCraftingAdded.Show()l138   endif

Because Game.GetPlayer() takes processing time and there's no reason to use it more than once in a single script.

User avatar
Georgine Lee
 
Posts: 3353
Joined: Wed Oct 04, 2006 11:50 am

Post » Tue Oct 22, 2013 7:49 am

Ah, I see. I should really go through the tutorials again but I've done them in the past and it's hard to get through them a second time when you remember most of it still.

Thanks for the help! It compiled successfully without errors, I'll have to wait until later to see if it runs correctly in-game.

User avatar
josie treuberg
 
Posts: 3572
Joined: Wed Feb 07, 2007 7:56 am

Post » Mon Oct 21, 2013 7:30 pm

You had a Then you didn't need.

Anything after If "this or that", is assumed to be Then "do this" by the script "brain", unless it meets an Else.

User avatar
Benjamin Holz
 
Posts: 3408
Joined: Fri Oct 19, 2007 9:34 pm


Return to V - Skyrim