一直想找一个跨平台的脚本,发现AngelScript简单易用,把我的实践分享给大家,希望能对关注AS的同学有所帮助。
我是用vc6编译的as2.2,把它编译成了一个静态库。
你看一下我的vc6工程中的注释就能明白as的用法。完整的vc6工程见附件,咦,怎么找不到如何上传附件啊。只好把我所有的代码贴在下面,但是你要自己到as的官网上下载他的源码,自己搭建环境了。这些代码也仅供参考一下了。
http://www.angelcode.com/angelscript/
// as_1.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "angelscript.h"
#include "scriptstdstring/scriptstdstring.h"
#include "scriptbuilder/scriptbuilder.h"
using namespace std;
//回调函数,这个函数将收集as的错误信息,并输出到指定文件
void MessageCallback(const asSMessageInfo *msg, void *param)
{
const char *type = "ERR ";
if( msg->type == asMSGTYPE_WARNING )
type = "WARN&#