changeset 9988 | 317d46a2afd2 |
parent 9987 | 8f07b47a641b |
child 9998 | 736015b847e3 |
9987:8f07b47a641b | 9988:317d46a2afd2 |
---|---|
104 |
104 |
105 procedure LuaError(s: shortstring); |
105 procedure LuaError(s: shortstring); |
106 begin |
106 begin |
107 WriteLnToConsole(s); |
107 WriteLnToConsole(s); |
108 AddChatString(#5 + s); |
108 AddChatString(#5 + s); |
109 if cTestLua then |
|
110 halt(rtnTestLuaErr); |
|
109 end; |
111 end; |
110 |
112 |
111 procedure LuaParameterCountError(call, paramsyntax: shortstring; wrongcount: LongInt); |
113 procedure LuaParameterCountError(call, paramsyntax: shortstring; wrongcount: LongInt); |
112 begin |
114 begin |
113 // TODO: i18n? |
115 // TODO: i18n? |
1980 if lua_gettop(L) <> 4 then |
1982 if lua_gettop(L) <> 4 then |
1981 LuaParameterCountError('DeclareAchievement', 'achievementId, teamname, location, value', lua_gettop(L)) |
1983 LuaParameterCountError('DeclareAchievement', 'achievementId, teamname, location, value', lua_gettop(L)) |
1982 else |
1984 else |
1983 declareAchievement(lua_tostring(L, 1), lua_tostring(L, 2), lua_tostring(L, 3), lua_tointeger(L, 4)); |
1985 declareAchievement(lua_tostring(L, 1), lua_tostring(L, 2), lua_tostring(L, 3), lua_tointeger(L, 4)); |
1984 lc_declareachievement:= 0 |
1986 lc_declareachievement:= 0 |
1987 end; |
|
1988 |
|
1989 // stuff for testing the lua API |
|
1990 function lc_endluatest(L : Plua_State) : LongInt; Cdecl; |
|
1991 begin |
|
1992 if lua_gettop(L) <> 1 then |
|
1993 begin |
|
1994 LuaParameterCountError('EndLuaAPITest', 'LUA_API_TEST_SUCCESSFUL or LUA_API_TEST_FAILED', lua_gettop(L)); |
|
1995 lua_pushnil(L); |
|
1996 end |
|
1997 else |
|
1998 begin |
|
1999 halt(lua_tointeger(L, 1)); |
|
2000 lc_endluatest:= 0; |
|
2001 end; |
|
1985 end; |
2002 end; |
1986 /////////////////// |
2003 /////////////////// |
1987 |
2004 |
1988 procedure ScriptPrintStack; |
2005 procedure ScriptPrintStack; |
1989 var n, i : LongInt; |
2006 var n, i : LongInt; |
2629 |
2646 |
2630 lua_register(luaState, _P'SetGearAIHints', @lc_setaihintsongear); |
2647 lua_register(luaState, _P'SetGearAIHints', @lc_setaihintsongear); |
2631 lua_register(luaState, _P'HedgewarsScriptLoad', @lc_hedgewarsscriptload); |
2648 lua_register(luaState, _P'HedgewarsScriptLoad', @lc_hedgewarsscriptload); |
2632 lua_register(luaState, _P'DeclareAchievement', @lc_declareachievement); |
2649 lua_register(luaState, _P'DeclareAchievement', @lc_declareachievement); |
2633 |
2650 |
2651 if cTestLua then |
|
2652 begin |
|
2653 ScriptSetInteger('TEST_SUCCESSFUL' ,rtnTestSuccess); |
|
2654 ScriptSetInteger('TEST_FAILED' ,rtnTestFailed); |
|
2655 lua_register(luaState, _P'EndLuaTest', @lc_endluatest); |
|
2656 end; |
|
2634 |
2657 |
2635 ScriptClearStack; // just to be sure stack is empty |
2658 ScriptClearStack; // just to be sure stack is empty |
2636 ScriptLoaded:= false; |
2659 ScriptLoaded:= false; |
2637 end; |
2660 end; |
2638 |
2661 |