Create custom "Condition Function"

Post » Tue Jun 19, 2012 7:24 am

Hi, i'm trying to add a custom function in the "Condition Function" list. I'm talking about the list u can scroll when adding a condition to, for example, a recipe (like HasPerk, isThis, isThat...).
I tryed to create and compile a script like this
Scriptname _RepConditions Conditionalbool Function hasRightWeap () globalif (game.getplayer() as _PlayerExt).arma != none  return trueelse  return falseendifendfunction
hoping "hasRightWeap" to appear in the list, but i had no success. Maybe i misunderstood the meaning of conditional flag :)
User avatar
Mrs Pooh
 
Posts: 3340
Joined: Wed Oct 24, 2007 7:30 pm

Post » Tue Jun 19, 2012 8:18 pm

bump :)
User avatar
jessica breen
 
Posts: 3524
Joined: Thu Aug 03, 2006 1:04 am

Post » Tue Jun 19, 2012 7:51 am

Hi, i'm trying to add a custom function in the "Condition Function" list. I'm talking about the list u can scroll when adding a condition to, for example, a recipe (like HasPerk, isThis, isThat...).
I tryed to create and compile a script like this
Scriptname _RepConditions Conditionalbool Function hasRightWeap () globalif (game.getplayer() as _PlayerExt).arma != none  return trueelse  return falseendifendfunction
hoping "hasRightWeap" to appear in the list, but i had no success. Maybe i misunderstood the meaning of conditional flag :smile:
I dont know if is possible to make a conditional function, but certainly it can be done with property.
Scriptname TestConditional Conditional  Int Property  TestCond = 1 Auto Conditionalbool Function hasRightWeap () globalendfunction

Add this script for example to an NPC.
Now in package Tab condition select function GetVmScriptVariable Target Reference ID the NPC with the conditional script, in variable you should see your conditional property to check (in the above example, TestCond).
User avatar
Kari Depp
 
Posts: 3427
Joined: Wed Aug 23, 2006 3:19 pm

Post » Tue Jun 19, 2012 8:19 am

The way I read it your script would appear as "_RepConditions" in the list.
User avatar
Lynette Wilson
 
Posts: 3424
Joined: Fri Jul 14, 2006 4:20 pm

Post » Tue Jun 19, 2012 1:37 pm

I dont know if is possible to make a conditional function, but certainly it can be done with property.
Scriptname TestConditional Conditional  Int Property  TestCond = 1 Auto Conditionalbool Function hasRightWeap () globalendfunction

Add this script for example to an NPC.
Now in package Tab condition select function GetVmScriptVariable Target Reference ID the NPC with the conditional script, in variable you should see your conditional property to check (in the above example, TestCond).

Wow! Yeah, i think that will work. With the function (without "global" flag i think) i'll update the property, that i can get by GetVmScriptVariable. Just a little tricky, but we are talking about bethesda :D


The way I read it your script would appear as "_RepConditions" in the list.
So you are telling me that it is possible?
But if i put the Condition Function name on the script title, where i write the logic and the values to return?
User avatar
Destinyscharm
 
Posts: 3404
Joined: Sun Jul 23, 2006 6:06 pm

Post » Tue Jun 19, 2012 2:26 pm

"Conditional" is a flag, recognised by the Creation Kit and ignored by the compiler, and there are no flags that are valid for use on functions.

The "conditional" flag can be used on properties, but only "auto" properties, so you can't use a custom "get" function for a property to do what you want. The closest thing you could do is use an auto property or a variable with the "conditional" flag, and set it whenever it needs to be set.

See http://www.creationkit.com/Flag_Reference for more information on flags.

Also, it looks like you've attached a script directly to the player reference. Don't do that - use a http://www.creationkit.com/ReferenceAlias_Script instead.

Cipscis
User avatar
Elina
 
Posts: 3411
Joined: Wed Jun 21, 2006 10:09 pm

Post » Tue Jun 19, 2012 6:17 am

Thanks, the Property with conditional flag works well with "GetVmScriptVariable" ;)

Also, it looks like you've attached a script directly to the player reference. Don't do that - use a http://www.creationkit.com/ReferenceAlias_Script instead.

Cipscis

Yes, i did that because i'm not sure how to use RefAlias. Tell me if this is right:
1- I create a quest (duplicate, if i create a quest CK crashes on "ok") with a ReferenceAlias (with an assigned script "_PlayerExt") on the Player Reference.
2- I assure that the quest start and run, since the game is loaded (i failed here, and decided for Assigning the script on the player Reference
3- When i've to use something on the _playerExt, how can i reach that, instead of "game.getplayer() as _playerExt"?

What are the side effects of attaching a script to the player ref? It will not work, or just compatibility issue with any other mod that changes player ref?
User avatar
Lizbeth Ruiz
 
Posts: 3358
Joined: Fri Aug 24, 2007 1:35 pm

Post » Tue Jun 19, 2012 6:57 pm

That method sounds right, although I don't have the Creation Kit with me at the moment to try it out myself.

In order to access the http://www.creationkit.com/ReferenceAlias_Script, you'll need to call http://www.creationkit.com/GetAlias_-_Quest on your http://www.creationkit.com/Quest_Script.

You can use http://www.creationkit.com/GetActorReference_-_ReferenceAlias as a general way of getting the http://www.creationkit.com/Actor_Script at which your alias is pointing, although if it'll always be the player then you don't need to use that method.

The side effects are compatibility issues and, more importantly, that scripts are not removed from objects when a mod is uninstalled. If you add a script to the player, it will remain attached when your mod is uninstalled, but if you use an alias then the alias is removed with the mod and everything should be just fine.

Cipscis
User avatar
Kate Schofield
 
Posts: 3556
Joined: Mon Sep 18, 2006 11:58 am

Post » Tue Jun 19, 2012 9:09 am

That method sounds right, although I don t have the Creation Kit with me at the moment to try it out myself.

In order to access the ReferenceAlias, you ll need to call GetAlias on your Quest.

You can use GetActorReference as a general way of getting the Actor at which your alias is pointing, although if it ll always be the player then you don t need to use that method.

Yeah, i didn't tought to that. I can still use game.getplayer() because the script is still attached to the player ref. It's just a different (read "correct" :D) way to attach it :)

The side effects are compatibility issues and, more importantly, that scripts are not removed from objects when a mod is uninstalled. If you add a script to the player, it will remain attached when your mod is uninstalled, but if you use an alias then the alias is removed with the mod and everything should be just fine.

My intention (for now) is to create a total overhaul, modifing a lot of thing, adding features like "item durability" (what i'm working on now). So it is intended for a fresh started game with low campatibility with other mods. I think i did worst, changing OnHit() in "Actor" script :D
User avatar
Skivs
 
Posts: 3550
Joined: Sat Dec 01, 2007 10:06 pm


Return to V - Skyrim