Jump to content

[Papyrus Need Help] a property cannot be used directly on a type


Akreontage

Recommended Posts

Hey all!

 

I am trying to do my very first mod for Skyrim, but since I am not a good programmer nor a good modder I have a problem with Papyrus.

So I am trying to create a mod for Skyrim Special Edition which will allow to see favorited gear on player (bDisableGearedUp; I do it because I can't stand seeing weapons appear from thin air, and also who else if not me...).

Right now I am at the very early stage of development and I am trying to make my idea work with only 2 weapons: Iron Sword and Long Bow.

 

Here is my script attached to Iron Sword:

Scriptname _newscript1 extends ObjectReference  

Form f1

Form property f1Prop
	Form function get()
		return f1
	endFunction
	function set(Form f2)
		f1 = f2
	endFunction
endProperty

Event OnInit()
	Utility.SetINIBool("bDisableGearedUp:General", False)
EndEvent

Event OnEquipped(Actor AkActor)
	f1 = Game.GetPlayer().GetEquippedWeapon(false)
	Game.GetPlayer().UnequipItem(Game.GetPlayer().GetEquippedWeapon(false))
	Game.GetPlayer().EquipItem(f1)
EndEvent

And here is the script attached to my Long Bow

Scriptname _newscript2 extends ObjectReference  

Form f1

Event OnEquipped(Actor AkActor)
	f1 = Game.GetPlayer().GetEquippedWeapon(false)
	Game.GetPlayer().UnequipItem(Game.GetPlayer().GetEquippedWeapon(false))
	Game.GetPlayer().UnequipItem(_newscript1.f1Prop)
        Game.GetPlayer().EquipItem(_newscript1.f1Prop)
	Game.GetPlayer().EquipItem(f1)
EndEvent

So the error I get looks like this : a property cannot be used directly on a type, it must be used on a variable

No output generated for _newscript2, compilation failed.
Which is obvious because I am trying to use property (_newscript1.f1Prop) from _newscript1.
The question is: how can I get Form property from external script (from _newscript2 in my case)?
And the other question is where should I create my script to make sure it is executed every time ANY weapon is sheathed and not only Iron Sword/Long bow.
Thanks for your time!
Link to comment
Share on other sites

To catch any weapon and work with any weapon that the player equips, you'll want to set up a quest and put the player on a reference alias. The script would be attached to said player alias. You'd use the OnObjectEquipped and OnObjectUnequipped events. Also by using a single script, you can use an array to store the current weapon from each of the weapon types that you want to display at the same time without trying to get individual scripts attached to individual weapons to communicate with each other.

 

Equipping is also different from sheathing. A weapon can be sheathed and still equipped. If you really need to track the draw/sheathe moments, you can use OnActorAction from SKSE.

Link to comment
Share on other sites

To catch any weapon and work with any weapon that the player equips, you'll want to set up a quest and put the player on a reference alias. The script would be attached to said player alias. You'd use the OnObjectEquipped and OnObjectUnequipped events. Also by using a single script, you can use an array to store the current weapon from each of the weapon types that you want to display at the same time without trying to get individual scripts attached to individual weapons to communicate with each other.

 

Equipping is also different from sheathing. A weapon can be sheathed and still equipped. If you really need to track the draw/sheathe moments, you can use OnActorAction from SKSE.

Thanks, that was very helpful!

 

Since there is no SKSE for Skyrim Special Edition I wonder if there is a way to disable Equipping/unequipping sounds and notifications when using EquipItem() and UnequipItem() functions? Or should I forget about it for now?

 

So after all those hours it seems to me that it is impossible to do without "Sheathe weapon" function/SKSE. : /

Edited by Akreontage
Link to comment
Share on other sites

I can't figure out what the heck you are trying to do in this script. Are you trying to find the weapon in the left hand, duplicate it with bDisableGearedUp:General enabled?

Why wouldn't you just do this from the console, or from the ini file? I read that the setting changed with the SSE edition:

 

...for anyone that's interested, now 1 is disabled and 0 is enabled, so proper setting is now bDisableGearedup=0
Edited by irswat
Link to comment
Share on other sites

I was trying to reequip previous weapon before equipping new weapon so that mesh could go to the right position... I managed to fix invisible weapon with this workaround but previous weapon is still visible (clipping and stuff) because it is being reequipped in drawn state. There is no such function in papyrus. : / Need to wait for SKSE.

Edited by Akreontage
Link to comment
Share on other sites

Regardless how useless your script would be, the point is the error message you got. "a property cannot be used directly on a type, it must be used on a variable"

 

Why, the reason behind that?

Scriptname _newscript2 extends ObjectReference  
Form f1

Event OnEquipped(Actor AkActor)
; ...
    Game.GetPlayer().UnequipItem(_newscript1.f1Prop)    ; script  "_newscript1" is unknown it needs an anchor like quest, objectReference, ..
; ...
EndEvent

I have rewritten both script to show you, how does it work without papyrus error! Keep in mind, I still have no idea what you want to do, inside!

 

script 2

 

Scriptname _newscript2 extends ObjectReference  
{rewritten by ReDragon 2016}

  ObjectReference PROPERTY weapon1 auto        ; fill with weapon which has attached the script "_newscript1"

; -- EVENT --

EVENT OnEquipped(Actor akActor)
IF (akActor == Game.GetPlayer())
ELSE
    RETURN    ; - STOP -    not the player, do nothing
ENDIF
;---------------------
    _newScript1 ps = weapon1 as _newscript1

IF ( ps )
    ; If true, will return the weapon equipped in the actors left hand.
    ; If false, will return the right-hand weapon instead.
    form fm = akActor.GetEquippedWeapon(False) as Form        ; right hand weapon (False)

    akActor.UnequipItem(fm)
    akActor.UnequipItem(ps.fm1)
    akActor.EquipItem(ps.fm1)
    akActor.EquipItem(fm)
ENDIF
ENDEVENT

 

 

script 1

 

Scriptname _newscript1 extends ObjectReference  
{rewritten by ReDragon 2016}

  Form PROPERTY fm1 auto Hidden                        ; do not fill this property by CK

; -- EVENTs -- 2

EVENT OnInit()
    Utility.SetINIBool("bDisableGearedUp:General", False)    ; not good !?
ENDEVENT

EVENT OnEquipped(Actor akActor)
IF (akActor == Game.GetPlayer())
ELSE
    RETURN    ; - STOP -    not the player, do nothing
ENDIF
;---------------------
    fm1 = akActor.GetEquippedWeapon(False) as Form    ; fill property on top
    akActor.UnequipItem(fm1)
    akActor.EquipItem(fm1)
ENDEVENT

 

 

 

Maybe it helps to understand papyrus scripting even more.

 

Thanks a lot!!! And kudos for answering the actual question! I love people who can answer questions even if they (questions) are really stupid like mine.

I just tried it and now I know how to access one script from the other script! That was really helpful!

 

.....................................

 

Since my idea of implementing proper geared up function failed I would like to hear your ideas on how to create something like that. I will work with any good idea I get.

Thanks!

Edited by Akreontage
Link to comment
Share on other sites

 

Have also a look at this mod: "Equipping Overhaul" by DragonDude1029

http://www.nexusmods.com/skyrim/mods/49784/?

 

Keep in mind the mod author is using SKSE script extender and wrote about some issues.

 

Yeah, this mod is exactly what I am trying to do (except realistic unequipping/lid torches features).

 

And yeah I figured out how to create Aliases using new quest, thanks.

 

I was looking DragonDude's source files and I have one more question now... How does one can additem to player?

In his source code all he does is he adds property "Armor property Shoes auto" and then adds Shoes to player like this: "GetActorRef().AddItem(Shoes, 1, true)"

 

I tried to do the same:

Armor property Shoes auto

Game.GetPlayer().AddItem(Shoes, 1, true)

 

I don't get any errors when compiling but I don't get Shoes in game either. What's the trick?

Edited by Akreontage
Link to comment
Share on other sites

You need to assign the desired object to the property via the properties window on the object that the script is attached to.

 

Highlight the script that you added to the object

press the properties button

use the interface that appears in the new window to fill the properties with your desired objects.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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