How can I implement scripts in my game?

I try to write a game and implement scripts so that later in development I do not have to recompile everything when I want to change the numbers.

My problem is that I do not know how scripts should interact with the game. The scripting language I use is angelscript .

Now I have a state: intro state, which I use as a test for most modules in my game engine (this looks more like a free collection of classes). It will load and draw an image and draw text, and also use scripts to update itself and, possibly, later switch to a dummy state to check the state manager.

During the recording, I realized that using a script for most of the update would require me to register most of my game engine modules with a script and pretty much move the bulk of the code into a scripting language. Personally, I would prefer that part of C ++ do most of the work, and the scripting language comes up with numbers that need to be used in formulas / drawing / independently.

However, if I am right, this will lead to a large number of different update modules for most of the things in the game that need to be updated, and require that all of them be loaded, and that C ++ code must run each update function individually.

Or, is there a way to achieve script and software compatibility that I miss. Anyway, can someone help me figure out what is the best way to get the scripts implemented in my game?

+3
source share
4 answers

There is no right answer to such a big question. You do this in the same way as in C ++ mode. Define an API that can call a script that allows it, whatever you want. Register functions in this API using a script and use the API in an angel script. What this API should use depends entirely on your needs and what kind of power you want to give the screenwriter.

+5
source

, AngelCode ( ) " ", , - , AngelCode, , ++ , "void ProvideNumberFor (-, )", , " " .

+3
+2

, Garry mod , UnrealScript, , . C/++- "" , , , , .. (.. ).

: IMHO - Lua. C/++, Javascript.

Lua , . , Lua. , .

EDIT: I did not fully read the question ... sorry. This is my real answer;)

+2
source

Source: https://habr.com/ru/post/1724899/


All Articles