Will a script attached to a topic run if there's nothing in

Post » Tue Jun 19, 2012 9:18 pm

I have this script, I want it to run when a dialogue topic is chosen, but I can't figure out what to put in the script fragment/ have never really understood how scripts with dialogue works. If I have this script attached:

;BEGIN FRAGMENT CODE - Do not edit anything between this and the end comment;NEXT FRAGMENT INDEX 3Scriptname TIF__01000D8F Extends PKRoseLevel;BEGIN FRAGMENT Fragment_2Function Fragment_2(ObjectReference akSpeakerRef)Actor akSpeaker = akSpeakerRef as Actor;BEGIN CODEPKMoveSlotNum.setValue(0)LearnMove();END CODEEndFunction;END FRAGMENT;END FRAGMENT CODE - Do not edit anything between this and the begin comment

Will it run when the player reaches this topic automatically, or is there something more I have to do?
User avatar
Naughty not Nice
 
Posts: 3527
Joined: Sat Nov 04, 2006 6:14 am

Post » Wed Jun 20, 2012 6:14 am

Seriously, I really need to know how to run a script on my actor from a dialogue topic.
User avatar
Emma
 
Posts: 3287
Joined: Mon Aug 28, 2006 12:51 am

Post » Tue Jun 19, 2012 7:20 pm

If you put your fragment under 'Begin', it will run when the NPC starts dialogue. If you put it under 'End', it will run when the NPC finishes dialogue. I'm not sure what else you could be asking.
User avatar
Captian Caveman
 
Posts: 3410
Joined: Thu Sep 20, 2007 5:36 am

Post » Tue Jun 19, 2012 6:40 pm

If you put your fragment under 'Begin', it will run when the NPC starts dialogue. If you put it under 'End', it will run when the NPC finishes dialogue. I'm not sure what else you could be asking.

No, I have an actor. The actor has a script attached to them. I want to run the functions in that actor's script, from dialogue. Or, how do I run any script (you know, the scripts you can write any put in on the side in any topic) when a topic is said.
User avatar
Hairul Hafis
 
Posts: 3516
Joined: Mon Oct 29, 2007 12:22 am

Post » Tue Jun 19, 2012 10:20 pm

Get the reference from his alias, cast it as the scriptname like

MyScriptName MyActor = (Alias_MyAliasName.GetReference() As MyScriptName)

Then you can call functions with:

MyActor.MyMemberFunctionName()
User avatar
marina
 
Posts: 3401
Joined: Tue Mar 13, 2007 10:02 pm

Post » Wed Jun 20, 2012 12:45 am

EDIT: Nevermind, I don't understand any of what you said. I tried that and the compiler pooped itself.
User avatar
luis dejesus
 
Posts: 3451
Joined: Sun Aug 19, 2007 7:40 am

Post » Wed Jun 20, 2012 7:07 am

You call the function from within the papyrus fragment. But the function itself should be written in your alias' script.
User avatar
clelia vega
 
Posts: 3433
Joined: Wed Mar 21, 2007 6:04 pm

Post » Wed Jun 20, 2012 7:44 am

You call the function from within the papyrus fragment.

How. I have never once gotten this to work.
User avatar
Jason White
 
Posts: 3531
Joined: Fri Jul 27, 2007 12:54 pm

Post » Wed Jun 20, 2012 12:39 am

This is the answer, but it is quite codey

Just take it slow and you should be OK.
  • Your dialogue needs a fragment that calls (in the Begin Block) a FUNCTION in your Actor Script (so the script must have functions, you can't just run the whole script ... So it depends what your script does and how you coded it)
  • The NPC with the script must be aliased in your Quest
Get the reference from his alias, cast it as the scriptname like

MyScriptName MyActor = (Alias_MyAliasName.GetReference() As MyScriptName)

Then you can call functions with:

MyActor.MyMemberFunctionName()
User avatar
Charlotte Henderson
 
Posts: 3337
Joined: Wed Oct 11, 2006 12:37 pm

Post » Tue Jun 19, 2012 10:13 pm

  • Your dialogue needs a fragment that calls (in the Begin Block) a FUNCTION in your Actor Script

FOR THE LOVE OF GOD HOW! HOW HOW HOW? This is what I'm asking. How do you call a function in an actor script from a dialogue fragment? The function name is LearnMove, the scriptname is PKRoseLevel, and the alias for the actor is PKRoseliaAlias.

Please, anyone responding to this, do not "describe" how to fix the problem. I'm not a programmer, I don't understand your jargon, and I don't intuitively know the syntax of Papyrus. Just write a line or two of code that one would put in a papyrus fragment that would call the function of an aliased actor.
User avatar
GLOW...
 
Posts: 3472
Joined: Thu Aug 03, 2006 10:40 am

Post » Wed Jun 20, 2012 8:02 am

I'll explain it a bit at a time:

MyScriptName MyActor = (Alias_MyAliasName.GetReference() as MyScriptName)

Replace "MyScriptName" in both instances with the name of the script attached to your actor that has the function you want to call

MyActor is the variable name you'll be using for the actor to call your functions on.

Alias_ is the prefix the quest script automatically adds to your quest alias. You can see them if you go to the fragment script (Called QF_QUESTNAME_SomeRandomNumber on the scripts tab) and click "properties" - Replace MyAliasName with the name of the alias your actor is assigned to.

GetReference() - This function tells the Alias it is called on to return the thing to which it refers (In this case your actor)

By casting the actor as the scriptname, you can then call any functions you defined in the script you named as the type of the variable you are storing the reference in (Which is the "MyMemberFunctionName" in my earlier post)

So in English, the line says "Define a variable called MyActor of type MyScriptName, and assign it to the reference that Alias_MyAliasName is storing, and make sure it is a "MyScriptName" type of object so I can access functions and properties it has."
User avatar
Len swann
 
Posts: 3466
Joined: Mon Jun 18, 2007 5:02 pm

Post » Tue Jun 19, 2012 7:01 pm

I'll explain it a bit at a time:

MyScriptName MyActor = (Alias_MyAliasName.GetReference() as MyScriptName)

Replace "MyScriptName" in both instances with the name of the script attached to your actor that has the function you want to call

MyActor is the variable name you'll be using for the actor to call your functions on.

Alias_ is the prefix the quest script automatically adds to your quest alias. You can see them if you go to the fragment script (Called QF_QUESTNAME_SomeRandomNumber on the scripts tab) and click "properties" - Replace MyAliasName with the name of the alias your actor is assigned to.

GetReference() - This function tells the Alias it is called on to return the thing to which it refers (In this case your actor)

By casting the actor as the scriptname, you can then call any functions you defined in the script you named as the type of the variable you are storing the reference in (Which is the "MyMemberFunctionName" in my earlier post)

So in English, the line says "Define a variable called MyActor of type MyScriptName, and assign it to the reference that Alias_MyAliasName is storing, and make sure it is a "MyScriptName" type of object so I can access functions and properties it has."

So...

PKRoseLevel Roselia = (Rosy.GetReference() as PKRoseLevel)Roselia.LearnMove()where Rosy is the property for the alias that I have in the dialogue sscript.

This seems to compile. I still don't understand how Papyrus fragments work, or why they even exist (why not just have attached scripts, and then have events that are the beginning and end of topics?) but at least it works.
User avatar
Scotties Hottie
 
Posts: 3406
Joined: Thu Jun 08, 2006 1:40 am

Post » Wed Jun 20, 2012 9:03 am

Your best bet would be to try it and see...I would have thought it would have to be Alias_Rosy.GetReference()...you are assigning Rosy the same way the questalias was assigned? (Assuming Rosy is a quest alias?)

Fragments are a way to have the CK do a lot of the tricky coding needed to make certain parts of a script to function in specific areas and be disabled everywhere else.
User avatar
Avril Churchill
 
Posts: 3455
Joined: Wed Aug 09, 2006 10:00 am

Post » Wed Jun 20, 2012 7:13 am

Your best bet would be to try it and see...I would have thought it would have to be Alias_Rosy.GetReference()...you are assigning Rosy the same way the questalias was assigned? (Assuming Rosy is a quest alias?)

Fragments are a way to have the CK do a lot of the tricky coding needed to make certain parts of a script to function in specific areas and be disabled everywhere else.

What? Rosy is the alias for the actor. Why would I put a quest alias there?
User avatar
Paula Rose
 
Posts: 3305
Joined: Fri Feb 16, 2007 8:12 am

Post » Tue Jun 19, 2012 11:30 pm

What? Rosy is the alias for the actor. Why would I put a quest alias there?

We are talking about a quest fragment, right? It creates the alias references for you when you assign your aliases...

At least I think that's how it works in fragments...
User avatar
Ladymorphine
 
Posts: 3441
Joined: Wed Nov 08, 2006 2:22 pm

Post » Tue Jun 19, 2012 8:15 pm

We are talking about a quest fragment, right? It creates the alias references for you when you assign your aliases...

At least I think that's how it works in fragments...

It's a dialogue fragment. Hence the title of this thread...
User avatar
louise tagg
 
Posts: 3394
Joined: Sun Aug 06, 2006 8:32 am

Post » Wed Jun 20, 2012 5:25 am

I'm a classical programmer, so this whole "Fragmented scripting" thing is fairly new to me, so this is the Begin or End script fragment in a scene, right? Then the regular quest alias should work instead of the Alias_ property you use for the OTHER type of fragments...man the quest fragmented script thing is massively headache inducing...
User avatar
Imy Davies
 
Posts: 3479
Joined: Fri Jul 14, 2006 6:42 pm

Post » Wed Jun 20, 2012 1:27 am

I'm a classical programmer, so this whole "Fragmented scripting" thing is fairly new to me, so this is the Begin or End script fragment in a scene, right? Then the regular quest alias should work instead of the Alias_ property you use for the OTHER type of fragments...man the quest fragmented script thing is massively headache inducing...

I 100% agree with you.
User avatar
Alexis Acevedo
 
Posts: 3330
Joined: Sat Oct 27, 2007 8:58 pm

Post » Wed Jun 20, 2012 6:15 am

Dialogue is always part of a Quest - Well, I know of no other way to create it?

So a script fragment in Dialogue is really just a script fragment that is part of a Quest; so it will accept Quest Alias.


No one is trying to confuse you, Ducey ;) Those of us who are/were coders struggle with bits of it, while we work out exactly how the IDE (the CK) and the associated language (Papyrus) works.

You need to try and pick up concepts - and understand them - as well as just asking for lines of code. Figuring stuff out (having read examples) is how we all learn to code (in whatever IDE and with whatever language).


Glad this bit is working for you ... hopefully when you run across a similar thing you want to do, you think back to this, remember how it was solved and - that next time - it's much easier.


My Water Margin* Bit: Coding is a journey; one that never seems to end. ;)

(* go google it!)
User avatar
Inol Wakhid
 
Posts: 3403
Joined: Wed Jun 27, 2007 5:47 am

Post » Wed Jun 20, 2012 9:01 am

I've been thinking of script fragments as local functions for the quest stages/dialog they are attached to...hoping that won't get me into trouble later...
User avatar
Juliet
 
Posts: 3440
Joined: Fri Jun 23, 2006 12:49 pm


Return to V - Skyrim