腳本引擎RapScript V0.0.0.1發(fā)布
這是最近完成的RapScript的0.0.0.1版的源代碼。
這份代碼目前比較糟糕,有點亂,而且沒有錯誤處理,但開源是一種習(xí)慣。。。
先介紹一下怎么用:
把RapScript.h RapScript.cpp RapStack.h加入工程,然后在自己的main.cpp里加入
XXX是對象名,可以自己取。
關(guān)于函數(shù)互交:
比如說,你在C++中寫了一個函數(shù):
腳本就會執(zhí)行了。
說明一下:
1.在腳本中寫命令時要這樣:test(a;b;);//我偷懶了
2.所有變量用前必須聲明(如int a;string b;)
目前只支持int 和 string
3.Bug超多。
4.if()和 for()等暫時不支持
5.如果你愿意修改源代碼,只要合理,就會被采用,名字也會加入Author里。。。
下載RapScript V0.0.0.1源代碼
┏━┓ ┏━━┓ ┏┓
┃┃┣━┳━┫━━╋━┳┳╋╋━┳━━┓
┃ ┫━┃┃┣━━┃┣┫┏┫┃┃┣┓┏┛
┗┻┻┻┫┏┻━━┻━┻┛┗┫┏┛┗┛
┗┛ ┗┛
這份代碼目前比較糟糕,有點亂,而且沒有錯誤處理,但開源是一種習(xí)慣。。。
先介紹一下怎么用:
把RapScript.h RapScript.cpp RapStack.h加入工程,然后在自己的main.cpp里加入
#include "RapScript.h"
RapScript XXX;
RapScript XXX;
XXX是對象名,可以自己取。
關(guān)于函數(shù)互交:
比如說,你在C++中寫了一個函數(shù):
void test(int a,int b)
{
cout <<"In void test(int a,int b) a:"<<a<<" b: "<<b<<endl;
}
要調(diào)用它,要在寫一個:{
cout <<"In void test(int a,int b) a:"<<a<<" b: "<<b<<endl;
}
void rap_test()
{
int a=rapscript.para[0].v_int;//參數(shù)一
int b=rapscript.para[1].v_int;//參數(shù)二
test(a,b);
}
然后在合適的位置(比如int main()中)加入{
int a=rapscript.para[0].v_int;//參數(shù)一
int b=rapscript.para[1].v_int;//參數(shù)二
test(a,b);
}
rapscript.tmp_cmd.cmd_name="test";
rapscript.tmp_cmd.v_type=rapscript.CMD_VOID;
rapscript.tmp_cmd.fp_void=rap_test;
rapscript.cmd_list.push_back(rapscript.tmp_cmd);
調(diào)用rapscript.run_rap();rapscript.tmp_cmd.v_type=rapscript.CMD_VOID;
rapscript.tmp_cmd.fp_void=rap_test;
rapscript.cmd_list.push_back(rapscript.tmp_cmd);
腳本就會執(zhí)行了。
說明一下:
1.在腳本中寫命令時要這樣:test(a;b;);//我偷懶了
2.所有變量用前必須聲明(如int a;string b;)
目前只支持int 和 string
3.Bug超多。
4.if()和 for()等暫時不支持
5.如果你愿意修改源代碼,只要合理,就會被采用,名字也會加入Author里。。。
下載RapScript V0.0.0.1源代碼
┏━┓ ┏━━┓ ┏┓
┃┃┣━┳━┫━━╋━┳┳╋╋━┳━━┓
┃ ┫━┃┃┣━━┃┣┫┏┫┃┃┣┓┏┛
┗┻┻┻┫┏┻━━┻━┻┛┗┫┏┛┗┛
┗┛ ┗┛
posted on 2008-08-10 11:05 Bill Hsu 閱讀(1681) 評論(4) 編輯 收藏 引用 所屬分類: Game Dev