How to make add-ons for a game

So, I was wondering, is it possible for me to make add-ons for a game? If so I was thinking it would work as a file or files being in the game directory. What I want to be able to do is make it so when you drag a file into the game directory and start up the game it will give you the options/content that may be stored in the file. Such as a new weapon that can be used. Therefore, if this file was gone then the weapon wouldn’t be there.

I’m not sure how I could do this exactly, is it possible?

Thank you for taking the time to read this post, and all help is highly appreciated. :slight_smile:

You can read values from txt and XML files, and you can also store these values in groups inside the file, and check if the group is exist.
Probably not a good solution, but what you could do is to make groups inside txt files and check if groups are available.

For example, if you want a rifle to be available in your game only if the “addon” is present, simply use a group inside a text file as an “addon” and check if the group is exist like so.

Write this inside a txt file:

This is a group called rifle. save the txt file, and place it inside your project folder. In Game develop check if the group “rifle” is exist in the text file and make rifle available only if rifle group is available inside the specified text file. To check, you can use the Storage\Existence of a group event.
If you remove the text file or only the group from the text file, the condition is false and rifle not available in the game. If you add the text file to the project folder, or only add the group inside the text file, rifle become available.

But this solution is very easy to hack as you only write inside txt files. If you want to use premium addons in a commercial game, this is not a solution for you.
Maybe you could use dll’s instead txt files. As far as I know you can read functions from dll files using C++ feature but unfortunately I can’t help you with that as I don’t have any experience with the C++ feature of GD. But the idea is the same.
You can make a dll file in C++ and make a function inside the dll that return a value maybe. In GD you can try to read the function from the dll, if the function is exist and you get the value from the function, the reading is success and the rifle is available in the game. If function is not exist, you don’t get the value from the function, the reading is failed and the rifle is not available in the game. Probably this is also not practical way to do, but at the moment I have no better idea.

Hope it helps.

The final game is compiled, so I think it’s impossible to make add-ons using GD’s GUI events, because you would need to know what the add-on will add (for example, if you want a “rifle add-on” you should make all rifle events first, and des/activate it with a simple external file… This is not an add-on) :confused:
As ddabrahim says (and as ddabrahim, I really don’t know :stuck_out_tongue: ), the only way could be make the add-on in C++ code ( :exclamation: only if the C++ source files can be executed externally, after compile the game!), check this out:
In the base game, add an event that check every file in a folder “add-ons”. Then, for each file, check the add-on’s name and other things, if verified that the file is an add-on, add the file in a C++ list “addons_files”, or something like that. Finally add a C++ event, for each file in the list “addons_files” run them universal functions “on_run()” to run every add_on. The “on_run()” function should have C++ events that GD can recognize.
Repeat: Only if C++ events can be read externally after compile game!

The C++ has to be compiled, so it cannot work.

Oh ok, well thank you guys for trying to help me out. :slight_smile:

So let’s say you have already made all of the events and actions for the rifle but they won’t activate until you put a certain file of the name rifle into the game directory in a folder called add-ons. Once you put the file in there the options to select it will appear and you can then select the weapon.

Pretty much just a file that activates certain events and actions.

Is this possible? If so what files could it be done with?

For native games, there is a condition testing for the existence of a file if I remember correctly.