Jump to content

Skyrim Papyrus: intermod communication question


Recommended Posts

I'm trying to dynamically interact with some other mods using the Papyrus API in Skyrim SE. Some of the API's in the Creation Kit do not seem to be available in SSE.

 

The document link is https://www.creationkit.com/fallout4/index.php?title=Inter-mod_Communication

 

I can't find anything 'official' that is for SSE, just Fallout4.

 

The Game.IsPluginInstalled() works fine, but the ScriptObject.CallFunction() and ScriptObject.GetPropertyValue() do not seem to even exist.

 

Is there another way of accomplishing this in SSE, or another library/mod that I can use?

 

I'm trying very hard to avoid hard dependencies which equate to patches... any help or input is appreciated!

Link to comment
Share on other sites

Instead of IsPluginInstalled, you can use GetModByName (requires SKSE) or GetFormFromFile, to check if a plugin is present.

 

There are no functions like CallFunction or GetPropertyValue in Skyrim, but you can make a property for the object the script is attached to and use (ObjectName as ScriptName) to call functions or retrieve property values.

Link to comment
Share on other sites

Thanks, I'll checkout that call out in SKSE!

 

The mods I'm checking for are not mine, so I can't add a property to them. They do have properties/functions I can access.

 

This leads me then to the dynamic casting. Is there a way to do the 'as someobject' for the casting dynamically? The docs I have also refer to a ScriptObject.CastAs() which doesn't appear in SSE either.

Link to comment
Share on other sites

I don't think you can do this dynamically, it needs to be done individually for each script that you want to access.

 

For example, if you would want to read a property value from a script on another mod that is attached to a quest, you can do the following:

Quest OtherModsQuest

Event OnInit()
	OtherModsQuest = Game.GetFormFromFile(0x00002dca, "OtherMod.esp") as Quest
        if OtherModsQuest
	   debug.messagebox("Property value is: "+(OtherModsQuest as SomeScript).SomeProperty)
        endif
EndEvent

A property is not even needed, it can also be a local object variable.

Link to comment
Share on other sites

The caveat being, if users decide to save some mod slots by merging a bunch of mods into a single esp with a different filename, your script will no longer work. So make sure to warn your users never to merge or rename the other mod ;P

 

edit: it's also a great way to discourage your mods from being included in modpacks ;)

Link to comment
Share on other sites

Its not as hard as some may imply, and you have more options than are commonly mentioned. Like Quests, you can look for it by EID and not have to worry about FormIDs

 

Quest FromThatOtherMod = Quest.GetQuest("WhateverItsEditorIDIs") <----- Has no reliance or worry about plugin name or FormID

 

Can do the same for Keywords Headparts and Race also. Keyword.GetKeyword("WhateverWord")

 

Depends ofc what you are doing, and ways you pref to set things up, but you can fully communicate with these other scripted objects, but you would need to iron out a gameplan which works for you, of how you plan to handle things, if ABC mod is present, and or DEF mod, etc

Link to comment
Share on other sites

  • 2 months later...

Thank you for the info on GetQuest('someeditorid')! The documentation on papyrus has partial examples that don't work very well, not to mention they are frequently flagged for fallout 4.

 

for the editorid, is that the same as the FormId listed in the Creation Kit's ObjectWindow column? I know I can't use it directly in the code and need to get the objects using the Id with an API. I keep seeing the Editor/Form Id being used interchangeably in the docs and it's confusing.

 

I'm trying to script a mod that will dynamically determine if another mod is installed and if so, use a function or set a property in it. My goal is to create a mod that doesn't require patching for each mod combination that's out there which could impact mine.

Link to comment
Share on other sites

I see more and more people landing on the FO4 pages for the Creation Kit than they do on the Skyrim pages.

At any rate, here is a link to the Skyrim Papyrus page: https://www.creationkit.com/index.php?title=Category:Papyrus

Note the lack of Fallout4 in the URL. Any Creation Kit wiki page without Fallout4 in the URL is for Skyrim.

 

EditorID is the text label for a given record

FormID is the 8 character hex number for a given record

 

You can statically determine if another mod is installed. i.e. you have a list of condition checks with GetModByName if using SKSE or GetFormFromFile if not using SKSE. After that you can link up with whatever script from the other mod to affect properties or use their functions.

 

To the end user it is "dynamic" but as far as the code goes it is not dynamic but explicitly written out.

 

GetQuest requires SKSE. Just letting you know before you run into issues should you try to use it.

Link to comment
Share on other sites

  • 5 weeks later...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...