Jump to content

Help with activate function


Vylssius

Recommended Posts

I'm pretty new to modding and all that so I'm sorry if I am overlooking something blatantly obvious.

 

I am trying to make a mod where you have an aid item, and when you use it, it will open a container to store things in.

 

I have a script on a magic effect that is using the activate function on the player to open the container. Problem is I keep getting the error (Activate is not a function or does not exist)

 

I have tried a lot of things to fix this, but it seems like all the documentation I have found is incredibly vague. I assume I'm overlooking or missing something but I haven't been able to find anything on it. As far as the official creation kit wiki is concerned, I am using it exactly how it is meant to be used... so I don't understand why it isn't working.

 

Thank you in advance for your help!

 

 

 

[sOLVED]

Well I kind of feel stupid but at least I learned something.

For anyone else who might be having the same problem, you have to define your container as an ObjectReference instead of Container, because activate works on objectreference.

 

ObjectReference Property ContainerName auto const

NOT

Container Property ContainerName auto const

even though its a container you are activating...

Link to comment
Share on other sites

 

a magic effect that is using the activate function on the player

 

If you want to open the container then use activate on the container.

 

I have that, under the event OnEffectStart i have the line ContainerName.Activate(game.GetPlayer(), true) but im still getting the error :/

Link to comment
Share on other sites

container is a base object, the object reference is the object placed in the world, activate only works for references:

 

ObjectReference Property ContainerName Auto Const

 

And fill the property with the container from the render window.

Link to comment
Share on other sites

You're welcome.

 

A simple example that will help you to understand the way papyrus works:

 

Note that, in the wiki, each script function has its own script type (ObjectReference, Actor, Weapon, Armor, etc...), and Activate() is part of ObjectReference. If for example you wanted to use GetAmmo(), which is part of Weapon Script, you should use a Weapon Property, or infiere it from the object reference, you can get the base object from a reference using GetBaseObject(), this returns a Form, which is a base object with an undefined type of script (it is a basic script type tho, which has some basic functions that all child objects can use), to convert this base object to a Weapon script you need to cast it using AS, once it is a weapon script you can call GetAmmo on it, and that's how you travers over the different types of scripts from object reference, which is the most commonly used since every object in the world are object references:

Ammo MyWeaponAmmo = (WeaponReference.GetBaseObject() As Weapon).GetAmmo()
Link to comment
Share on other sites

 

You're welcome.

 

A simple example that will help you to understand the way papyrus works:

 

Note that, in the wiki, each script function has its own script type (ObjectReference, Actor, Weapon, Armor, etc...), and Activate() is part of ObjectReference. If for example you wanted to use GetAmmo(), which is part of Weapon Script, you should use a Weapon Property, or infiere it from the object reference, you can get the base object from a reference using GetBaseObject(), this returns a Form, which is a base object with an undefined type of script (it is a basic script type tho, which has some basic functions that all child objects can use), to convert this base object to a Weapon script you need to cast it using AS, once it is a weapon script you can call GetAmmo on it, and that's how you travers over the different types of scripts from object reference, which is the most commonly used since every object in the world are object references:

Ammo MyWeaponAmmo = (WeaponReference.GetBaseObject() As Weapon).GetAmmo()

That is some very useful information! Thank you for clarifying, I wish this information was more widely available, seems like a lot of information around papyrus is a secret lol

I wish I knew people who were into this stuff so I wouldn't have to make so many forum posts when I need help, but I am not very good at making friends :/

Link to comment
Share on other sites

  • Recently Browsing   0 members

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