hedgewars/uScript.pas
branch0.9.24
changeset 13687 f60b3998ba56
parent 13398 ae5d6448c5be
child 13688 6c0cf6b9eff8
equal deleted inserted replaced
13620:3561a457c11c 13687:f60b3998ba56
   833 const
   833 const
   834     call = 'AddVisualGear';
   834     call = 'AddVisualGear';
   835     params = 'x, y, visualGearType, state, critical [, layer]';
   835     params = 'x, y, visualGearType, state, critical [, layer]';
   836 begin
   836 begin
   837     uid:= 0;
   837     uid:= 0;
   838     if CheckAndFetchParamCount(L, 5, 6, call, params, n) then
   838     if not(cOnlyStats) and CheckAndFetchParamCount(L, 5, 6, call, params, n) then
   839         begin
   839         begin
   840         s:= LuaToVisualGearTypeOrd(L, 3, call, params);
   840         s:= LuaToVisualGearTypeOrd(L, 3, call, params);
   841         if s >= 0 then
   841         if s >= 0 then
   842             begin
   842             begin
   843             vgt:= TVisualGearType(s);
   843             vgt:= TVisualGearType(s);
   902 
   902 
   903 
   903 
   904 function lc_getvisualgearvalues(L : Plua_State) : LongInt; Cdecl;
   904 function lc_getvisualgearvalues(L : Plua_State) : LongInt; Cdecl;
   905 var vg: PVisualGear;
   905 var vg: PVisualGear;
   906 begin
   906 begin
   907     if CheckLuaParamCount(L, 1, 'GetVisualGearValues', 'vgUid') then
   907     if not(cOnlyStats) and CheckLuaParamCount(L, 1, 'GetVisualGearValues', 'vgUid') then
   908         begin
   908         begin
   909         vg:= VisualGearByUID(Trunc(lua_tonumber(L, 1)));
   909         vg:= VisualGearByUID(Trunc(lua_tonumber(L, 1)));
   910         if vg <> nil then
   910         if vg <> nil then
   911             begin
   911             begin
   912             lua_pushnumber(L, round(vg^.X));
   912             lua_pushnumber(L, round(vg^.X));
   935 end;
   935 end;
   936 
   936 
   937 function lc_setvisualgearvalues(L : Plua_State) : LongInt; Cdecl;
   937 function lc_setvisualgearvalues(L : Plua_State) : LongInt; Cdecl;
   938 var vg : PVisualGear;
   938 var vg : PVisualGear;
   939 begin
   939 begin
       
   940     lc_setvisualgearvalues:= 0;
       
   941 	if cOnlyStats then exit;
   940 // Param count can be 1-11 at present
   942 // Param count can be 1-11 at present
   941 //    if CheckLuaParamCount(L, 11, 'SetVisualGearValues', 'vgUid, X, Y, dX, dY, Angle, Frame, FrameTicks, State, Timer, Tint') then
   943 //    if CheckLuaParamCount(L, 11, 'SetVisualGearValues', 'vgUid, X, Y, dX, dY, Angle, Frame, FrameTicks, State, Timer, Tint') then
   942 //        begin
   944 //        begin
   943         vg:= VisualGearByUID(Trunc(lua_tonumber(L, 1)));
   945         vg:= VisualGearByUID(Trunc(lua_tonumber(L, 1)));
   944         if vg <> nil then
   946         if vg <> nil then
   961                 vg^.State:= Trunc(lua_tonumber(L, 9));
   963                 vg^.State:= Trunc(lua_tonumber(L, 9));
   962             if not lua_isnoneornil(L, 10) then
   964             if not lua_isnoneornil(L, 10) then
   963                 vg^.Timer:= Trunc(lua_tonumber(L, 10));
   965                 vg^.Timer:= Trunc(lua_tonumber(L, 10));
   964             if not lua_isnoneornil(L, 11) then
   966             if not lua_isnoneornil(L, 11) then
   965                 vg^.Tint:= Trunc(lua_tonumber(L, 11))
   967                 vg^.Tint:= Trunc(lua_tonumber(L, 11))
   966             end;
   968             end
   967 //        end
   969 //        end
   968 //    else
   970 //    else
   969 //        lua_pushnil(L); // return value on stack (nil)
   971 //        lua_pushnil(L); // return value on stack (nil)
   970     lc_setvisualgearvalues:= 0
       
   971 end;
   972 end;
   972 
   973 
   973 // so. going to use this to get/set some of the more obscure gear values which were not already exposed elsewhere
   974 // so. going to use this to get/set some of the more obscure gear values which were not already exposed elsewhere
   974 // can keep adding things in the future. isnoneornil makes it safe
   975 // can keep adding things in the future. isnoneornil makes it safe
   975 function lc_getgearvalues(L : Plua_State) : LongInt; Cdecl;
   976 function lc_getgearvalues(L : Plua_State) : LongInt; Cdecl;