Globals in dialogue fragments

Post » Wed Jun 20, 2012 11:42 pm

I've tried adding something that will simply change a global variable to a certain value when a dialogue response is chosen.
But whenever I try it, it doesn't seem to work.
All I've really done is add
TWDestination.SetValue(3)
to the begin section of my response topic, with TWDestination being the global.
However, it refuses to compile, giving me errors about how that variable doesn't exist.
I'm gonna guess it's got something to do with globals having to be a property, but I really don't understand what's going on at this point.
User avatar
{Richies Mommy}
 
Posts: 3398
Joined: Wed Jun 21, 2006 2:40 pm

Post » Thu Jun 21, 2012 1:15 am

In Papyrus when something is global this means it can be accessed globally via properties, and not that it can be used "just like that" anywhere.

So yes, you need to add a property which links the name you use for that variable in your script with actual global variable name.

You may want to edit the source of your script and add at the end this code:
GlobalVariable Property TWDestination Auto
then press Properties button on right and then Auto-Fill button.

OR

just press that Properties button and define property there without messing with the code...
User avatar
Rozlyn Robinson
 
Posts: 3528
Joined: Wed Jun 21, 2006 1:25 am

Post » Thu Jun 21, 2012 2:38 am

Tried adding that property to the source, but the compiler still yells at me when I go to compile whatever's in the begin box. However I noticed changing the source script doesn't seem to change either box, is this expected?
User avatar
sas
 
Posts: 3435
Joined: Thu Aug 03, 2006 8:40 am

Post » Wed Jun 20, 2012 6:43 pm

You need to declare properties in source code of the script OUTSIDE of Begin and End fragments!
Just right click on script's name and choose Edit Source from menu, then AFTER the whole code you have there just add that line which declares property. Then CTRL+S to compile and save the script.
User avatar
Cagla Cali
 
Posts: 3431
Joined: Tue Apr 10, 2007 8:36 am

Post » Wed Jun 20, 2012 2:04 pm

So
;BEGIN FRAGMENT CODE - Do not edit anything between this and the end comment;NEXT FRAGMENT INDEX 5Scriptname TIF__020210E1 Extends TopicInfo HiddenGlobalVariable property MyRef auto;BEGIN FRAGMENT Fragment_4Function Fragment_4(ObjectReference akSpeakerRef)Actor akSpeaker = akSpeakerRef as Actor;BEGIN CODEMyRef.setValue(3);END CODEEndFunction;END FRAGMENT;END FRAGMENT CODE - Do not edit anything between this and the begin comment

is the full script, according to the thing would that work fine?
EDIT: Nevermind, got it working.
User avatar
Rachie Stout
 
Posts: 3480
Joined: Sun Jun 25, 2006 2:19 pm


Return to V - Skyrim