Jump to content

Help with basic scripting?


dianacat777

Recommended Posts

Okay, so I've gotten pretty good at manipulating New Vegas's construction set. Huh. Why don't I try my hand at skyrim modding? It can't be that diff - OHAI PAPYRUS.

 

Yeah. I do not understand. I try, but even copying by example is not working for me. And at least New Vegas would tell me when I had a script that didn't work...

 

So. I'll eventually get my footing (or give up), but for now, I can't understand what's going on and I'd really appreciate some pointers. What I'm trying to do is a basic script that, when an item is equipped, adds a spell and a perk. When taken off, it removes the spell and perk.

 

 

Scriptname AlexJacketScript extends ObjectReference

 

Perk Property AlexJacketPerk Auto

 

{Event OnEquipped(Actor akActor)

if akActor == Game.GetPlayer()

Debug.Notification("This is working")

Game.GetPlayer().Addperk(AlexJacketPerk)

Game.GetPlayer().Addspell(AlexSpell)

else

Debug.Notification("This is not working")

endif

EndEvent

 

Event onUnequipped(Actor akActor)

if akActor == Game.GetPlayer()

Game.GetPlayer().Removeperk(AlexJacketPerk)

Game.GetPlayer().Removespell(AlexSpell)

endif

EndEvent}

 

 

 

Neither debug plays for me, and nothing happens. :U Am very confuse.

 

Also, what program do you need to create visual spell effects, the glowy stuff?

Edited by dianacat777
Link to comment
Share on other sites

Just for fun...

 

try this out

 

Scriptname AlexJacketScript extends ObjectReference

Import Game
Import Debug
Import Utility

Perk Property AlexJacketPerk Auto
Spell Property AlexSpell Auto

Event OnEquipped(Actor Ishara)
     Actor Player = GetPlayer()
     If Ishara == Player
        AddTheStuff()
     else
         String NoWork = "This is not working"
         Return Notification(NoWork)
     EndIf
EndEvent

Function AddTheStuff()
     Actor Player = GetPlayer()
     String ItWorks = "This is working"
     Return Notification(ItWorks)
     Player.Addperk(AlexJacketPerk)
     Player.Addspell(AlexSpell)
EndFunction

Event OnUnequipped(Actor Ishara)
     Actor Player = GetPlayer()
     If Ishara == Player
        RemoveTheStuff()
     endif
EndEvent

Function RemoveTheStuff()
     Actor Player = GetPlayer()
     Player.Removeperk(AlexJacketPerk)
     Player.Removespell(AlexSpell)
EndFunction

make sure you set your properties for the spell & the perk within the object that you place the script. If this works, come back and let me know.

Link to comment
Share on other sites

As stupid as this sounds... can you rewrite that script to reference a generic player instead of your specific one? Like I said, I'm horribly confused by papyrus, and I can't accurately tell which parts of that script are redundant, or should have 'player' where you put your name, or nothing at all.

 

But thank you.

Link to comment
Share on other sites

I just replaced akActor with Ishara because I had trouble getting a script to work that had the default akWhatever (where whatever was whatever was put there by default in the wiki), but when it was replaced by something else the script did its job...

 

it doesn't reference my character. its just a variable name. I could have used WhoeverEquippedThis instead

 

this Actor Player = GetPlayer() is what gets the player

and then

this If Ishara == Player compares the player value with the actor who equipped the object

 

as far as redundancy,

 

I've found that some things only work inside functions thus I moved the AddSpell, AddPerk, RemoveSpell, and RemovePerk actions into functions. That's the big thing that I wanted to see if would make the difference for you.

 

Unfortunately you can't define Player as I have as a property. I've tried, it won't compile. so in this case it has to be defined in each function or event it is used in unless you want to do GetPlayer() all the time. You could even drop Import Game if you were inclined to write Game.GetPlayer() in every instance. Its a habit I got into cause sometimes there can be lots of entries needing Game.GetPlayer() and if one line can significantly reduce my typing... But now that I've got a few scripts that I understand at my disposal, I tend to copy paste as needed :P

 

I broke the notification up, because that's how I learned to do it and that I know works. Plus it gives the ability to define the strings up with the properties and use them multiple times in different events/functions

Link to comment
Share on other sites

Oh, thanks for clearing that up. I'll try it.

 

Edit: Still no dice. No notifications or anything (and I do have debug enabled); it's just like there's no script attached to the item.

 

Actually, I wonder if I have debug enabled in the wrong location. Hmm. Retry.

 

Edit 2: Sweet failure yet again. Gah. This is even worse than when I was trying to figure out how to make an animation play without it getting immediately overriden, before I learned how to jury-rig timers.

Edited by dianacat777
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...