I have been wanting to make a game in C++ about programming little ships to fight together.
One of the things, though, is I wanted to be able to edit the game while it was running, instead of having to exit out and recompile the entire thing. My father told me that I can use a DLL to do this, by having the game copy the selected DLL file and run functions from that, then in the game when I press reload it will stop the script and copy in the new DLL and the continue the game.
To test this idea, I made a simple program and DLL project in Codeblocks. The console program called a function thisIsAFunction()
from the DLL once, which would return a number to print to the console, like "1", then I would replace the DLL file with another DLL file that has the same function name but instead returns a different number to print to console.
It isn't working. Trying to replace the DLL file or the library.a
file while the console application was running, Windows says it is open in another process.
Is there any way of accomplishing what I want to do? That is, to change a function return value during the program using DLL files or anything else?
EDIT: First of all thank you, Remy Lebeau, for helping fix all the grammar mistakes. I will be gathering the code soon to put here for reference but it seems like some of you have recommended using a scripting language instead which might work too. So thank you Ill be looking into that as well. So is it really worth it to go through all the trouble with DLLs or should I really just use something like Python or Lua?