Jump to content

Trying to make my first script-would appreciate a little input


Recommended Posts

Im familiar with the CK website, that consistently has done alot more to discourage me, than provide help in learning...  a physical book, or actual web book called "python" or "c#" would be alot with a proper index where I could look something up and not see an empty "uh, idk what it is" space would be more useful.  So While I am looking for any help, I would appreciate it  if we could "Explain it like im 5".

 

I am using  the color red for anything that I think I am supposed to supply (variable names for example)  blue is what im 110% sure im lost on
Here is what I would like the script to do.

 

On equip specific items(armor, clothing, etc)  add perk to player. if not equippied, no perk

 

I lifted this as a provided demo script, 
 

SlilliusSword  et all = what the item is called in my editor ID.(tessedit)????

 

 

Is one small script like this okay, or should I basically do 1 item = 1 script?  (there wont be alot of scripting anyway)

 

 

Scriptname SilliusScript Extends ReferenceAlias

Weapon Property SIlliussword Auto

Event OnObjectEquipped(Form akBaseObject, ObjectReference reference)
  If (SIlliussword as Weapon) == true
    sillyperk1
 If (SIlliuscarmorhead as Weapon) == true
   sillyperk2 
If (SIlliuscArmorLeg as armor) == true
   sillyperk3
If (SIlliusAarmorSheild as armor) == true
   sillyperk4
If (SIlliuscArmoFeet as armor) == true
   sillyperk5

  EndIf
EndEvent
Link to comment

OnObjectEquipped is an event. Event based programing.

 

Its triggered whenever someting is equiped.

 

Event OnObjectEquipped(Form akBaseObject, ....

 

akBaseObject: thats what is being equipped. Its of type Form. Form is sort of base object for most things in Skyrim. Object oriented programing stuff.

 

A tipical example would be:

 

Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference)

    if akBaseObject as Weapon
        ...
    endIf

...

EndEvent

 

Part: "if akBaseObject as Weapon" reads as:

- cast akBaseObject into type Weapon

- if akBaseObject  actualy is of type Weapon, if condition will evaluate as 'true; or better to say "not none"

- if akBaseObject  is not of type Weapon, result is "none" (nil, null in other languages).

 

So good check is "if akBaseObject as Weapon". Nothing more is required. Thats because result of "akBaseObject as Weapon" is acutaly of type "Weapon" and not "bool".

 

To check if SIlliussword will be equipped, you could write a code:

 

Scriptname SilliusScript Extends ReferenceAlias

Weapon Property SIlliussword Auto

 

Event OnObjectEquipped(Form akBaseObject, ObjectReference reference)

  if SIlliussword == (akBaseObject as Weapon)

      ... do my stuff when SIlliussword is equipped

  endIf

EndEvent

 

Link to comment

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more information, see our Privacy Policy & Terms of Use