Jump to content

[LE] if statement isn't working?


juffatoot

Recommended Posts

Hi,

I'm trying to create a spell that is dependent on the player's location:

Scriptname ChangeRealmEffectScript extends activemagiceffect

ObjectReference property WintTeleDest auto
ObjectReference property ArtTeleDest auto

Event OnEffectFinish(Actor Target, Actor Caster)
	Target.GetCurrentLocation()
		if (Target.IsInLocation(TamrielLocation))
			Target.MoveTo(WintTeleDest)
		else
			Target.MoveTo(ArtTeleDest)
		endif
endEvent 

After compiling, the only problem is that it says TamrielLocation (or any other location, for that matter) is not a defined variable.

 

Does anyone know why this is and what I should do to fix it?

Thank you :smile:

Edited by juffatoot
Link to comment
Share on other sites

Scriptname ChangeRealmEffectScript extends activemagiceffect
 
Location property TamrielLocation auto
ObjectReference property WintTeleDest auto
ObjectReference property ArtTeleDest auto
 
Event OnEffectFinnish(Actor Target, Actor Caster)
    Location CurrentLoc = Target.GetCurrentLocation()
    
    If CurrentLoc != none
        If CurrentLoc.isChild(TamrielLocation) || CurrentLoc == TamrielLocation
            Target.MoveTo(WintTeleDest)
        Else
            Target.MoveTo(ArtTeleDest)
        Endif
    Else
        return
    Endif
EndEvent

I think I eliminated two function calls(IsInLocation and the extra GetCurrentLocation it'll call for the assignment) and because GetCurrentLocation() expects a location to have a location, if you don't explicitly check for this, it'll return none and post a error to the log if the Cell does not have a location. I added a check to prevent such an error. Many wilderness cells do not have a location.

 

*Not tested.

Edited by Rasikko
Link to comment
Share on other sites

Hi,

I'm trying to create a spell that is dependent on the player's location:

Scriptname ChangeRealmEffectScript extends activemagiceffect

ObjectReference property WintTeleDest auto
ObjectReference property ArtTeleDest auto

Event OnEffectFinish(Actor Target, Actor Caster)
	Target.GetCurrentLocation()
		if (Target.IsInLocation(TamrielLocation))
			Target.MoveTo(WintTeleDest)
		else
			Target.MoveTo(ArtTeleDest)
		endif
endEvent 

After compiling, the only problem is that it says TamrielLocation (or any other location, for that matter) is not a defined variable.

 

Does anyone know why this is and what I should do to fix it?

Thank you :smile:

 

It's because you didn't define it. You can't simply type a form's name into the papyrus compiler and have it understand what you mean to do. Information like that is passed in through the properties system, which hooks Papyrus variables with the game forms. You can see how to use them in Rasikko's script, but after you compile it you'll need to go to the 'properties' button beside the script window and fill them.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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