Jump to content

[LE] [Papyrus] Compile Error


SevenBlue

Recommended Posts

Working on the same test as before and run into a new error that I can't seem to suss out.

 

Here's the script

Scriptname SB_AddictionTestScript extends activemagiceffect  

SPELL Property AltarTalosSpell  Auto  

Actor Property PlayerRef  Auto  

MagicEffect Property SB_TestEffect  Auto  


Event OnEffectFinish(Actor akTarget, Actor akCaster)

	AltarTalosSpell.cast(SB_TestEffect, playerRef)

	
	EndEvent 

and here's the error

SB_AddictionTestScript.psc(12,17): type mismatch on parameter 1 (did you forget a cast?)

any help or guidance will be much appreciated as always

Link to comment
Share on other sites

 

Who is PlayerRef? Shouldn't you be using akCaster/akTarget?

AltarTalosSpell.Cast(akCaster, akTarget)

 

PlayerRef is presumably the player, and is specified in the properties.

 

Working on the same test as before and run into a new error that I can't seem to suss out.

 

Here's the script

Scriptname SB_AddictionTestScript extends activemagiceffect  

SPELL Property AltarTalosSpell  Auto  

Actor Property PlayerRef  Auto  

MagicEffect Property SB_TestEffect  Auto  


Event OnEffectFinish(Actor akTarget, Actor akCaster)

	AltarTalosSpell.cast(SB_TestEffect, playerRef)

	
	EndEvent 

and here's the error

SB_AddictionTestScript.psc(12,17): type mismatch on parameter 1 (did you forget a cast?)

any help or guidance will be much appreciated as always

 

The Cast function only accepts two arguments, both of which are ObjectReferences: The source and the target. SB_TestEffect, being a magic effect, is an invalid argument: https://www.creationkit.com/index.php?title=Cast_-_Spell

 

What effects are to be applied is entirely specified by the spell the Cast function is being called on.

Edited by foamyesque
Link to comment
Share on other sites

PlayerRef is presumably the player, and is specified in the properties.

 

Sure, but a property isn't need for that. Also, the Cast() function is adequate enough to target the caster. So unless the property is an unrelated third party then it doesn't need to be used. At least that's how I'm understanding this.

Link to comment
Share on other sites

 

PlayerRef is presumably the player, and is specified in the properties.

 

Sure, but a property isn't need for that. Also, the Cast() function is adequate enough to target the caster. So unless the property is an unrelated third party then it doesn't need to be used. At least that's how I'm understanding this.

 

 

The caster of the spell that tries to call the cast function may not be the player, but the player might be meant to be either the source or the target of the second spell in all circumstances. Depends what SevenBlue is up to.

Link to comment
Share on other sites

Hey sorry for the delay in my response. Kapteyn was correct, changing the parameters (is that the right word?) to akCaster and akTarget got things working like a charm. Though I don't think I properly understand why it worked. If someone could walk me through that that would be peachy.

 

Also to satisfy curiosity, I was practicing using a scripted effect with potions. Specifically I was working on a withdrawal system for my skooma mod. With your help I now understand the principles well enough to introduce a addiction system I'm pretty happy with. So thank you both of you : )

Link to comment
Share on other sites

Hey sorry for the delay in my response. Kapteyn was correct, changing the parameters (is that the right word?) to akCaster and akTarget got things working like a charm. Though I don't think I properly understand why it worked. If someone could walk me through that that would be peachy.

 

foamyesque already explained why it did not work:

The Cast function only accepts two arguments, both of which are ObjectReferences: The source and the target. SB_TestEffect, being a magic effect, is an invalid argument: https://www.creationkit.com/index.php?title=Cast_-_Spell

 

 

Link to comment
Share on other sites

Okay, so you could technically use the PlayerRef property if you want to. The function will it accept because it's an actor, I expect it would still work. However, if PlayerRef is either the caster or the intended target then it's wholly unnecessary because you already have that information.

 

It depends on the spell itself. Most spells target either the caster (say you're healing yourself) or you're explicitly targetting somebody. You only need the property to be there if a third person is relevant. Let's say you drink a potion and you want it to heal a companion as well - in this case akTarget and akCaster are both the same thing because the magic effect targets the self, so you would indeed need a property reference for somebody else.

 

Don't take my word on all this because I'm still finding my way around the code as well, it's not what I'm used to.

Link to comment
Share on other sites

 

 

foamyesque already explained why it did not work:

 

 

Yup, you're totally right, that's my derp, sorry.

Okay, so you could technically use the PlayerRef property if you want to. The function will it accept because it's an actor, I expect it would still work. However, if PlayerRef is either the caster or the intended target then it's wholly unnecessary because you already have that information.

 

It depends on the spell itself. Most spells target either the caster (say you're healing yourself) or you're explicitly targetting somebody. You only need the property to be there if a third person is relevant. Let's say you drink a potion and you want it to heal a companion as well - in this case akTarget and akCaster are both the same thing because the magic effect targets the self, so you would indeed need a property reference for somebody else.

 

Don't take my word on all this because I'm still finding my way around the code as well, it's not what I'm used to.

 

Cool, that definitely makes logical sense, thank you!

Link to comment
Share on other sites

  • Recently Browsing   0 members

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