How to get started making my game moddable?

Hey everyone,

After a long, long journey of making my own engine with SDL and OpenGL, I now know that I was right for picking monogame as my favourite way of making games. However, I am feeling ambitious and I want my next game to feature modding support in the sense that every enemy, map, weapon, NPC etc is created from a script. I will adopt an Entity-Component System in order to execute this, but my question is where the hell do I start?

I know Nlua is a thing, but the question is how easy is it to integrate it into my game? What about just using C#? Any way of importing scripts written in C# that simply references function calls?

What I’m really looking for is someone who has tried this already and what they feel would be best. All I will be wanting to do is a way for someone to take what I code and mix it up a bit and I believe implementing scripting will be an enjoyable project. Is it do able?

Thanks for reading!

I’d say c#, or even vb - which as it turns out makes a pretty neato language to embed - but it’s somewhat painful (whitelist/blacklist is the only way afaik) to sandbox it in a nice, secure way. So if security for some reason doesn’t matter in your project, I’d go for Roslyn/the-mono-eval-thing.

If I remember correctly, IronPython has callbacks for when it loads in types/assemblies. So, and I have no idea how you would, you might could do some kind of special checking in there if you wanted (aside from the aforementioned whitelist/blacklisting, even though you could technically do this here as well.).

From what i can tell Roslyn allows you to execute c# code at runetime, even entire classes. Might be worth taking a look. https://github.com/dotnet/roslyn/wiki/Scripting-API-Samples

Is Roslyn still cross platform on windows linux and mac? Thankyou for both of your replies! :slight_smile:

Roslyn does support mono by default so Its likely to be cross platform, not 100% sure though. Hopefully someone else can give a better answer.

I can’t… But StackOverflow can!

Edit: But also see the answer (and its comments) right below the previously linked one.

1 Like

Thankyou! I think this is what I’m going to go for!