[Papyrus] Condition functions syntax ?

Post » Mon Jun 18, 2012 7:08 am

Hi,

I dont understand how to use http://www.creationkit.com/Category:Condition_Functions T.T

For ex, I try to do something (via a quest script) if the player is swimming. Voilà my little script :
Scriptname 00MyQuest extends QuestEvent OnInit()  RegisterForUpdate(5)EndEventEvent OnUpdate()  If Game.GetPlayer().IsSwimming == 1	;Do something  EndifEndEvent
Papyrus error messages :
(...)(8,34): IsSwimming is not a property on script actor or one of its parents(...)(8,45): cannot compare a none to a int (cast missing or types unrelated)

Any idea ?
Ty very much in advance !
User avatar
loste juliana
 
Posts: 3417
Joined: Sun Mar 18, 2007 7:37 pm

Post » Sun Jun 17, 2012 8:18 pm

I would guess you are just missing brackets on the function call:

If Game.GetPlayer().IsSwimming() == 1

Note that "condition functions" are just a sub-category of all scripting functions that are available to use when editing conditions found in a few types of records. When used in scripts they aren't different than any other function.
User avatar
N Only WhiTe girl
 
Posts: 3353
Joined: Mon Oct 30, 2006 2:30 pm

Post » Sun Jun 17, 2012 11:26 pm

Thanks Dave !

See you.

Edit : in fact some condition functions seems to work, but many dont :
;For ex :game.getplayer().IsRunning()	 ; worksgame.getplayer().IsSwimming()   ; doesnt  :(
User avatar
lucy chadwick
 
Posts: 3412
Joined: Mon Jul 10, 2006 2:43 am

Post » Mon Jun 18, 2012 7:40 am

Hi,

Another syntax problem...

Can't figure how to usehttp://www.creationkit.com/IsSpellTarget (again a http://www.creationkit.com/Category:Condition_Functions, and a really useful one to say the least).

Syntaxes I've tried :
If game.getplayer().IsSpellTarget() MySpell == FalseIf game.getplayer().IsSpellTarget().MySpell == FalseIf MySpell.IsSpellTarget() game.getplayer() == FalseIf MySpell.IsSpellTarget().game.getplayer() == FalseIf MySpell.IsSpellTarget(game.getplayer()) == FalseIf game.getplayer().IsSpellTarget(MySpell) == FalseIf IsSpellTarget(game.getplayer() MySpell) == FalseIf IsSpellTarget(MySpell game.getplayer()) == FalseIf IsSpellTarget(game.getplayer(), MySpell) == FalseIf IsSpellTarget(MySpell, game.getplayer()) == False

I receive various error messages in function of the different syntaxes.
Ofc my spell property is declared : I'm using this spell in the same script with the cast function and it's working.

The wiki really need some practical syntax examples T.T

Any idea ?
Thanks.
User avatar
.X chantelle .x Smith
 
Posts: 3399
Joined: Thu Jun 15, 2006 6:25 pm

Post » Sun Jun 17, 2012 9:25 pm

It looks like IsSpellTarget() is supposed to be used in the following manner according to the docs and function data

Enchantment Property Enchant01 Auto            ;Spell, potion or enchantmentObjectReference Property TargetRef01 Auto   ;Referenceif ObjectReferecnce.IsSpellTarget(Enchant01)if Game.GetPlayer().IsSpellTarget(Enchant01)

However these fail to compile with a "is not a function" type error Trying to define it as native doesn't work either (though I'm unsure of the exact function definition). Searching through all existing scripts and this function is actually never used. If you can find a script that does something similar to what you want to do you can try to figure out how they did it as an alternative.
...
User avatar
Bitter End
 
Posts: 3418
Joined: Fri Sep 08, 2006 11:40 am

Post » Mon Jun 18, 2012 2:00 am

In fact, condition function are different from regular functions. Condition functions can be used for conditions (quest, dialogue, etc.) in the CK and not all of them have a Papyrus equivalent. There is no IsSpellTarget in Papyrus.

Maybe you can use http://www.creationkit.com/HasMagicEffectWithKeyword_-_Actor or http://www.creationkit.com/HasMagicEffect_-_Actor.
User avatar
Betsy Humpledink
 
Posts: 3443
Joined: Wed Jun 28, 2006 11:56 am

Post » Sun Jun 17, 2012 6:37 pm

Many thanks Dave and Qazaaq.
Will try HasMagicEffect and give some feedback tomorrow !
User avatar
Naazhe Perezz
 
Posts: 3393
Joined: Sat Aug 19, 2006 6:14 am

Post » Mon Jun 18, 2012 2:58 am

Bump !

So until now I found a couple of condition functions that arent working in a Papyrus script, for ex :
-> IsSpellTarget : possible to replace it with HasMagicEffect
-> IsSwimming : possible to detect if an actor is swimming by casting a spell on an actor, and switching a custom GlobalVariable through a scripted MagicEffect (global is switched by OnInit and OnEffectFinish Events). Magic Effect which is switched to active(will check Oninit)/inactive(will check OnEffectFinish) when the actor is swimming or not (with a condition sets to IsSwimming == 0/1 in the spell tab only (when adding the magicEffect to the spell. But no condition in the Magic Effect tab))... A really tedious way, but it's working.
-> IsMoving : no solution yet, but will try to do the same thing than IsSwimming.

All seems to be possible by using Magic Effects, but I'm still suprised that some major condition functions are not originally usable in Payrus scripts...
I'm still wondering if it coudnt be a syntax problem (?)
User avatar
Adriana Lenzo
 
Posts: 3446
Joined: Tue Apr 03, 2007 1:32 am

Post » Mon Jun 18, 2012 8:40 am

This is driving me crazy. I've run into this very problem while working the hypothermia mod. How is there no IsSwimming() function? It just seems crazy to me. I'm trying to use the magic effect method, but I guess it's good to know I'm not just an idiot. I hope it's a syntax problem. There doesn't seem to be anything on the wiki about it.
User avatar
Andrew Lang
 
Posts: 3489
Joined: Thu Oct 11, 2007 8:50 pm

Post » Mon Jun 18, 2012 5:49 am

I hope it's a syntax problem. There doesn't seem to be anything on the wiki about it.
It's not a syntax problem. Papyrus and the condition/console functions are completely separate. Maybe you can use a condition to trigger something that you can monitor from a Papyrus script, but you won't be able to use those functions (until SKSE of course).
User avatar
Bereket Fekadu
 
Posts: 3421
Joined: Thu Jul 12, 2007 10:41 pm

Post » Mon Jun 18, 2012 3:16 am

How is there no IsSwimming() function?

IsSwimming is a console command and condition function for magic effects and perks.
User avatar
TASTY TRACY
 
Posts: 3282
Joined: Thu Jun 22, 2006 7:11 pm


Return to V - Skyrim