add PlaySound(soundType, hogGearUID) -- this roundabout way to reference a team seems to be how things are done in lua right now. might need changing in future
authornemo
Sun, 12 Dec 2010 23:52:53 -0500
changeset 4516 ecf012a762d8
parent 4515 9b30be246742
child 4517 0618b31023dc
add PlaySound(soundType, hogGearUID) -- this roundabout way to reference a team seems to be how things are done in lua right now. might need changing in future
hedgewars/uScript.pas
--- a/hedgewars/uScript.pas	Mon Dec 13 04:53:48 2010 +0100
+++ b/hedgewars/uScript.pas	Sun Dec 12 23:52:53 2010 -0500
@@ -492,7 +492,6 @@
 end;
 
 function lc_getclancolor(L : Plua_State) : LongInt; Cdecl;
-var gear : PGear;
 begin
     if lua_gettop(L) <> 1 then
         begin
@@ -850,11 +849,17 @@
 end;
 
 function lc_playsound(L : Plua_State) : LongInt; Cdecl;
+var gear: PGear;
 begin
-    if lua_gettop(L) <> 1 then
-        LuaError('Lua: Wrong number of parameters passed to PlaySound!')
-    else
-        PlaySound(TSound(lua_tointeger(L, 1)));
+    if lua_gettop(L) = 1 then
+        PlaySound(TSound(lua_tointeger(L, 1)))
+    else if lua_gettop(L) = 2 then
+        begin
+        gear:= GearByUID(lua_tointeger(L, 2));
+        if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then
+            PlaySound(TSound(lua_tointeger(L, 1)),gear^.Hedgehog^.Team^.Voicepack)
+        end
+    else LuaError('Lua: Wrong number of parameters passed to PlaySound!');
     lc_playsound:= 0;
 end;