diff options
author | Aaron Marks <nymacro@gmail.com> | 2005-05-13 06:15:36 +0000 |
---|---|---|
committer | Aaron Marks <nymacro@gmail.com> | 2005-05-13 06:15:36 +0000 |
commit | c82a80e5c2ad81eb7532f849f1f4c805d9337e7d (patch) | |
tree | 46e48f5529beebbea47a737b48dbb3c2b8fdbbaf | |
parent | 09443761bc3a8a194856d74d827a83b8aa499a1e (diff) | |
download | manaserv-c82a80e5c2ad81eb7532f849f1f4c805d9337e7d.tar.gz manaserv-c82a80e5c2ad81eb7532f849f1f4c805d9337e7d.tar.bz2 manaserv-c82a80e5c2ad81eb7532f849f1f4c805d9337e7d.tar.xz manaserv-c82a80e5c2ad81eb7532f849f1f4c805d9337e7d.zip |
Committed stuff i forgot to commit last night ("Standard Script Lib")
-rw-r--r-- | docs/scripting.txt | 1 | ||||
-rw-r--r-- | src/script-squirrel.cpp | 102 |
2 files changed, 92 insertions, 11 deletions
diff --git a/docs/scripting.txt b/docs/scripting.txt index 8786e7a2..a70ab592 100644 --- a/docs/scripting.txt +++ b/docs/scripting.txt @@ -34,6 +34,7 @@ Item Scripting: void use(void) - Called when player uses the item. Public Variables: + string name - Name of item. int type - Type of item (weapon, armor, usable, etc.) *Special Properties* diff --git a/src/script-squirrel.cpp b/src/script-squirrel.cpp index cb3d7601..901ad9a9 100644 --- a/src/script-squirrel.cpp +++ b/src/script-squirrel.cpp @@ -1,6 +1,8 @@ #include "script-squirrel.h" #include <cstring> +void registerStdLib(HSQUIRRELVM); + /* * printfunc - Print function for Squirrel */ @@ -137,15 +139,6 @@ int testFunc(HSQUIRRELVM v) return 1; } -/* - * Another test function - */ -int worldTime(HSQUIRRELVM v) -{ - sq_pushinteger(v, 10); - return 1; -} - /******/ ScriptSquirrel::ScriptSquirrel(const std::string &file) : @@ -160,8 +153,7 @@ ScriptSquirrel::ScriptSquirrel(const std::string &file) : std::cerr << "Error: ScriptSquirrel: could not execute " << scriptName << std::endl; } else { - functionRegister(vm, testFunc, "printargs"); - functionRegister(vm, worldTime, "worldtime"); + registerStdLib(vm); functionCall(vm, "", NULL); functionCall(vm, "init", NULL); @@ -191,3 +183,91 @@ void ScriptSquirrel::message(char *msg) functionCall(vm, "message", "s", msg); } +/******************************/ +/* + * Standard Library Functions + */ +int getName(HSQUIRRELVM v) +{ + sq_pushstring(v, "no name", -1); + return 1; +} + +int getX(HSQUIRRELVM v) +{ + sq_pushinteger(v, 0); + return 1; +} + +int getY(HSQUIRRELVM v) +{ + sq_pushinteger(v, 0); + return 1; +} + +int getMap(HSQUIRRELVM v) +{ + sq_pushstring(v, "map1.map", -1); + return 1; +} + +int getLevel(HSQUIRRELVM v) +{ + sq_pushinteger(v, 0); + return 1; +} + +int getHealth(HSQUIRRELVM v) +{ + sq_pushinteger(v, 0); + return 1; +} + +int getMaxHealth(HSQUIRRELVM v) +{ + sq_pushinteger(v, 0); + return 1; +} + +int getAttack(HSQUIRRELVM v) +{ + sq_pushinteger(v, 0); + return 1; +} + +int getDefense(HSQUIRRELVM v) +{ + sq_pushinteger(v, 0); + return 1; +} + +int getLuck(HSQUIRRELVM v) +{ + sq_pushinteger(v, 0); + return 1; +} + +int getVitality(HSQUIRRELVM v) +{ + sq_pushinteger(v, 0); + return 1; +} + +/* + * Register standard functions for game script + */ +void registerStdLib(HSQUIRRELVM v) +{ + functionRegister(v, getName, "getName"); + functionRegister(v, getX, "getX"); + functionRegister(v, getY, "getY"); + functionRegister(v, getMap, "getMap"); + functionRegister(v, getLevel, "getLevel"); + functionRegister(v, getHealth, "getHealth"); + functionRegister(v, getMaxHealth, "getMaxHealth"); + functionRegister(v, getAttack, "getAttack"); + functionRegister(v, getDefense, "getDefense"); + functionRegister(v, getLuck, "getLuck"); + functionRegister(v, getVitality, "getVitality"); +} + |