add optional state parameter to hogsay
authornemo
Tue, 14 Dec 2010 20:41:33 -0500
changeset 4533 8d35c3e0e6ba
parent 4532 d0efc40f609b
child 4534 395278890955
add optional state parameter to hogsay
hedgewars/uScript.pas
--- a/hedgewars/uScript.pas	Tue Dec 14 19:36:12 2010 -0500
+++ b/hedgewars/uScript.pas	Tue Dec 14 20:41:33 2010 -0500
@@ -674,17 +674,17 @@
 function lc_hogsay(L : Plua_State) : LongInt; Cdecl;
 var gear : PGear;
    vgear : PVisualGear;
+       s : LongWord;
 begin
-    if lua_gettop(L) <> 3 then
-        begin
-        LuaError('Lua: Wrong number of parameters passed to HogSay!');
-        end
-    else
+    if lua_gettop(L) = 4 then s:= lua_tointeger(L, 4)
+    else s:= 0;
+
+    if (lua_gettop(L) = 4) or (lua_gettop(L) = 3) then
         begin
         gear:= GearByUID(lua_tointeger(L, 1));
         if gear <> nil then
             begin
-            vgear:= AddVisualGear(0, 0, vgtSpeechBubble);
+            vgear:= AddVisualGear(0, 0, vgtSpeechBubble, s, true);
             if vgear <> nil then
                begin
                vgear^.Text:= lua_tostring(L, 2);
@@ -693,7 +693,8 @@
                if (vgear^.FrameTicks < 1) or (vgear^.FrameTicks > 3) then vgear^.FrameTicks:= 1;
                end;
             end
-        end;
+        end
+    else LuaError('Lua: Wrong number of parameters passed to HogSay!');
     lc_hogsay:= 0
 end;