Hector0818 Posted October 11 Share Posted October 11 Hello everyone, I’m sure this is a really simple question but I’m just spinning my wheels. I know how to write and compile a script fragment, but how do I add an existing script I already made to dialogue. I see the add option on the far right, and I’m able to find and click on the script that I’ve made, which adds my script to the box or window on the right. But the dialogue doesn’t seem to acknowledge my script. How do I get the dialogue to recognize that existing script I’ve added? Thank you for your time Link to comment Share on other sites More sharing options...
xkkmEl Posted October 11 Share Posted October 11 You need it to extend TopicInfo. ... and call your function as "(Self as myTopicInfoUtilityScript).myFunction()". I however recommend you make your script extend Quest, and attach it to the quest the dialogue is part of, and then use "(getOwningQuest() as myQuestUtilityScript).myFunction()" to call "myFunction" in that script. Of course, change "myQuestUtilityScript" for the name of your script in which "myFunction" is defined.... Why attach it to the quest instead of the dialogue? Because you can use the "sqv myQuest" console command to see the state of your script. There is no similar facility (that I know of) for TopicInfo scripts. Link to comment Share on other sites More sharing options...
scorrp10 Posted October 11 Share Posted October 11 Yes, it is generally best to have all the larger functions defined in a quest script, and the TopicInfo fragments be one-liners invoking them. But yes, you can attach a larger script to a topicInfo and use it. I.e. if you attach a 'MyTopicInfoScript' which has a 'MyFunction()' in it, then you can define a fragment with following line: (Self as MyTopicInfoScript).MyFunction(). Thing is, you still need to create a fragment (TIF) script. It can be rather frustrating as you might have a hundred TopicInfos, each with its own one-liner fragment script doing exactly the same thing, and you end up with a bazillion tiny script files that are 100% the same. I really wish CK had the facility where you could just select which function to call in an attached script, rather than its current forced fragment system. The only way around it is via SSEEdit. So lets say, I created a TopicInfo for a quest MyQuest, and in its Fragment_0, I put: GetOwningQuest().SetStage(20), and I renamed this script as TIF_MyQuest_SetStage20, Now I am creating another topicInfo, which is also supposed to set the quest to stage 20. In its end fragment window, I just put in some comment, and compile the fragment. This will create new TIF__xxxxxxxx.psc and .pex files. Then I click OK, save my plugin, and exit CK. Next, you load SSEEdit, and locate the TopcInfo you just created. In its VMAD - virtual machine adapter section: In the Scripts part, you will see that it has an attached script TIF__xxxxxxxx. Then, under Script Fragments section, in FileName, it has TIF__xxxxxxxx Finally, under under Fragments - Fragment#0 - it has ScriptName TIF__xxxxxxxx and FragmentName = Fragment_0 In all 3 above places, you replace TIF__xxxxxxxx with TIF_MyQuest_SetStage20. Save and exit. Now, you can delete the TIF__xxxxxxxx .psc and .pex files. You can even do one better. Create a fragment script, rename it to TIF_MyQuest_SetStage, add an Int property called 'Stage', populate it with stage number you want to set, and fragment would contain: GetOwningQuest().SetStage(Stage) Then, any Topic Info you create that sets a quest stage, you create an empty fragment and add an Int Stage property to it. Then, in SSEEdit, you change that TopicInfo to use TIF_MyQuest.SetStage script instead, with the Stage property set to desired value. Overall, it is a lot extra work, but it can really cut down on the number of TIF script fragments your mod will include... Link to comment Share on other sites More sharing options...
Hector0818 Posted October 11 Author Share Posted October 11 Thank you for the help ill try this out! Link to comment Share on other sites More sharing options...
PeterMartyr Posted October 13 Share Posted October 13 good go at explaining coupling and cohesion... hehehehe at @scorrp10 doing that with topic info is a waste of time, if you consolidation 10 topic info into 1 and set it values with CK properties, yeah you have 1 physical script, BUT you still have 10 virtual ones in the memory, a lot work for no gain, or performance improvement How do I know there 10 virtual ones? It would not work if that was not true. Think where the CK properties values are stored? Link to comment Share on other sites More sharing options...
scorrp10 Posted October 13 Share Posted October 13 Yeah, not much savings in terms of memory/performance. Link to comment Share on other sites More sharing options...
Recommended Posts