Quick Questions, Quick Answers, The 3'rd

Post » Thu Jun 21, 2012 2:55 am

Is there a "this" keyword in Papyrus that directly references the object a script is attached to?

There's a "self" keyword.
User avatar
Laura Ellaby
 
Posts: 3355
Joined: Sun Jul 02, 2006 9:59 am

Post » Wed Jun 20, 2012 11:17 am

There's a "self" keyword.
I tried it on an ObjectReference script, and it doesn't work.
User avatar
Emmanuel Morales
 
Posts: 3433
Joined: Sat Oct 06, 2007 2:03 pm

Post » Wed Jun 20, 2012 9:35 pm

It should work just fine... what does the script look like? You could just post the relevant line.
User avatar
Manny(BAKE)
 
Posts: 3407
Joined: Thu Oct 25, 2007 9:14 am

Post » Wed Jun 20, 2012 1:24 pm

This is an actual script:
Event OnInit()   if Game.GetPlayer().IsEquipped(self)	  Game.GetPlayer().EquipItem(NewArmor,false,true)      Game.GetPlayer().RemoveItem(self,1,true)      Game.GetPlayer().AddItem(self,1,true)   endif   GotoState("Initialized")EndEvent

In case you spilled your coffee for seeing this again, yes, this is the same script I posted in another thread. I tried to use "self", but it just won't work, so I created a property named "this" and fill it with a reference to the armor I attached the script to.

The script extends ObjectReference

I attached this script to ArmorImperialStuddedCuirass

On a side note, if I attach a script to a base armor, do armors that use said base armor as template have the script attached too?
User avatar
john page
 
Posts: 3401
Joined: Thu May 31, 2007 10:52 pm

Post » Wed Jun 20, 2012 8:05 pm

Regarding your side note, I think so. Or at least that's how actors and actor templates work.

As for your script, I have no idea why it's not working for you. It does absolutely nothing?
User avatar
JR Cash
 
Posts: 3441
Joined: Tue Oct 02, 2007 12:59 pm

Post » Wed Jun 20, 2012 4:17 pm

Regarding your side note, I think so. Or at least that's how actors and actor templates work.

As for your script, I have no idea why it's not working for you. It does absolutely nothing?
Awesome.

To be fair, I haven't used Debug.Trace in it, but considering that if I use "this" it fires 17 times, I'd say it doesn't work, yes.
User avatar
Erin S
 
Posts: 3416
Joined: Sat Jul 29, 2006 2:06 pm

Post » Wed Jun 20, 2012 5:58 pm

I guess maybe the wiki is wrong or the articles are incomplete and you can't actually use the item reference itself in those functions. Does it work properly when you change your script to this:

Event OnInit()	if Game.GetPlayer().IsEquipped(self.GetBaseObject())		Game.GetPlayer().EquipItem(NewArmor,false,true)		Game.GetPlayer().RemoveItem(self.GetBaseObject(),1,true)		Game.GetPlayer().AddItem(self.GetBaseObject(),1,true)	endif	GotoState("Initialized")EndEvent

?
User avatar
Claudz
 
Posts: 3484
Joined: Thu Sep 07, 2006 5:33 am

Post » Thu Jun 21, 2012 12:14 am

Say I have a message box with three buttons, A, B, and C. I write a script to show the message and return 0, 1, or 2 depending on what is pressed. If I add a condition to A and B so that if the player has perk X they dont show, and the player does in fact have this perk when the menu comes up so they can only press C, what is returned in my script?

Is it "2" or is it "0"?


Please god tell me it is 2, and I just messed up somewhere in my script.
User avatar
Jamie Moysey
 
Posts: 3452
Joined: Sun May 13, 2007 6:31 am

Post » Thu Jun 21, 2012 12:16 am

It is 2.
User avatar
Ray
 
Posts: 3472
Joined: Tue Aug 07, 2007 10:17 am

Post » Thu Jun 21, 2012 12:49 am

Interesting. Perhaps someone could help me understand why this is not working?

Spoiler

PMreturn = MessageA.Show(Points)If (PMreturn == 0 || 1 || 2 || 3 || 4 || 5)   Game.GetPlayer().AddPerk(AListOfPerks.GetAt(PMreturn) as Perk)   RefundPoints.SetValue(Points - 1)   Show = FalseElseIf PMreturn == 6   Show = falseEndIf

To clarify, that is a snippet of the bit that isnt working. i have tons of bits like this, it is a three stage menu, first stage has 6 buttons, 5 of which lead to separate menus, each with 5 buttons, 4 of those buttons then leading to more menus with 7 buttons.

These final menus are the ones where the actual choice is made to add a perk, but I do not want the player to be adding perks that they could not get normally through leveling up, so I add conditions to each button for each perk so the button doesn't show up if the player doesn't have the prerequisites for that particular perk.

This is the part that is not working. When I press "cancel" which is button 6 in the menu, it sets show to false (exiting the while loop) but it also sets the globalvariable refundpoints! Even though only one or two of the first 6 buttons (0-5) is showing, why is button seven, the cancel button, running that bit of code that should only run if buttons 0-5 are pressed?


Show is the bool to maintain the while loop.
AListOfPerks is a formlist with perks in the same order as the buttons on the menu so that they correspond with each other.
Refundpoints is a global variable to keep track of how many refund points you have left after each time you select a perk. (shouldnt use a point if you hit cancel)
User avatar
Hazel Sian ogden
 
Posts: 3425
Joined: Tue Jul 04, 2006 7:10 am

Post » Thu Jun 21, 2012 2:22 am

If (PMreturn == 0 || 1 || 2 || 3 || 4 || 5) 

should be

if (PMReturn < 6)

or if you want to keep the same format

If (PMreturn == 0 || PMreturn == 1 || PMreturn == 2 || PMreturn == 3 || PMreturn == 4 || PMreturn == 5) 

otherwise the script will keep on hitting that

 if (... || 1 || ...)

which will always return true.
User avatar
Baby K(:
 
Posts: 3395
Joined: Thu Nov 09, 2006 9:07 pm

Post » Thu Jun 21, 2012 12:05 am

Thanks, that worked perfectly!

New question. I am trying to get an:

Event OnStorySkillIncrease()

to fire every time I skill up. So I made a quest, set its event to skill increase, added my script, then I went into the SM Event Node section of the object window. Then I duplicated the Skill Increase event node, and stuck my quest in there.

However, it seems this quest does not fire when I skill up, because it is not doing what I want it to do. Any information about SM Event nodes? how am I supposed to be using them to fire up my quest, how do I make it so the quest will fire up the code in that event every time I skill up and not just the first time? How to I avoid conflicts with other mods using the same event node?
User avatar
DAVId Bryant
 
Posts: 3366
Joined: Wed Nov 14, 2007 11:41 pm

Post » Wed Jun 20, 2012 10:11 pm

I have a follow-up question on something I asked previously:

In the Story Manager, when the Player Remove Item event is triggered, do you know what RemoveType 7 is? In the CK wiki, it's listed as "REMOVE_TYPE_COUNT." I have no idea what this means.
Reference:
http://www.creationkit.com/Player_Remove_Item
User avatar
pinar
 
Posts: 3453
Joined: Thu Apr 19, 2007 1:35 pm

Post » Wed Jun 20, 2012 4:32 pm

Thanks, that worked perfectly!

New question. I am trying to get an:

Event OnStorySkillIncrease()

to fire every time I skill up. So I made a quest, set its event to skill increase, added my script, then I went into the SM Event Node section of the object window. Then I duplicated the Skill Increase event node, and stuck my quest in there.

However, it seems this quest does not fire when I skill up, because it is not doing what I want it to do. Any information about SM Event nodes? how am I supposed to be using them to fire up my quest, how do I make it so the quest will fire up the code in that event every time I skill up and not just the first time? How to I avoid conflicts with other mods using the same event node?

Took a long time for me to figure this out. So here you go :biggrin:

Go into the SM EventNode.
DO NOT DUPLICATE Skill Increase. Delete your duplicate.
Open the existing Skill Increase.
Right Click on Stacked Event Node
Select New Quest Node
Enter your unique ID name.
Check Shares Event.
You can leave the other options unchecked.
Right Click on the Quest Node that was just added (Which should now show your ID)
Select Add Quest
Select your quest from the dialog box.
Click OK.

Open your quest script.
You should have:

Event OnStoryIncreaseSkill(string asSkill)

If asSkill == "Alchemy" (or whatever)
;do stuff
EndIf

Stop() <<<< Important: without this, it appears the script will only fire once regardless of the number of skill increases.
EndEvent


If you want to cover simultaneous skillups, you need to add multiple quests by copying the added quest or actually adding additional quests if you have/need them.
User avatar
Soraya Davy
 
Posts: 3377
Joined: Sat Aug 05, 2006 10:53 pm

Post » Wed Jun 20, 2012 2:11 pm

This is the trouble
If (PMreturn == 0 || 1 || 2 || 3 || 4 || 5)
That will always be true, as '1' is true. What you mean is...
If (PMreturn == 0 || PMreturn == 1 || PMreturn == 2 || etc. )
or just...
if (PMreturn == -1)  ; Show failed.ElseIf (PMreturn < 6)  ; 0 to 5

Edit: Doh. didn't see there was another page.
User avatar
Claire Lynham
 
Posts: 3432
Joined: Mon Feb 12, 2007 9:42 am

Post » Wed Jun 20, 2012 4:44 pm

Took a long time for me to figure this out. So here you go :biggrin:

Go into the SM EventNode.
DO NOT DUPLICATE Skill Increase. Delete your duplicate.
Open the existing Skill Increase.
Right Click on Stacked Event Node
Select New Quest Node
Enter your unique ID name.
Check Shares Event.
You can leave the other options unchecked.
Right Click on the Quest Node that was just added (Which should now show your ID)
Select Add Quest
Select your quest from the dialog box.
Click OK.

Open your quest script.
You should have:

Event OnStoryIncreaseSkill(string asSkill)

If asSkill == "Alchemy" (or whatever)
;do stuff
EndIf

Stop() <<<< Important: without this, it appears the script will only fire once regardless of the number of skill increases.
EndEvent


If you want to cover simultaneous skillups, you need to add multiple quests by copying the added quest or actually adding additional quests if you have/need them.

Thanks! Only question though, will that conflict with other mods that also add quests to the Skill Increase Story Manager Event Node, even though I added a separate new Quest Node within it?

I mean, If I do exactly as you say, and then install another mod that does the same thing, will only one of the two mods (whichever is loaded last) have their quest started by this story manager event?

Rapidly coming up with questions here, you guys are a tremendous help. I swear, it feels like they could have an entire curriculum surrounding this creation kit. Anyways, next question: What is the easiest way to detect, inside of a script, if another separate ESP file is loaded? I was thinking, in my first ESP file, I would have a Global Variable set as "constant" with value 1, then just have it is a property in a quest script in my second ESP and get the value. I am assuming it would return "none" if the variable did not exist, meaning the first ESP is not installed, and would return 1 if it was. Unless there is a better way or perhaps there is some problem with that method?
User avatar
Robyn Howlett
 
Posts: 3332
Joined: Wed Aug 23, 2006 9:01 pm

Post » Wed Jun 20, 2012 8:39 pm

Thanks! Only question though, will that conflict with other mods that also add quests to the Skill Increase Story Manager Event Node, even though I added a separate new Quest Node within it?

I mean, If I do exactly as you say, and then install another mod that does the same thing, will only one of the two mods (whichever is loaded last) have their quest started by this story manager event?

Rapidly coming up with questions here, you guys are a tremendous help. I swear, it feels like they could have an entire curriculum surrounding this creation kit. Anyways, next question: What is the easiest way to detect, inside of a script, if another separate ESP file is loaded? I was thinking, in my first ESP file, I would have a Global Variable set as "constant" with value 1, then just have it is a property in a quest script in my second ESP and get the value. I am assuming it would return "none" if the variable did not exist, meaning the first ESP is not installed, and would return 1 if it was. Unless there is a better way or perhaps there is some problem with that method?

Yep. Until Wrye Bash can see all the records and merge them when necessary, the rule of last mod loaded would apply.
I tried several diferent methods to get the story manager to work with a duplicate skill increase, but never could.

As to the second, I'm not entirely sure, but I beleive you cannot detect another mod loaded from within your mod. This is going to be a SKSE function at some point.
User avatar
carley moss
 
Posts: 3331
Joined: Tue Jun 20, 2006 5:05 pm

Post » Wed Jun 20, 2012 2:26 pm

How do I rename a quest fragment script? It's driving me crazy!

I click on the advanced tab for script fragments in the quest stages tab and rename the script there. But when I check the script tab of the quest, it's still using the old script. If I make changes to the script fragments, the changes are not reflected in the old script, but the new script.

I try to remove the old script from the quest, but each time I open up the quest, the script is still there. I want to add in the new renamed script, but it isn't one of the choices, even when I choose to show hidden.

EDIT:

I don't know why, but I can rename them properly now. I guess it's like how some of the other script fragments are, where they don't work properly until you close the dialog window and reopen it. Maybe even needing to exit and reload the CK.
User avatar
Sunny Under
 
Posts: 3368
Joined: Wed Apr 11, 2007 5:31 pm

Post » Thu Jun 21, 2012 3:32 am

How do I rename a quest fragment script? It's driving me crazy!

I click on the advanced tab for script fragments in the quest stages tab and rename the script there. But when I check the script tab of the quest, it's still using the old script. If I make changes to the script fragments, the changes are not reflected in the old script, but the new script.

I try to remove the old script from the quest, but each time I open up the quest, the script is still there. I want to add in the new renamed script, but it isn't one of the choices, even when I choose to show hidden.

I recall recently seeing something about this. Let me dig through my history and see if maybe I can help you out for a change. Will edit if I find anything.
User avatar
sara OMAR
 
Posts: 3451
Joined: Wed Jul 05, 2006 11:18 pm

Post » Wed Jun 20, 2012 12:31 pm

Let's say I have a reference alias filled by an actor. If I have OnReset in it, when does it fire? When the actor resets, or when the owning quest resets?

EDIT:

http://www.gamesas.com/topic/1367537-quests-aliases-and-resets/
User avatar
Anna Watts
 
Posts: 3476
Joined: Sat Jun 17, 2006 8:31 pm

Post » Wed Jun 20, 2012 6:11 pm

I'm getting an odd error message on loading an interior cell:

HAVOK: File contains a phantom with mesh shape collision.
Plaese remove shape or convert to primitive

I've had it for ages and it migrated to another cell when I copied a weapon plaque, which I have deleted but the error remains. Does anyone know what causes this? I can't find any phantoms, or maybe I just don't know how to find them.
User avatar
Avril Louise
 
Posts: 3408
Joined: Thu Jun 15, 2006 10:37 pm

Post » Wed Jun 20, 2012 4:42 pm

How would I go about retrieving a summoned actor to put it in a reference alias?

This was easy to accomplish with reanimation spells, because I can just do RefAlias.ForceRefTo(Target) when OnEffectStart returns the target. But Summon Familiar, for example, applies the magic effect to the caster, thus OnEffectStart returns the caster as the target and the caster.

Is there an easier way than making new summoned actors, replacing the vanilla ones, and attaching a script to them that forces the reference alias to them OnInit()?
User avatar
IM NOT EASY
 
Posts: 3419
Joined: Mon Aug 13, 2007 10:48 pm

Post » Thu Jun 21, 2012 2:42 am

I feel pretty dumb asking about this since I had like 3 discrete math/combinatorics courses in university, but I'm having a logic problem trying to figure out how to convert my nice and simple expression into one i can enter into the magic effects conditions box, and I'd appreciate someone helping me (and maybe refreshing my memory on how to do this so I don't have to ask in the future):

This is for a magic effect, which activates IF (PlayerHasPerk=False) OR (PlayerHasPerk=True AND ConditionMet=False). For the expression in the first parentheses, the state of ConditionMet is irrelevant (although maybe my failure to include both potential values for it is what's messing me up?).

Anyway, if I'm understanding the CK documentation correctly, the CK's order of operations is OR > AND, which would screw up my expression if entered into the condition box as is. So help! Please.

Edit: Think I figured it out, although if this is wrong, please still correct me. Looks like: (ConditionMet=False OR PlayerHasPerk=False) AND (ConditionMet=False OR PlayerHasPerk=True) AND (ConditionMet=True AND PlayerHasPerk=False)

which should reduce to (ConditionMet=False AND PlayerHasPerk=False OR PlayerHasPerk=True) AND (ConditionMet=True AND PlayerHasPerk=False)

No, that's definitely wrong. I'm still stuck. :/

Further edit! Got it! I was making it way too hard. The correct answer is: IF ConditionMet=False OR PlayerHasPerk!=True. I forgot that I could do the whole not-equal comparison thing.
User avatar
Yung Prince
 
Posts: 3373
Joined: Thu Oct 11, 2007 10:45 pm

Post » Wed Jun 20, 2012 12:51 pm

Further edit! Got it! I was making it way too hard. The correct answer is: IF ConditionMet=False OR PlayerHasPerk!=True. I forgot that I could do the whole not-equal comparison thing.

http://www.creationkit.com/Condition#Comparison

In the future, you can think of "AND" as +, "OR" as x:

(A AND B) OR (C AND D)
(A + B) X (C + D)
(A X C) + (A X D) + (B X C) + (B X D)
(A OR C) AND (A OR D) AND (B OR C) AND (B OR D)
A OR C AND A OR D AND B OR C AND B OR D

(Need to use code tags or else I get the smilies.)
User avatar
Silencio
 
Posts: 3442
Joined: Sun Mar 18, 2007 11:30 pm

Post » Wed Jun 20, 2012 9:03 pm

I guess maybe the wiki is wrong or the articles are incomplete and you can't actually use the item reference itself in those functions. Does it work properly when you change your script to this:

Event OnInit()	if Game.GetPlayer().IsEquipped(self.GetBaseObject())		Game.GetPlayer().EquipItem(NewArmor,false,true)		Game.GetPlayer().RemoveItem(self.GetBaseObject(),1,true)		Game.GetPlayer().AddItem(self.GetBaseObject(),1,true)	endif	GotoState("Initialized")EndEvent

?
I put that script in an Armor, and when I use this:
Debug.MessageBox(Self.GetBaseObject())

It returns none.

Oh well.

EDIT:
How do I attach a script to the Player? I want to add an OnItemAdded event to the player. DO I have to create a quest?
User avatar
Causon-Chambers
 
Posts: 3503
Joined: Sun Oct 15, 2006 11:47 pm

PreviousNext

Return to V - Skyrim

cron