Jump to content

Function to get the reference a script is attached to?


Asterra

Recommended Posts

With the script attached to apple ... apple would be the implicit reference.

Therefore you need not return apple. But if need it "GetSelf"

 

 

Add edit : Ahh the ninja post explains my post delay.

I see we think alike GamerRick ...

Link to comment
Share on other sites

You need explain why you need apple returned ... cuz most likely using it willy nilly won't give you what you want. And there may be a better way to get what you want ... if you explain it.

 

No worries ... I only steal everyother mod idea I help with.

And the last one was about a quick draw bonus.

Link to comment
Share on other sites

 

It probably would help to explain that the script belongs to an effect which is then attached, via AddNewEffect, to the Apple.

 

Script is as follows:

scn IPromiseThisIsAnApple

ref rRef

begin ScriptEffectStart
  let rRef := this
  if rRef == Apple
    PrintC "Working as intended."
  elseif rRef == player
    PrintC "Where exactly is 'player' even coming from here?"
  endif
end

Mktavish: The reason I need to be able to dynamically ascertain the object being eaten is twofold. 1: I intend to put the same script on multiple things, but the result needs to be different -- based on which thing was eaten. 2: This can't be (entirely) done with, say, an OnAidItem event, because said event only works with the refs you hand it (list or otherwise), and I need to be able to account for refs outside of the mod (from other mods), which cannot be added to lists (it gives errors and sulks).

 

(For that matter, anyone know of an event I can use for universally capturing the use of expendable items? OnActorEquip does not work in this capacity, even though it apparently will work as such when used as a block attached to the actor...)

 

Obviously I can get this done if I make one effect+sctipt each for every result I need, but that could amount to dozens. Not what I'm looking to do.

Edited by Asterra
Link to comment
Share on other sites

 

 

It probably would help to explain that the script belongs to an effect which is then attached, via AddNewEffect, to the Apple.

 

So then "HasMagicEffect" or "IsSpellTarget" ??? (read the differences on those)

Ya effects are not a reference themselves ... therefore they cannot be an implicit reference.

And of course getself if it worked for that ... would return the object ID of the base effect ... since that is what the script would be attatched to. An object or Actor effect is still not a reference even though it uses a base effect. And in actuality ... are a secondary delivery means , with other functionality / data storage.

Hence 2 pieces for 1 product.

 

 

Script is as follows:

scn IPromiseThisIsAnApple

ref rRef

begin ScriptEffectStart  ; you need "ScriptEffectUpdate" here
  let rRef := this
  if rRef == Apple
    PrintC "Working as intended."
  elseif rRef == player
    PrintC "Where exactly is 'player' even coming from here?"
  endif
end

I'm not sure what you are trying to do with that script , but "ScriptEffectStart" is a 1 frame read. So you cannot set rRef and compare rRef in 1 frame

 

Mktavish: The reason I need to be able to dynamically ascertain the object being eaten is twofold. 1: I intend to put the same script on multiple things, but the result needs to be different -- based on which thing was eaten.

Would help in understanding if you gave us an example .

 

2: This can't be (entirely) done with, say, an OnAidItem event, because said event only works with the refs you hand it (list or otherwise), and I need to be able to account for refs outside of the mod (from other mods), which cannot be added to lists (it gives errors and sulks).

 

You meant OnAddItem ? Which yes it needs more frames to register if you are not running a continuous block.

 

(For that matter, anyone know of an event I can use for universally capturing the use of expendable items?

 

You have to be more specific in what you imagine the engine is doing ... cuz it is possible what you are thinking may be possible , just not necessarily how you thought it could get done.

So explain it with an A to B to C kinda thing in your minds eye.

 

 

OnActorEquip does not work in this capacity, even though it apparently will work as such when used as a block attached to the actor...)

 

Obviously I can get this done if I make one effect+sctipt each for every result I need, but that could amount to dozens. Not what I'm looking to do.

 

And that very well might be the best method , wouldn't be the first time.

But ya some more explaining can help ferret out the possibilities :wink:

 

Link to comment
Share on other sites

 

 

So then "HasMagicEffect" or "IsSpellTarget" ??? (read the differences on those)

 

 

Fine if I'm polling every frame, but I'm obviously trying to do this only when it specifically matters. Though I'm starting to suspect I won't have that option.

 

I'm not sure what you are trying to do with that script , but "ScriptEffectStart" is a 1 frame read. So you cannot set rRef and compare rRef in 1 frame

 

Not sure where you got that idea. I've already done exactly that in other mods, without issue. This exact scenario, in fact -- script attached to effect attached to expendable.

 

 

You meant OnAddItem ?

 

SetOnUseAidItemEventHandler. It demands references; you can't leave the entry blank in the hope that it captures all such events.

 

So explain it with an A to B to C kinda thing in your minds eye.

 

I can only further elaborate. I need to capture the use of expendables when they happen, and, upon said capture, dynamically ascertain just exactly what was used. This needs to be accomplished for expendables found in external mods. I can attach an effect to those items, but the script affixed to said effect allows for no means of understanding what was just eaten. The only solutions to this conundrum I have seem to be:

 

1: Monitor, frame-by-frame, the player's inventory for any changes in the count of every relevant item.

2: Attach individually-created effects to each relevant item, so there is no guesswork about what was just eaten.

 

The first option allows me to avoid creating 50 different effects and scripts, and the second option affords me the elegance of not having to do massive polling on the player's inventory, which might need to be done even during gamemode. An event that triggers when using an expendable (without having to specify what to look for) would have kept me from having to ask for ways to get this done.

Link to comment
Share on other sites

An event that triggers when using an expendable (without having to specify what to look for) would have kept me from having to ask for ways to get this done.

 

But what fun would that be in figuring it out ??? nada thats for sure ... lol

 

That is the key though , needing to create an event you can log for some delineation.

Hmmmm I'm gona give it some thought , can't promise anything though , then get back tomorrow with or without some answers.

 

So is this strictly just "Ingestibles" or are there other items ?

But as I see it , you just need the result your looking for , albeit dynamic based on the input. Not really the ID of what was consumed ?

 

Care to share that , incase it helps the round about way to get there ?

But I understand if you have intellectual property concerns.

Link to comment
Share on other sites

But as I see it , you just need the result your looking for , albeit dynamic based on the input. Not really the ID of what was consumed ?

 

Care to share that , incase it helps the round about way to get there ?

 

The ID is needed, or, in a pinch, the $name. It's because even though the various ingestibles have other qualities that differentiate themselves (magnitude of satiation, for example), none of those in themselves guarantee the identification of the item used because the values are too shared across various usable items in various mods.

 

Honestly though, I've decided to go the multiple effect route. I think I was dumb not doing that in the first place. Not like it's the end of the world if the available functions don't quite manage to fit the bill, and certainly isn't the first time.

Link to comment
Share on other sites

 

Honestly though, I've decided to go the multiple effect route. I think I was dumb not doing that in the first place. Not like it's the end of the world if the available functions don't quite manage to fit the bill, and certainly isn't the first time.

 

 

I'm glad you went for that too. cuz i wasn;t comming back with nothin.

 

for your mods health ,

Link to comment
Share on other sites

  • Recently Browsing   0 members

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