Mmorgp large-scale game design and development (client architecture part8 of vegine)

Source: Internet
Author: User
Tags virtual environment

The script module is a topic of much debate in game design. It is because of the advantages and disadvantages of the script itself. In fact, this does not matter. Trade-offs are a skill that people must learn. If you don't make a trade-off, let the trend give you a satisfactory answer. Since the advent of World of Warcraft and legend (World of legends), they have been accompanied by the script (LUA) configuration. The root cause of this is the ease of script, you do not need to worry too much about the changes. I have always insisted on using scripts here. On the other hand, it is the convenience of seamless coupling with other advanced languages, especially C/C ++, it also becomes an important reason for me to choose it.

Code

File environment. h

/** * PAP Engine ( -- ) * $Id environment.h * @link -- for the canonical source repository * @copyright Copyright (c) 2013-2014 viticm( [email protected] ) * @license * @user viticm<[email protected]/[email protected]> * @date 2014-3-19 19:36:10 * @uses vengine script environment module */#ifndef VENGINE_SCRIPT_ENVIRONMENT_H_#define VENGINE_SCRIPT_ENVIRONMENT_H_#include "vengine/config.h"#include "vengine/kernel/node.h"/* use luaplus */namespace LuaPlus {class LuaState;class LuaObject;}; //namespace LuaPlusnamespace vengine_script {class Environment { public:   virtual const char* getname() const = 0;   virtual int32_t executescript(const char* filename) = 0;   virtual void executefunction(const char* functionname,                                 const char* param = NULL) = 0;   virtual void executestring(const char* str) = 0;   virtual LuaPlus::LuaObject* get_luaobject() = 0;};}; //namespace vengine_script#endif //VENGINE_SCRIPT_ENVIRONMENT_H_

File System. h

/*** Pap engine (--) * $ ID system. H * @ link -- For the canonical source repository * @ copyright (c) 2013-2014 viticm ([email protected]) * @ license * @ user viticm <[email protected]/[email protected]> * @ date 2014-3-19 19:49:05 * @ uses vengine script system module */# ifndef vengine_script_system_h _ # define vengine_script_system_h _ # include "vengine/config. H "# include" vengine/kernel/node. H "# include" vengine/script/environment. H "/* use luaplus */namespace luaplus {class luastate; Class luaobject;}; // namespace uses vengine_script {class vengine_api system: Public vengine_kernel: node {kernel (vengine_script_system ); public: Virtual luaplus: luastate * get_luastate () = 0; // obtain the Lua status // create a new script Environment Virtual Environment * newenvironment (const char * Name, const char * filename) = 0; virtual void destroyenvironment (Environment * Environment) = 0; Virtual Environment * getenvironment (const char * Name) = 0 ;};}; // namespace vengine_script # endif // vengine_script_script_h _
Brief Introduction

What is the environment? Why is there an environment?

Environment is the place on which humans depend to survive. The environment determines many things, especially what you can do. To put it simply, such as the environment in which we live, the Health Care and shopping malls around you are all part of the environment, but some places do not exist, which leads to different environments, what you can do or what you want to do in different environments will change a lot. If you want to eat a bowl of ramen noodles, if you have such factors in your life environment, you can eat it, whether it is your own or go to the restaurant. However, if your environment does not provide the factors you need, you will not be able to eat a bowl of ramen.

To eat a bowl of ramen, you must have environmental factors to eat ramen. Naturally, to run a piece of script code, you need to have an environment for running the script code. Of course, this environment may be the environment where you cannot eat the ramen, because we can choose the environment, it's just like we ran from a place in your life to a very long place to eat a bowl of ramen.

What is environment creation? Why the environment?

After the above example, I want you to know why you need such an environment, and the code is a virtual world. Your environment can be created with your mind. Does it feel better than your life?

Summary

Whether it's a state machine or a running environment, what the script engine can offer you is just a way of execution. Lua script has been developed for so many years and is favored by everyone for its small size and outstanding performance. If you are free, I hope you can take a look at this knowledge. I will not talk about any mechanism of Lua here.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.