Jump to content

When / how / why should I get into trying to write a custom F4SE plugin?


Recommended Posts

Good evening everybody!

 

Usually my approach to learning new tools / new technology is that I will start to learn it if I come across a challenge that can't be overcome with what I already know.

Probably most other people have this approach when working on creating mods.

 

 

I have one big project that I am currently working on (a big worldspace) and I don't really see that needing custom F4SE plugin functions.

Most of the things needed for that mod will be implemented with "simple" stuff like quests, regular papyrus scripts, ...

 

But somehow I think learning a new "technology" (creating custom F4SE plugins in this case) might give me new "perspective" when it comes to trying to implement stuff.

 

I think know the "basic idea" of F4SE plugins: they are a way to have C++ code that can be called by functions in papyrus scripting or just run "alongside" the game or whatever.

 

So, F4SE plugins can be used to do engine-level stuff or do other "fancy stuff".

Since there is no real "scope" of what can or can't be done with F4SE plugins, it is kind of hard to find somewhere to start.

 

For regular mods, learning how to do stuff is easy.

There are tons of tutorials for the CK and xEdit out there that bring you from "what even is an ESP file" to doing things like navmeshing or quests.

And while following these tutorials, the brain will automatically start to imagine things like "oh, I could use this script that moves statics to create a hidden door ...", you probably know what I mean.

It's like learning a new language. First you learn some words and then you learn how to make meaningfull sentences out of those words. And eventually at some point, you will deviate from the "tutorial" and start to look up stuff on your own ...

At least htat is how I learned how to make mods with the CK a few years ago ...

 

But so far I have found no easy-to-follow tutorials for creating custom F4SE plugins.

I have asked about this before and I got the answer "well, creating f4se plugins is per definition no 'beginner task' so there are no 'beginner level tutorials' for it".

And since there are no real "step by step" tutorials for it, that process that I described above does not happen.

It's like getting handed an empty sheet of paper and beeing told "go figure out how to write stuff in this new language yourself".

 

But everybody has to start somewhere, right?

 

So how does a person who might be interested in creating custom F4SE plugins "get into it"?

 

For creating "regular mods" (esp files) there are lots of "beginner projects", like creating a small custom player home or creating a custom settlement, or changing the crafting requirements of some items, ..... (I could go on for ever ...)

 

When I say "beginner level F4SE", I do not mean beginner level in terms of general modding and mod making.

I mean "beginner" at F4SE!

 

I know how to create ESPs, ESMs, ESL, I know the differences between them, I know how to sort load order by hand, I know how to avoid messing up precombines, I know how to avoid that "face texture bug" when creating custom NPCs, ..... I know how to create mods.

I just don'T know how to create F4SE plugins.

So I am a beginner in that "area" of modding.

 

So, what are some "beginner level" F4SE projects?

 

At what point in the creation of a mod does the mod author decide "ok, I think I need to write a F4SE plugin for this", and why?

Ok, the answer to this question might be simple:

If there is no way to implement what you want to do with regular papyrus scripting or with the other functions of the CK.

 

Ok, let's say I want to remove that annoying bug that limits the worldspace size to +-64 cells on the X axis.

Could a F4SE plugin be used to do something like that?

And if so, how?

 

What is the general "workflow" of creating a custom F4SE plugin?

The answer will probably be "it depends" ...

But for example if you create and interior cell in the CK, the usual workflow is something like this: Place all the structural pieces, place all the clutter, place things like idle-markers and doors, do the navmesh, do the optimization (precombines and/or RoomBounds).

No matter what size or shape the interior cell, the general workflow is the same.

 

 

Sorry if this is written like a rant or if it is repetitive or if it makes no sense at all to you ...

I just don't know how to ask and explain these questions in a few lines of text ...

Link to comment
Share on other sites

There is an example plugin for f4Se which will probably go a long way to getting you started.

 

Basically, it defines a papyrus class and a single function within that class, and implements code to print a message when that function is called. Which is basically your workflow, I guess: create entry point, write code to do <whatever>, package up results in a Papyrus type and return them the the engine.

 

 

 

Le me know if you get the urge to write a generalized JSON reader, or similar doo-dad. That's the thing I keep flirting with making.

Link to comment
Share on other sites

There is an example plugin for f4Se which will probably go a long way to getting you started.

 

create entry point

What do you mean by that?

I looked over that example project that you linked to.

What section of that "Main.cpp" file would that be?

 

I can see that there are lots of functions that get defined, but they never get called. Weird ...

Link to comment
Share on other sites

What do you mean by that?

This:

 

bool RegisterFuncs(VirtualMachine* vm) {
	vm->RegisterFunction(
		new NativeFunction0 <StaticFunctionTag, void>("Test", "TestClass", Example_Plugin_Functions::Test, vm));
	return true;
}
Calls the papyrus virtual machine to create a new native function called "Test" attached to a class called TestClass. The TestClass.psc definition is in the git archive too.

 

I can see that there are lots of functions that get defined, but they never get called. Weird ...

Mainly they're being passed to the engine so they can be called later when papyrus invokes the TestClass - Test method.

Link to comment
Share on other sites

 

What do you mean by that?

This:

 

bool RegisterFuncs(VirtualMachine* vm) {
	vm->RegisterFunction(
		new NativeFunction0 <StaticFunctionTag, void>("Test", "TestClass", Example_Plugin_Functions::Test, vm));
	return true;
}
Calls the papyrus virtual machine to create a new native function called "Test" attached to a class called TestClass. The TestClass.psc definition is in the git archive too.

 

I can see that there are lots of functions that get defined, but they never get called. Weird ...

Mainly they're being passed to the engine so they can be called later when papyrus invokes the TestClass - Test method.

 

Aaaaahhhh!

Ok, that makes sense!

 

I think I comprehend, but I need some time to actually understand ;-)

I think I could somehow get this to work and use it as a "starting point" to work / experiment from ...

Link to comment
Share on other sites

  • Recently Browsing   0 members

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