Illustrious Posted December 8, 2015 Posted December 8, 2015 I want to attach a script to a piece of dialogue that will change a Global variable. I've spent hours trying to get this simple thing to work and it just won't. Basically all I need a way of calling a function via dialogue. I've been working on SexLab mods on and on for months but using Creation Kit is a complete nightmare. Please help me, I'm so angry right now. By looking at other mods this seems like it should work but it doesn't: ---------------------------------------------------------------------------------------- Scriptname SCRIPTNAME Extends TopicInfo Hidden;BEGIN FRAGMENT Fragment_0Function Fragment_0(ObjectReference akSpeakerRef)Actor akSpeaker = akSpeakerRef as Actor;BEGIN CODEGLOBALVARIABLE.SetValue(1);END CODEEndFunction;END FRAGMENTGlobalVariable Property GLOBALVARIABLE Auto ---------------------------------------------------------------------------------------- I can get it to change using this, but Event OnInt only seems to work once. If I load another save afterwards it won't trigger the second time. ---------------------------------------------------------------------------------------- Scriptname SCRIPTNAME Extends TopicInfo Hidden Event OnInit() FunctionName() EndEvent Function FunctionName() GLOBALVARIABLE.SetValue(1)EndFunctionGlobalVariable Property GLOBALVARIABLE Auto
Tepi Posted December 8, 2015 Posted December 8, 2015 Not sure why that particular thing doesn't work as I have not really done much in CK but you could do the increment via function: Function FunctionX() GLOBALVARIABLE += 1 endFunction Then call it from fragment with: (GetOwningQuest() as SCRIPTNAME).FunctionX()
Guest Posted December 8, 2015 Posted December 8, 2015 Your first script is the correct way to do it. Just check if you defined the property in the script (right click on the script in the Topic Info, select Properties, and fill the value.) Of course your GLOBALVARIABLE has to be defined in the CK. The event OnInit fires only once. So it is not what you are looking for. To @Tepi, you cannot increase a value of a GlobalVariable object with the operator +=. It is an object, not an integer.
Illustrious Posted December 8, 2015 Author Posted December 8, 2015 Thank you both for replying. I do have the global variable added as a property to the script. Of course your GLOBALVARIABLE has to be defined in the CK. I'm not sure I fully understand. I created the global varaible before writing the script, is that what you mean? I have it set to 0, short and not a constant. Is that right?
Guffel Posted December 8, 2015 Posted December 8, 2015 Thank you both for replying. I do have the global variable added as a property to the script. Of course your GLOBALVARIABLE has to be defined in the CK. I'm not sure I fully understand. I created the global varaible before writing the script, is that what you mean? I have it set to 0, short and not a constant. Is that right? Then you did that all right Are you editing this script throug right click -> "open source" ? Or are you typing in the small windows for "On dialouge start/ end" ? Because you can only edit script fragments through the windows, not in the source. So your script compiles? the oninit() event trigger once when the script was loaded, so directly when you start the game, even if the quest is not started. Edit: did you click an "properties" and point the property of the GV to the actuall GV?
Illustrious Posted December 8, 2015 Author Posted December 8, 2015 Thanks for the reply. Yes, I did do the property thing. I've been doing all the scripting in the source because I can't get anything that isn't 'GetOwningQuest().SetStage(10)' to compile in the small End window.Perhaps I'm not doing the right thing? If you have a moment, could you post a version of my first script that I would need to put in the small window for it to compile without error.
Guffel Posted December 8, 2015 Posted December 8, 2015 If you have the property of the global variable already set up, GLOBALVARIABLE.SetValue(1) is all you need to type in the window for the dialouge start or end. I'm not sure if your scrip will still compile after your changes to the source, so it might be better to start over. Than remove the script, close the dialoug and open it again, then type in the fragment window you want somethin like: ;content and hit compile. The ; marks everything after is as comment and the compiler ignores it. So you get a fresh new script. Now select the script in the list on the right, click property and set you GV up. Now you can delete the ; content again and put the line from the beginning into the fragment window. That should compile now.
Illustrious Posted December 8, 2015 Author Posted December 8, 2015 I actually teared up a little bit when it worked. Thank you, Guffel. Creation Kit needing to be tricked into doing something basic like that means it can die in a fire, but you're quite wonderful.Thanks everyone for helping.
Guffel Posted December 8, 2015 Posted December 8, 2015 Yes I know, the CK can be very frustrating, especially for beginning modders. I'm glad I could help you, and don't hesitate to ask again if another problem occurs.
Illustrious Posted February 26, 2016 Author Posted February 26, 2016 Back again. I'm attempting to adapt Submit for something and have a compilation problem, 'GetActorRef' and 'ForceRefTo' work when I use Submit's original 'ActorBounty1' but not my own. As far as I can tell my references are he same. :/akSpeaker.StopCombat()akSpeaker.RemoveFromAllFactions()akSpeaker.SetRelationshipRank(Game.GetPlayer(), 2)akSpeaker.AddToFaction(DunPlayerAllyFaction)akSpeaker.SetFactionRank(DunPlayerAllyFaction, 2)akSpeaker.SetPlayerTeammate()akSpeaker.GetActorBase().SetProtected()akSpeaker.SetAV("Health",1.0)akSpeaker.AddItem(zilLeatherCuffs, 1)Game.GetPlayer().RemoveItem(zilLeatherCuffs, 1)akSpeaker.SetAV("Aggression",0)akSpeaker.AddToFaction(zilCaptiveFaction)If ActorCaptive1.GetActorRef() == None ActorCaptive1.ForceRefTo(akSpeaker)Else ActorCaptive2.ForceRefTo(akSpeaker)EndIf Starting 1 compile threads for 1 files...Compiling "zilCaptiveScript"...C:\Steam\steamapps\common\skyrim\Data\Scripts\Source\temp\zilCaptiveScript.psc(21,17): GetActorRef is not a function or does not existC:\Steam\steamapps\common\skyrim\Data\Scripts\Source\temp\zilCaptiveScript.psc(22,15): ForceRefTo is not a function or does not existC:\Steam\steamapps\common\skyrim\Data\Scripts\Source\temp\zilCaptiveScript.psc(24,15): ForceRefTo is not a function or does not existNo output generated for zilCaptiveScript, compilation failed.Batch compile of 1 files finished. 0 succeeded, 1 failed.Failed on zilCaptiveScript
Guffel Posted February 26, 2016 Posted February 26, 2016 Back again. I'm attempting to adapt Submit for something and have a compilation problem, 'GetActorRef' and 'ForceRefTo' work when I use Submit's original 'ActorBounty1' but not my own. As far as I can tell my references are he same. :/ akSpeaker.StopCombat() akSpeaker.RemoveFromAllFactions() akSpeaker.SetRelationshipRank(Game.GetPlayer(), 2) akSpeaker.AddToFaction(DunPlayerAllyFaction) akSpeaker.SetFactionRank(DunPlayerAllyFaction, 2) akSpeaker.SetPlayerTeammate() akSpeaker.GetActorBase().SetProtected() akSpeaker.SetAV("Health",1.0) akSpeaker.AddItem(zilLeatherCuffs, 1) Game.GetPlayer().RemoveItem(zilLeatherCuffs, 1) akSpeaker.SetAV("Aggression",0) akSpeaker.AddToFaction(zilCaptiveFaction) If ActorCaptive1.GetActorRef() == None ActorCaptive1.ForceRefTo(akSpeaker) Else ActorCaptive2.ForceRefTo(akSpeaker) EndIf Starting 1 compile threads for 1 files... Compiling "zilCaptiveScript"... C:\Steam\steamapps\common\skyrim\Data\Scripts\Source\temp\zilCaptiveScript.psc(21,17): GetActorRef is not a function or does not exist C:\Steam\steamapps\common\skyrim\Data\Scripts\Source\temp\zilCaptiveScript.psc(22,15): ForceRefTo is not a function or does not exist C:\Steam\steamapps\common\skyrim\Data\Scripts\Source\temp\zilCaptiveScript.psc(24,15): ForceRefTo is not a function or does not exist No output generated for zilCaptiveScript, compilation failed. Batch compile of 1 files finished. 0 succeeded, 1 failed. Failed on zilCaptiveScript look like a property issue for me. Your "ActorCaptive1" and "ActorCaptive2" need to be of the "ReferenceAlias" type. How do your properties on that script look like?
Illustrious Posted February 27, 2016 Author Posted February 27, 2016 Ah, you were right again. I had the properties as Alias and not ReferenceAlias, Thank you!
Illustrious Posted September 14, 2017 Author Posted September 14, 2017 Sorry to necro. Anyidea why this barber script doesn't work? Scriptname zilTestScript extends TopicInfo Headpart property HairFemaleRedguard03 Auto Event OnInit() Game.getplayer().ChangeHeadPart(HairFemaleRedguard03)
Recommended Posts
Archived
This topic is now archived and is closed to further replies.