I know "Self" will not work, so is there any way to

Post » Thu Jun 21, 2012 1:06 pm

The following script is on a 7 different tokens (armor with no slots nor weight)

Scriptname aadpFeintTokenScript extends ObjectReferenceEvent OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer) actor me = akNewContainer as actor Utility.wait(me.getactorvalue("block")) Me.removeitem(Self, 1, true)endevent

Now I am sure that SELF will not work as it refers to the script and not the token.
Is there any way to get the token dynamically so that I do not need to make 7 different scripts?
User avatar
BlackaneseB
 
Posts: 3431
Joined: Sat Sep 23, 2006 1:21 am

Post » Thu Jun 21, 2012 2:54 pm

first have you tested to make sure the removeitem wont trigger the containerchanged block again?

if aknewcontainer returns "none" after the item is removed i think it will cause a papyrus log error, especially when it tries to cast a none as actor and retrieve the none's actor value (doesnt exist). you might need to run aknewcontainer against getplayer() so that the code wont run otherwise



if self doesnt work as you have it there, you can try

form token = self.getbaseobject()

me.removeitem(token)
User avatar
David Chambers
 
Posts: 3333
Joined: Fri May 18, 2007 4:30 am

Post » Thu Jun 21, 2012 3:29 pm

This will not only be on the player, but I guess I could throw in a check for any actor.

So you think SELF might work or you just do not know any other way to do this?

Self it defiantly getting the script, not the token.

Thanks for the heads up on the possible issue about removing the token.

first have you tested to make sure the removeitem wont trigger the containerchanged block again?

if aknewcontainer returns "none" after the item is removed i think it will cause a papyrus log error, especially when it tries to cast a none as actor and retrieve the none's actor value (doesnt exist). you might need to run aknewcontainer against getplayer() so that the code wont run otherwise

if self doesnt work as you have it there, you can try

form token = self.getbaseobject()

me.removeitem(token)
User avatar
Kevan Olson
 
Posts: 3402
Joined: Tue Oct 16, 2007 1:09 am

Post » Thu Jun 21, 2012 3:47 am

Perhaps...
ScriptName aadpFeintTokenScript extends ObjectReferenceEvent OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)	Utility.Wait((akNewContainer As Actor).GetActorValue("Block"))	akNewContainer.RemoveItem(GetBaseObject(), 1, True)EndEvent
...or...
ScriptName aadpFeintTokenScript extends ObjectReferenceArmor Property WhateverThisIs AutoEvent OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)	Utility.Wait((akNewContainer As Actor).GetActorValue("Block"))	akNewContainer.RemoveItem(WhateverThisIs, 1, True)EndEvent
GetBaseObject() is kinda flimsy depending on context, but worst case scenario is you make a generic property and point it accordingly to the owning token. Hopefully the first variant works w/ no property.
User avatar
Mashystar
 
Posts: 3460
Joined: Mon Jul 16, 2007 6:35 am

Post » Thu Jun 21, 2012 9:35 am

er....I do not understand, how would this avoid making many different scripts?
If I did that I would need to make one for each token.

Did you skip my OP? :sad:

Armor Property WhateverThisIs Auto

Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)
Utility.Wait((akNewContainer As Actor).GetActorValue("Block"))
akNewContainer.RemoveItem(WhateverThisIs, 1, True)
EndEvent[/code]GetBaseObject() is kinda flimsy depending on context, but worst case scenario is you make a generic property and point it accordingly to the owning token. Hopefully the first variant works w/ no property.
User avatar
STEVI INQUE
 
Posts: 3441
Joined: Thu Nov 02, 2006 8:19 pm

Post » Thu Jun 21, 2012 3:26 pm

Yeah, I read the OP... A single script can be made to behave differently according to where its properties are pointed. With the same script attached to all seven tokens, you can just point the WhateverThisIs property to the token the script instance is attached to, killing all seven birds with the same stone (if GetBaseObject() is flaky).



User avatar
james tait
 
Posts: 3385
Joined: Fri Jun 22, 2007 6:26 pm

Post » Thu Jun 21, 2012 6:01 pm

Yeah, I read the OP... A single script can be made to behave differently according to where its properties are pointed. With the same script attached to all seven tokens, you can just point the WhateverThisIs property to the token the script instance is attached to, killing all seven birds with the same stone (if GetBaseObject() is flaky).

mmmmm...wow really?

but I do not see how this does what you are saying
where is "WhateverThisIs" getting set to the token the script is on?

edit:

OHHHHH!!! right in the properties! :facepalm:

I will need to set each one and not use the AUTO set, but that is no big deal to do.... wow how could I have missed that. THANKS!

I need to get some sleep maybe.
User avatar
kelly thomson
 
Posts: 3380
Joined: Thu Jun 22, 2006 12:18 pm

Post » Thu Jun 21, 2012 2:20 am

where is "WhateverThisIs" getting set to the token the script is on?
In each token's script's properties window. With a multipurpose property like that, it won't auto-fill, but you can manually point properties ...wherever.

NP :) One of the coolest things about Papyrus, IMO, is the capacity for a single script to pull off multiple tasks like that.
User avatar
Queen
 
Posts: 3480
Joined: Fri Dec 29, 2006 1:00 pm

Post » Thu Jun 21, 2012 6:04 pm

yeah, I will not admit it if you tell anyone, but I am starting to warm up to this new scripting language. The only thing that makes me still desire oblivion scripting is the script lag.


In each token's script's properties window. With a multipurpose property like that, it won't auto-fill, but you can manually point properties ...wherever.

NP :smile: One of the coolest things about Papyrus, IMO, is the capacity for a single script to pull off multiple tasks like that.
User avatar
lucile davignon
 
Posts: 3375
Joined: Thu Mar 22, 2007 10:40 pm

Post » Thu Jun 21, 2012 10:15 am

Was kinda foreboding at first, but Papyrus has grown on me too. :) It's a lot more ...malleable than Legacy/ObScript.
User avatar
Jake Easom
 
Posts: 3424
Joined: Sun Jul 29, 2007 4:33 am


Return to V - Skyrim