--- a/hedgewars/uScript.pas Thu Jun 12 14:11:22 2014 +0200
+++ b/hedgewars/uScript.pas Thu Jun 12 14:42:48 2014 +0200
@@ -119,10 +119,16 @@
LuaError(call + ': ' + error + ' function syntax: ' + call + ' ( ' + paramsyntax + ' )');
end;
+procedure LuaParameterCountError(expected, call, paramsyntax: shortstring; wrongcount: LongInt); inline;
+begin
+ // TODO: i18n?
+ LuaCallError('Wrong number of parameters! (is: ' + inttostr(wrongcount) + ', should be: '+ expected + ')', call, paramsyntax);
+end;
+
+// TODO remove this precedure after all references have been changed to one of the checks below
procedure LuaParameterCountError(call, paramsyntax: shortstring; wrongcount: LongInt); inline;
begin
- // TODO: i18n?
- LuaCallError('Wrong number of parameters (' + inttostr(wrongcount) + ')!', call, paramsyntax);
+ LuaCallError('Wrong number of parameters! (actual: ' + inttostr(wrongcount) + ')', call, paramsyntax);
end;
// compare with allowed count
@@ -132,7 +138,7 @@
c:= lua_gettop(L);
if c <> count then
begin
- LuaParameterCountError(call, paramsyntax, c);
+ LuaParameterCountError('exactly ' + inttostr(count), call, paramsyntax, c);
exit(false);
end;
@@ -145,7 +151,7 @@
actual:= lua_gettop(L);
if (actual <> count1) and (actual <> count2) then
begin
- LuaParameterCountError(call, paramsyntax, actual);
+ LuaParameterCountError('either ' + inttostr(count1) + ' or ' + inttostr(count2), call, paramsyntax, actual);
exit(false);
end;
@@ -158,7 +164,7 @@
actual:= lua_gettop(L);
if (actual < minCount) then
begin
- LuaParameterCountError(call, paramsyntax, actual);
+ LuaParameterCountError(inttostr(minCount) + ' or more', call, paramsyntax, actual);
exit(false);
end;