The interpretation script is an important measure to use to control triggers, rule systems, and data systems in a large number of games. In the RPG game, especially the script is used to control the changes in the plot, battlefield details, etc. Even in non-RPG games, a variety of scripts are also used in large quantities.
The script here does not refer to those "Material scripts" "Shader scripts", for me, those who can't call scripts, but just configuration files, these two senses are somewhat different. The script is used to execute, and the configuration file is used to configure, modulate. Regardless of its performance, is it XML? Is III? Still, as long as it is loaded, interpretation and runs line by line, it is an explanation type script.
The interpretation script is easy to learn, durable. Just like a gun AK47, the structure is simple, durable, alpine, drought, and wet heat conditions can be applied. Each compilation principle will spend a lot of effort to explain the principle. Inexhaustible. We were seriously insufficient when compiling the principles, but it was just explained the principle. Unfortunately, how to compile the target code on the target machine, how to connect the target code as the machine code, have not learned, embarrassment! regret!
Since I haven't studied the true compilation principle, I haven't made a very simple interpreter so far.
Unfortunate things, since there is no learning principle, compile the code to machine code is almost impossible, do you write C or C code, and finally hand it over to C or C compiler to compile? Although this has a precedent, it doesn't make sense, it is better to directly encode directly.
Later I thought about it, why do you think about it, compile, why do you compile? The key to the interpreter is to explain the progressive explanation. Every run explanation script will reinterpret, for many games, this is an unable tolerable behavior. The role of compilation is to compile script code into a continuous, fixed instruction sequence, as long as the script is unchanged, and the influence of the random number, the result of the same compilation instruction should be identical. Is there anything else? It should be no.
In fact, there is already such a compiler, and there is also an application in the game, and the language such as Python provides compilation, which is relatively simple.
You can understand the compiled code: That is a collection of instructions or basic elements, it is not necessary to complicate these basic elements to assembly levels such as Push, POP, JUMP, and actually give it very roughly as needed. Out of the basic element: Follow the functionality to divide the elements into behavior and operators, such as the Gethp instruction to get the HP (if any) of an object, or MoveTo sets an object to a position of MoveTo, the last operator is the most simpler Indispensable, such as: with or non-sub-multiplexing, bit operators, address operators, domain operators (for object-based), and the like. Such a series of code, is very simple for the upper-layer user, unnecessary attention to the details that do not need attention, while ensuring scalability, if you need a new element, you only need to add a new element. Just like CISC, I don't have to streamize the command, use a complex directive, need to add a complex directive, efficiency? If you want efficiency, you don't play this, go to play the machine code, that is the highest efficiency. This is not prepared to pay attention to efficiency, but pay attention to the efficiency of development. How many games have been developed in China? Most of 2, 3, you can't help it, wait for you to have time to get tortured for 5 years? The only large-scale companies and businesses may be possible in China: Material, human financial resources are impossible. In addition to the acts and operators, more important is data, how to put data - more refers to variables - to each instruction at runtime? The textbooks in this compilation will be mentioned that I haven't worked yet, so I don't write it anymore, wait until I finish it. The beginning of compilation, progressive scan analysis script directive, dispel into the relationship collection of basic elements. If the script is pro process, you need to pay attention to the problem of entering the stack, and if it is an object or object-oriented, it has not been thought about. Finally, all basic elements are stored in a more streamlined data format as a file as the compiled target code. When the game is executed, we preloaded these target code, convert it into a command sequence stored with an array or other data structure. This will not explain the script. When you run to the target code, you only need to provide the corresponding data, then call the for loop to run all instructions.
I used to use 3DGS, I heard that it was compiled script. I was very touched by the interpreter. Later, I slammed the 3DGS file. I feel that 3dgs seems to be compiled as a machine code. . The 3DGS scripts are relatively RISC, and the instructions are simple instructions, so it is very difficult to write, and it is more uncomfortable than Write C. CISC is also a specific practice difference. The former saves the criminals of the script, but it is more laborious, not well grasped, the latter will make the script's headache, but it is better to grasp, and it is easy.
Sketchy, please help me see if there is any omission and look forward to communicating with you.