Jump to content

Photo

Papyrus Equip Item Script Help

papyrus creation kit script

  • Please log in to reply
20 replies to this topic

#1
IronDusk33

IronDusk33

    Maniacal Script Dragon

  • Supporter
  • PipPipPipPip
  • 1,422 posts

Hello, I'm trying to make a script for an armor item, where when the item is added to the player's inventory, its automatically equipped, and can't be unequipped. I attached this script to the armor. This is what I came up with:

----------------------------------------------------------------------------------------------------

Scriptname IronHookEquipScript extends ObjectReference  
 
Actor Property PlayerREF Auto
 
Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)
     If akNewContainer == PlayerREF
           Game.GetPlayer() .EquipItem (IronHook, true, true)
 
    EndIf
 
EndEvent

-----------------------------------------------------------------------------------------------

However, being absolutely clueless with scripting, when I attempted to save, this error popped up:

-----------------------------------------------------------------------------------------------

Starting 1 compile threads for 1 files...
Compiling "IronHookEquipScript"...
C:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\temp\IronHookEquipScript.psc(7,31): variable IronHook is undefined
No output generated for IronHookEquipScript, compilation failed.
 
Batch compile of 1 files finished. 0 succeeded, 1 failed.
Failed on IronHookEquipScript
--------------------------------------------------------------------------------------------------
I have no idea of what is going on, or if I have anything right. Please Help!

Edited by IronDusk33, 04 November 2013 - 10:33 PM.


#2
csirgli

csirgli

    Stranger

  • Members
  • Pip
  • 4 posts

Hi,

 

I'm not really familliar with papyrus (just started to look it at yestarday), but an ide which can be useful.

 

The below message is saying the IronHook is unknown.

-

 

 

 

 

When a console command player.additem used, the item number (FormID) has to be used. Like 000DB5D2 which is the crafting material "leather". Do you know the item number for "Iron Hook" ?
 



#3
IsharaMeradin

IsharaMeradin

    The Pale Redguard

  • Members
  • PipPipPipPipPip
  • 8,978 posts

You need to declare a property variable for your armor piece.

 

The modified script is as follows

Scriptname IronHookEquipScript extends ObjectReference  
 
Actor Property PlayerREF Auto
Armor Property IronHook Auto
 
Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)
     If akNewContainer == PlayerREF
           PlayerREF.EquipItem(IronHook, true, true)
    EndIf
EndEvent

Be sure to fill your properties after you compile your script else it won't do anything.

 

However, since this script is on the object itself...  There is one trick you can do which will remove the need for that property.

Scriptname IronHookEquipScript extends ObjectReference  
 
Actor Property PlayerREF Auto
 
Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)
     If akNewContainer == PlayerREF
           PlayerREF.EquipItem(Self, true, true)
    EndIf
EndEvent

You can use Self to refer to the object running the script.  Provided that object is a CK object or placed reference.  Aliases on quests can't use Self directly, they need to get their reference.  But I'm getting ahead of what you need to know.



#4
IronDusk33

IronDusk33

    Maniacal Script Dragon

  • Supporter
  • PipPipPipPip
  • 1,422 posts

Thanks! I did some tweaking and was able to get the item to auto-equip. I had to make a property for the Iron Hook, the Self trick didn't work for some reason.

 

There is one more problem though. I can't unequip the hook, but I can drop it. Is there some trick to keep the character from dropping the hook, and possibly keep it from getting removed from my character when he is taken to jail?



#5
IsharaMeradin

IsharaMeradin

    The Pale Redguard

  • Members
  • PipPipPipPipPip
  • 8,978 posts

I haven't tested this...  and I'm not too sure on my handling of what happens when it is dropped.  But it is at least worth a test.

 

This script would go on the player alias on a dummy quest that is running start game enabled (note the quest doesn't have to be start game enabled if the hook is being given and maintained as part of another quest.  So long as whatever quest has the player alias is going to run constantly for the life of the hook)

 

Spoiler

 

If it works, this script would also make the script on the object obsolete and unnecessary.



#6
IronDusk33

IronDusk33

    Maniacal Script Dragon

  • Supporter
  • PipPipPipPip
  • 1,422 posts

Thanks for the info, but when I tried putting this onto an alias, it gave an error saying Disable isn't a command.

 

I think simply putting an alias onto the Iron Hook, and checking the quest item box should work. One problem, I'm not entirely sure how to make a constant running dummy quest. What I did was made a new quest, made it a miscellaneous quest, made sure Start Game Enabled was checked, unchecked Run Once, and checked Allow Repeated Stages. I made one stage (stage 0). I made an alias to the Iron Hook, checked Quest Item, and did Ctrl Shift R to make it allow reserved. I also made an  alias to the player, and tried (and failed) to put your script on it. After I did all this, I loaded the game, and could still drop the hook. Could you clear any of this up?



#7
IsharaMeradin

IsharaMeradin

    The Pale Redguard

  • Members
  • PipPipPipPipPip
  • 8,978 posts

See the section called  Set Up A Reference Alias

http://www.creationk...Reference_Alias

 

You could do what you suggested by making the hook itself an alias and having it treated as a quest item.  You'd still need to use the original on item script (or on the new reference alias) to force the equip and keep the player from unequipping.



#8
IronDusk33

IronDusk33

    Maniacal Script Dragon

  • Supporter
  • PipPipPipPip
  • 1,422 posts

WHOOOO! Got it to work! Thanks for the help! For anyone else who finds this post in hope of doing something similar; I created the dummy quest I mentioned above, and then the forced player reference linked above, then I made another reference "Create Reference to Object" checked "In" and selected my other alias . I also checked the "Quest Object" box in the alias, obviously. Now I can play a hook-handed character! (Don't ask why)



#9
dubird

dubird

    Regular

  • Members
  • PipPip
  • 65 posts

Ok, I have yet to get this to work.  Made a dummy quest with player alias, as described above.  Made an object reference to the item, linking it to playeralias.  The item appears in inventory when I start, but is not equipped, nor is it unequipable.  I'm not sure what I'm doing wrong.  Did I miss a step somewhere?   I don't know if this is connected, but it will not compile with Extends anything.  Tried typing it in Notepad++, regular Notepad, it keeps saying it can't find that script.  When I try to do the New Script from CK, it gives me an error that it can't find that script.  I'm new to scripting, so I'm sure it's something minor, but yeah, kinda lost here.

 

Script I'm using (attaching to player alias)

Spoiler


#10
IsharaMeradin

IsharaMeradin

    The Pale Redguard

  • Members
  • PipPipPipPipPip
  • 8,978 posts
Two things.

One the script if attached to the player alias on a quest needs to extend ReferenceAlias. You may need to manually type that in.

Second your events and functions are all inside the comment brackets. { } remove those and the script should compile provided everything else is correct.





Also tagged with one or more of these keywords: papyrus, creation kit, script

Page loaded in: 1.176 seconds