286 end; |
286 end; |
287 |
287 |
288 function LuaToHogEffectOrd(L : Plua_State; i: LongInt; call, paramsyntax: shortstring): LongInt; inline; |
288 function LuaToHogEffectOrd(L : Plua_State; i: LongInt; call, paramsyntax: shortstring): LongInt; inline; |
289 begin |
289 begin |
290 if lua_isnoneornil(L, i) then i:= -1 |
290 if lua_isnoneornil(L, i) then i:= -1 |
291 else i:= lua_tointeger(L, i); |
291 else i:= Trunc(lua_tonumber(L, i)); |
292 if (i < ord(Low(THogEffect))) or (i > ord(High(THogEffect))) then |
292 if (i < ord(Low(THogEffect))) or (i > ord(High(THogEffect))) then |
293 begin |
293 begin |
294 LuaCallError('Invalid gear type!', call, paramsyntax); |
294 LuaCallError('Invalid effect type!', call, paramsyntax); |
295 LuaToHogEffectOrd:= -1; |
295 LuaToHogEffectOrd:= -1; |
296 end |
296 end |
297 else |
297 else |
298 LuaToHogEffectOrd:= i; |
298 LuaToHogEffectOrd:= i; |
299 end; |
299 end; |
300 |
300 |
301 function LuaToCapGroupOrd(L : Plua_State; i: LongInt; call, paramsyntax: shortstring): LongInt; inline; |
301 function LuaToCapGroupOrd(L : Plua_State; i: LongInt; call, paramsyntax: shortstring): LongInt; inline; |
302 begin |
302 begin |
303 if lua_isnoneornil(L, i) then i:= -1 |
303 if lua_isnoneornil(L, i) then i:= -1 |
304 else i:= lua_tointeger(L, i); |
304 else i:= Trunc(lua_tonumber(L, i)); |
305 if (i < ord(Low(TCapGroup))) or (i > ord(High(TCapGroup))) then |
305 if (i < ord(Low(TCapGroup))) or (i > ord(High(TCapGroup))) then |
306 begin |
306 begin |
307 LuaCallError('Invalid capgroup type!', call, paramsyntax); |
307 LuaCallError('Invalid capgroup type!', call, paramsyntax); |
308 LuaToCapGroupOrd:= -1; |
308 LuaToCapGroupOrd:= -1; |
309 end |
309 end |
348 // use as return value the number of variables pushed back to the lua script |
348 // use as return value the number of variables pushed back to the lua script |
349 |
349 |
350 function lc_band(L: PLua_State): LongInt; Cdecl; |
350 function lc_band(L: PLua_State): LongInt; Cdecl; |
351 begin |
351 begin |
352 if CheckLuaParamCount(L, 2, 'band', 'value1, value2') then |
352 if CheckLuaParamCount(L, 2, 'band', 'value1, value2') then |
353 lua_pushinteger(L, lua_tointeger(L, 2) and lua_tointeger(L, 1)) |
353 lua_pushnumber(L, Trunc(lua_tonumber(L, 2)) and Trunc(lua_tonumber(L, 1))) |
354 else |
354 else |
355 lua_pushnil(L); |
355 lua_pushnil(L); |
356 lc_band := 1; |
356 lc_band := 1; |
357 end; |
357 end; |
358 |
358 |
359 function lc_bor(L: PLua_State): LongInt; Cdecl; |
359 function lc_bor(L: PLua_State): LongInt; Cdecl; |
360 begin |
360 begin |
361 if CheckLuaParamCount(L, 2, 'bor', 'value1, value2') then |
361 if CheckLuaParamCount(L, 2, 'bor', 'value1, value2') then |
362 lua_pushinteger(L, lua_tointeger(L, 2) or lua_tointeger(L, 1)) |
362 lua_pushnumber(L, Trunc(lua_tonumber(L, 2)) or Trunc(lua_tonumber(L, 1))) |
363 else |
363 else |
364 lua_pushnil(L); |
364 lua_pushnil(L); |
365 lc_bor := 1; |
365 lc_bor := 1; |
366 end; |
366 end; |
367 |
367 |
368 function lc_bnot(L: PLua_State): LongInt; Cdecl; |
368 function lc_bnot(L: PLua_State): LongInt; Cdecl; |
369 begin |
369 begin |
370 if CheckLuaParamCount(L, 1, 'bnot', 'value') then |
370 if CheckLuaParamCount(L, 1, 'bnot', 'value') then |
371 lua_pushinteger(L, (not lua_tointeger(L, 1))) |
371 lua_pushnumber(L, (not Trunc(lua_tonumber(L, 1)))) |
372 else |
372 else |
373 lua_pushnil(L); |
373 lua_pushnil(L); |
374 lc_bnot := 1; |
374 lc_bnot := 1; |
375 end; |
375 end; |
376 |
376 |
377 function lc_div(L: PLua_State): LongInt; Cdecl; |
377 function lc_div(L: PLua_State): LongInt; Cdecl; |
378 begin |
378 begin |
379 if CheckLuaParamCount(L, 2, 'div', 'dividend, divisor') then |
379 if CheckLuaParamCount(L, 2, 'div', 'dividend, divisor') then |
380 lua_pushinteger(L, lua_tointeger(L, 1) div lua_tointeger(L, 2)) |
380 lua_pushnumber(L, Trunc(lua_tonumber(L, 1)) div Trunc(lua_tonumber(L, 2))) |
381 else |
381 else |
382 lua_pushnil(L); |
382 lua_pushnil(L); |
383 lc_div := 1; |
383 lc_div := 1; |
384 end; |
384 end; |
385 |
385 |
386 function lc_getinputmask(L : Plua_State) : LongInt; Cdecl; |
386 function lc_getinputmask(L : Plua_State) : LongInt; Cdecl; |
387 begin |
387 begin |
388 if CheckLuaParamCount(L, 0, 'GetInputMask', '') then |
388 if CheckLuaParamCount(L, 0, 'GetInputMask', '') then |
389 lua_pushinteger(L, InputMask); |
389 lua_pushnumber(L, InputMask); |
390 lc_getinputmask:= 1 |
390 lc_getinputmask:= 1 |
391 end; |
391 end; |
392 |
392 |
393 function lc_setinputmask(L : Plua_State) : LongInt; Cdecl; |
393 function lc_setinputmask(L : Plua_State) : LongInt; Cdecl; |
394 begin |
394 begin |
395 if CheckLuaParamCount(L, 1, 'SetInputMask', 'mask') then |
395 if CheckLuaParamCount(L, 1, 'SetInputMask', 'mask') then |
396 InputMask:= lua_tointeger(L, 1); |
396 InputMask:= Trunc(lua_tonumber(L, 1)); |
397 lc_setinputmask:= 0 |
397 lc_setinputmask:= 0 |
398 end; |
398 end; |
399 |
399 |
400 function lc_writelntoconsole(L : Plua_State) : LongInt; Cdecl; |
400 function lc_writelntoconsole(L : Plua_State) : LongInt; Cdecl; |
401 begin |
401 begin |
537 end; |
537 end; |
538 |
538 |
539 function lc_showmission(L : Plua_State) : LongInt; Cdecl; |
539 function lc_showmission(L : Plua_State) : LongInt; Cdecl; |
540 begin |
540 begin |
541 if CheckLuaParamCount(L, 5, 'ShowMission', 'caption, subcaption, text, icon, time') then |
541 if CheckLuaParamCount(L, 5, 'ShowMission', 'caption, subcaption, text, icon, time') then |
542 ShowMission(lua_tostringA(L, 1), lua_tostringA(L, 2), lua_tostringA(L, 3), lua_tointeger(L, 4), lua_tointeger(L, 5)); |
542 ShowMission(lua_tostringA(L, 1), lua_tostringA(L, 2), lua_tostringA(L, 3), Trunc(lua_tonumber(L, 4)), Trunc(lua_tonumber(L, 5))); |
543 lc_showmission:= 0; |
543 lc_showmission:= 0; |
544 end; |
544 end; |
545 |
545 |
546 function lc_hidemission(L : Plua_State) : LongInt; Cdecl; |
546 function lc_hidemission(L : Plua_State) : LongInt; Cdecl; |
547 begin |
547 begin |
548 L:= L; // avoid compiler hint |
548 L:= L; // avoid compiler hint |
549 HideMission; |
549 HideMission; |
550 lc_hidemission:= 0; |
550 lc_hidemission:= 0; |
551 end; |
551 end; |
552 |
552 |
|
553 function lc_setammotexts(L : Plua_State) : LongInt; Cdecl; |
|
554 const |
|
555 call = 'SetAmmoTexts'; |
|
556 params = 'ammoType, name, caption, description'; |
|
557 begin |
|
558 if CheckLuaParamCount(L, 4, call, params) then |
|
559 SetAmmoTexts(TAmmoType(LuaToAmmoTypeOrd(L, 1, call, params)), lua_tostringA(L, 2), lua_tostringA(L, 3), lua_tostringA(L, 4)); |
|
560 lc_setammotexts:= 0; |
|
561 end; |
|
562 |
|
563 function lc_setammodescriptionappendix(L : Plua_State) : LongInt; Cdecl; |
|
564 const |
|
565 call = 'SetAmmoDescriptionAppendix'; |
|
566 params = 'ammoType, descAppend'; |
|
567 var |
|
568 ammoType: TAmmoType; |
|
569 descAppend: ansistring; |
|
570 begin |
|
571 if CheckLuaParamCount(L, 2, call, params) then |
|
572 begin |
|
573 ammoType := TAmmoType(LuaToAmmoTypeOrd(L, 1, call, params)); |
|
574 descAppend := lua_tostringA(L, 2); |
|
575 trluaammoa[Ammoz[ammoType].NameId] := descAppend; |
|
576 end; |
|
577 lc_setammodescriptionappendix := 0; |
|
578 end; |
|
579 |
553 function lc_enablegameflags(L : Plua_State) : LongInt; Cdecl; |
580 function lc_enablegameflags(L : Plua_State) : LongInt; Cdecl; |
554 var i, n : integer; |
581 var i, n : integer; |
555 begin |
582 begin |
556 // can have 1 or more arguments |
583 // can have 1 or more arguments |
557 if CheckAndFetchLuaParamMinCount(L, 1, 'EnableGameFlags', 'gameFlag, ... ', n) then |
584 if CheckAndFetchLuaParamMinCount(L, 1, 'EnableGameFlags', 'gameFlag, ... ', n) then |
558 begin |
585 begin |
559 for i:= 1 to n do |
586 for i:= 1 to n do |
560 GameFlags := GameFlags or LongWord(lua_tointeger(L, i)); |
587 GameFlags := GameFlags or LongWord(Trunc(lua_tonumber(L, i))); |
561 ScriptSetInteger('GameFlags', GameFlags); |
588 ScriptSetInteger('GameFlags', GameFlags); |
562 end; |
589 end; |
563 lc_enablegameflags:= 0; |
590 lc_enablegameflags:= 0; |
564 end; |
591 end; |
565 |
592 |
636 function lc_spawnfakehealthcrate(L: Plua_State) : LongInt; Cdecl; |
663 function lc_spawnfakehealthcrate(L: Plua_State) : LongInt; Cdecl; |
637 var gear: PGear; |
664 var gear: PGear; |
638 begin |
665 begin |
639 if CheckLuaParamCount(L, 4,'SpawnFakeHealthCrate', 'x, y, explode, poison') then |
666 if CheckLuaParamCount(L, 4,'SpawnFakeHealthCrate', 'x, y, explode, poison') then |
640 begin |
667 begin |
641 gear := SpawnFakeCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), |
668 gear := SpawnFakeCrateAt(Trunc(lua_tonumber(L, 1)), Trunc(lua_tonumber(L, 2)), |
642 HealthCrate, lua_toboolean(L, 3), lua_toboolean(L, 4)); |
669 HealthCrate, lua_toboolean(L, 3), lua_toboolean(L, 4)); |
643 if gear <> nil then |
670 if gear <> nil then |
644 lua_pushinteger(L, gear^.uid) |
671 lua_pushnumber(L, gear^.uid) |
645 else lua_pushnil(L) |
672 else lua_pushnil(L) |
646 end |
673 end |
647 else |
674 else |
648 lua_pushnil(L); |
675 lua_pushnil(L); |
649 lc_spawnfakehealthcrate := 1; |
676 lc_spawnfakehealthcrate := 1; |
652 function lc_spawnfakeammocrate(L: PLua_State): LongInt; Cdecl; |
679 function lc_spawnfakeammocrate(L: PLua_State): LongInt; Cdecl; |
653 var gear: PGear; |
680 var gear: PGear; |
654 begin |
681 begin |
655 if CheckLuaParamCount(L, 4,'SpawnFakeAmmoCrate', 'x, y, explode, poison') then |
682 if CheckLuaParamCount(L, 4,'SpawnFakeAmmoCrate', 'x, y, explode, poison') then |
656 begin |
683 begin |
657 gear := SpawnFakeCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), |
684 gear := SpawnFakeCrateAt(Trunc(lua_tonumber(L, 1)), Trunc(lua_tonumber(L, 2)), |
658 AmmoCrate, lua_toboolean(L, 3), lua_toboolean(L, 4)); |
685 AmmoCrate, lua_toboolean(L, 3), lua_toboolean(L, 4)); |
659 if gear <> nil then |
686 if gear <> nil then |
660 lua_pushinteger(L, gear^.uid) |
687 lua_pushnumber(L, gear^.uid) |
661 else lua_pushnil(L) |
688 else lua_pushnil(L) |
662 end |
689 end |
663 else |
690 else |
664 lua_pushnil(L); |
691 lua_pushnil(L); |
665 lc_spawnfakeammocrate := 1; |
692 lc_spawnfakeammocrate := 1; |
668 function lc_spawnfakeutilitycrate(L: PLua_State): LongInt; Cdecl; |
695 function lc_spawnfakeutilitycrate(L: PLua_State): LongInt; Cdecl; |
669 var gear: PGear; |
696 var gear: PGear; |
670 begin |
697 begin |
671 if CheckLuaParamCount(L, 4,'SpawnFakeUtilityCrate', 'x, y, explode, poison') then |
698 if CheckLuaParamCount(L, 4,'SpawnFakeUtilityCrate', 'x, y, explode, poison') then |
672 begin |
699 begin |
673 gear := SpawnFakeCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), |
700 gear := SpawnFakeCrateAt(Trunc(lua_tonumber(L, 1)), Trunc(lua_tonumber(L, 2)), |
674 UtilityCrate, lua_toboolean(L, 3), lua_toboolean(L, 4)); |
701 UtilityCrate, lua_toboolean(L, 3), lua_toboolean(L, 4)); |
675 if gear <> nil then |
702 if gear <> nil then |
676 lua_pushinteger(L, gear^.uid) |
703 lua_pushnumber(L, gear^.uid) |
677 else lua_pushnil(L) |
704 else lua_pushnil(L) |
678 end |
705 end |
679 else |
706 else |
680 lua_pushnil(L); |
707 lua_pushnil(L); |
681 lc_spawnfakeutilitycrate := 1; |
708 lc_spawnfakeutilitycrate := 1; |
686 var health, n: LongInt; |
713 var health, n: LongInt; |
687 begin |
714 begin |
688 if CheckAndFetchParamCount(L, 2, 3, 'SpawnHealthCrate', 'x, y [, health]', n) then |
715 if CheckAndFetchParamCount(L, 2, 3, 'SpawnHealthCrate', 'x, y [, health]', n) then |
689 begin |
716 begin |
690 if n = 3 then |
717 if n = 3 then |
691 health:= lua_tointeger(L, 3) |
718 health:= Trunc(lua_tonumber(L, 3)) |
692 else |
719 else |
693 health:= cHealthCaseAmount; |
720 health:= cHealthCaseAmount; |
694 gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), HealthCrate, health, 0); |
721 gear := SpawnCustomCrateAt(Trunc(lua_tonumber(L, 1)), Trunc(lua_tonumber(L, 2)), HealthCrate, health, 0); |
695 if gear <> nil then |
722 if gear <> nil then |
696 lua_pushinteger(L, gear^.uid) |
723 lua_pushnumber(L, gear^.uid) |
697 else lua_pushnil(L); |
724 else lua_pushnil(L); |
698 end |
725 end |
699 else |
726 else |
700 lua_pushnil(L); |
727 lua_pushnil(L); |
701 lc_spawnhealthcrate := 1; |
728 lc_spawnhealthcrate := 1; |
706 n : LongInt; |
733 n : LongInt; |
707 begin |
734 begin |
708 if CheckAndFetchParamCount(L, 3, 4, 'SpawnAmmoCrate', 'x, y, content [, amount]', n) then |
735 if CheckAndFetchParamCount(L, 3, 4, 'SpawnAmmoCrate', 'x, y, content [, amount]', n) then |
709 begin |
736 begin |
710 if n = 3 then |
737 if n = 3 then |
711 gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), AmmoCrate, lua_tointeger(L, 3), 0) |
738 gear := SpawnCustomCrateAt(Trunc(lua_tonumber(L, 1)), Trunc(lua_tonumber(L, 2)), AmmoCrate, Trunc(lua_tonumber(L, 3)), 0) |
712 else gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), AmmoCrate, lua_tointeger(L, 3), lua_tointeger(L, 4)); |
739 else gear := SpawnCustomCrateAt(Trunc(lua_tonumber(L, 1)), Trunc(lua_tonumber(L, 2)), AmmoCrate, Trunc(lua_tonumber(L, 3)), Trunc(lua_tonumber(L, 4))); |
713 if gear <> nil then |
740 if gear <> nil then |
714 lua_pushinteger(L, gear^.uid) |
741 lua_pushnumber(L, gear^.uid) |
715 else lua_pushnil(L); |
742 else lua_pushnil(L); |
716 end |
743 end |
717 else |
744 else |
718 lua_pushnil(L); |
745 lua_pushnil(L); |
719 lc_spawnammocrate := 1; |
746 lc_spawnammocrate := 1; |
724 n : LongInt; |
751 n : LongInt; |
725 begin |
752 begin |
726 if CheckAndFetchParamCount(L, 3, 4, 'SpawnUtilityCrate', 'x, y, content [, amount]', n) then |
753 if CheckAndFetchParamCount(L, 3, 4, 'SpawnUtilityCrate', 'x, y, content [, amount]', n) then |
727 begin |
754 begin |
728 if n = 3 then |
755 if n = 3 then |
729 gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), UtilityCrate, lua_tointeger(L, 3), 0) |
756 gear := SpawnCustomCrateAt(Trunc(lua_tonumber(L, 1)), Trunc(lua_tonumber(L, 2)), UtilityCrate, Trunc(lua_tonumber(L, 3)), 0) |
730 else gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), UtilityCrate, lua_tointeger(L, 3), lua_tointeger(L, 4)); |
757 else gear := SpawnCustomCrateAt(Trunc(lua_tonumber(L, 1)), Trunc(lua_tonumber(L, 2)), UtilityCrate, Trunc(lua_tonumber(L, 3)), Trunc(lua_tonumber(L, 4))); |
731 if gear <> nil then |
758 if gear <> nil then |
732 lua_pushinteger(L, gear^.uid) |
759 lua_pushnumber(L, gear^.uid) |
733 else lua_pushnil(L); |
760 else lua_pushnil(L); |
734 end |
761 end |
735 else |
762 else |
736 lua_pushnil(L); |
763 lua_pushnil(L); |
737 lc_spawnutilitycrate := 1; |
764 lc_spawnutilitycrate := 1; |
750 begin |
777 begin |
751 t:= LuaToGearTypeOrd(L, 3, call, params); |
778 t:= LuaToGearTypeOrd(L, 3, call, params); |
752 if t >= 0 then |
779 if t >= 0 then |
753 begin |
780 begin |
754 gt:= TGearType(t); |
781 gt:= TGearType(t); |
755 x:= lua_tointeger(L, 1); |
782 x:= Trunc(lua_tonumber(L, 1)); |
756 y:= lua_tointeger(L, 2); |
783 y:= Trunc(lua_tonumber(L, 2)); |
757 s:= lua_tointeger(L, 4); |
784 s:= Trunc(lua_tonumber(L, 4)); |
758 dx:= int2hwFloat(lua_tointeger(L, 5)) / 1000000; |
785 dx:= int2hwFloat(Trunc(lua_tonumber(L, 5))) / 1000000; |
759 dy:= int2hwFloat(lua_tointeger(L, 6)) / 1000000; |
786 dy:= int2hwFloat(Trunc(lua_tonumber(L, 6))) / 1000000; |
760 t:= lua_tointeger(L, 7); |
787 t:= Trunc(lua_tonumber(L, 7)); |
761 |
788 |
762 gear:= AddGear(x, y, gt, s, dx, dy, t); |
789 gear:= AddGear(x, y, gt, s, dx, dy, t); |
763 lastGearByUID:= gear; |
790 lastGearByUID:= gear; |
764 lua_pushinteger(L, gear^.uid) |
791 lua_pushnumber(L, gear^.uid) |
765 end |
792 end |
766 else |
793 else |
767 lua_pushnil(L); |
794 lua_pushnil(L); |
768 end |
795 end |
769 else |
796 else |
798 begin |
825 begin |
799 s:= LuaToVisualGearTypeOrd(L, 3, call, params); |
826 s:= LuaToVisualGearTypeOrd(L, 3, call, params); |
800 if s >= 0 then |
827 if s >= 0 then |
801 begin |
828 begin |
802 vgt:= TVisualGearType(s); |
829 vgt:= TVisualGearType(s); |
803 x:= lua_tointeger(L, 1); |
830 x:= Trunc(lua_tonumber(L, 1)); |
804 y:= lua_tointeger(L, 2); |
831 y:= Trunc(lua_tonumber(L, 2)); |
805 s:= lua_tointeger(L, 4); |
832 s:= Trunc(lua_tonumber(L, 4)); |
806 c:= lua_toboolean(L, 5); |
833 c:= lua_toboolean(L, 5); |
807 |
834 |
808 if n = 6 then |
835 if n = 6 then |
809 begin |
836 begin |
810 layer:= lua_tointeger(L, 6); |
837 layer:= Trunc(lua_tonumber(L, 6)); |
811 vg:= AddVisualGear(x, y, vgt, s, c, layer); |
838 vg:= AddVisualGear(x, y, vgt, s, c, layer); |
812 end |
839 end |
813 else |
840 else |
814 vg:= AddVisualGear(x, y, vgt, s, c); |
841 vg:= AddVisualGear(x, y, vgt, s, c); |
815 |
842 |
816 if vg <> nil then |
843 if vg <> nil then |
817 begin |
844 begin |
818 lastVisualGearByUID:= vg; |
845 lastVisualGearByUID:= vg; |
819 uid:= vg^.uid; |
846 uid:= vg^.uid; |
820 lua_pushinteger(L, uid); |
847 lua_pushnumber(L, uid); |
821 end; |
848 end; |
822 end |
849 end |
823 else |
850 else |
824 lua_pushnil(L); |
851 lua_pushnil(L); |
825 end |
852 end |
832 var vg : PVisualGear; |
859 var vg : PVisualGear; |
833 begin |
860 begin |
834 vg:= nil; |
861 vg:= nil; |
835 if CheckLuaParamCount(L, 1, 'DeleteVisualGear', 'vgUid') then |
862 if CheckLuaParamCount(L, 1, 'DeleteVisualGear', 'vgUid') then |
836 begin |
863 begin |
837 vg:= VisualGearByUID(lua_tointeger(L, 1)); |
864 vg:= VisualGearByUID(Trunc(lua_tonumber(L, 1))); |
838 if vg <> nil then |
865 if vg <> nil then |
839 DeleteVisualGear(vg); |
866 DeleteVisualGear(vg); |
840 end; |
867 end; |
841 // allow caller to know whether there was something to delete |
868 // allow caller to know whether there was something to delete |
842 lua_pushboolean(L, vg <> nil); |
869 lua_pushboolean(L, vg <> nil); |
843 lc_deletevisualgear:= 1 |
870 lc_deletevisualgear:= 1 |
844 end; |
871 end; |
845 |
872 |
|
873 function lc_getvisualgeartype(L : Plua_State) : LongInt; Cdecl; |
|
874 var vg : PVisualGear; |
|
875 begin |
|
876 if CheckLuaParamCount(L, 1, 'GetVisualGearType', 'vgUid') then |
|
877 begin |
|
878 vg := VisualGearByUID(Trunc(lua_tonumber(L, 1))); |
|
879 if vg <> nil then |
|
880 lua_pushnumber(L, ord(vg^.Kind)) |
|
881 else |
|
882 lua_pushnil(L); |
|
883 end |
|
884 else |
|
885 lua_pushnil(L); // return value on stack (nil) |
|
886 lc_getvisualgeartype:= 1 |
|
887 end; |
|
888 |
|
889 |
846 function lc_getvisualgearvalues(L : Plua_State) : LongInt; Cdecl; |
890 function lc_getvisualgearvalues(L : Plua_State) : LongInt; Cdecl; |
847 var vg: PVisualGear; |
891 var vg: PVisualGear; |
848 begin |
892 begin |
849 if CheckLuaParamCount(L, 1, 'GetVisualGearValues', 'vgUid') then |
893 if CheckLuaParamCount(L, 1, 'GetVisualGearValues', 'vgUid') then |
850 begin |
894 begin |
851 vg:= VisualGearByUID(lua_tointeger(L, 1)); |
895 vg:= VisualGearByUID(Trunc(lua_tonumber(L, 1))); |
852 if vg <> nil then |
896 if vg <> nil then |
853 begin |
897 begin |
854 lua_pushinteger(L, round(vg^.X)); |
898 lua_pushnumber(L, round(vg^.X)); |
855 lua_pushinteger(L, round(vg^.Y)); |
899 lua_pushnumber(L, round(vg^.Y)); |
856 lua_pushnumber(L, vg^.dX); |
900 lua_pushnumber(L, vg^.dX); |
857 lua_pushnumber(L, vg^.dY); |
901 lua_pushnumber(L, vg^.dY); |
858 lua_pushnumber(L, vg^.Angle); |
902 lua_pushnumber(L, vg^.Angle); |
859 lua_pushinteger(L, vg^.Frame); |
903 lua_pushnumber(L, vg^.Frame); |
860 lua_pushinteger(L, vg^.FrameTicks); |
904 lua_pushnumber(L, vg^.FrameTicks); |
861 lua_pushinteger(L, vg^.State); |
905 lua_pushnumber(L, vg^.State); |
862 lua_pushinteger(L, vg^.Timer); |
906 lua_pushnumber(L, vg^.Timer); |
863 lua_pushinteger(L, vg^.Tint); |
907 lua_pushnumber(L, vg^.Tint); |
864 end |
908 end |
865 else |
909 else |
866 begin |
910 begin |
867 lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); |
911 lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); |
868 lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); |
912 lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); |
880 var vg : PVisualGear; |
924 var vg : PVisualGear; |
881 begin |
925 begin |
882 // Param count can be 1-11 at present |
926 // Param count can be 1-11 at present |
883 // if CheckLuaParamCount(L, 11, 'SetVisualGearValues', 'vgUid, X, Y, dX, dY, Angle, Frame, FrameTicks, State, Timer, Tint') then |
927 // if CheckLuaParamCount(L, 11, 'SetVisualGearValues', 'vgUid, X, Y, dX, dY, Angle, Frame, FrameTicks, State, Timer, Tint') then |
884 // begin |
928 // begin |
885 vg:= VisualGearByUID(lua_tointeger(L, 1)); |
929 vg:= VisualGearByUID(Trunc(lua_tonumber(L, 1))); |
886 if vg <> nil then |
930 if vg <> nil then |
887 begin |
931 begin |
888 if not lua_isnoneornil(L, 2) then |
932 if not lua_isnoneornil(L, 2) then |
889 vg^.X:= lua_tointeger(L, 2); |
933 vg^.X:= Trunc(lua_tonumber(L, 2)); |
890 if not lua_isnoneornil(L, 3) then |
934 if not lua_isnoneornil(L, 3) then |
891 vg^.Y:= lua_tointeger(L, 3); |
935 vg^.Y:= Trunc(lua_tonumber(L, 3)); |
892 if not lua_isnoneornil(L, 4) then |
936 if not lua_isnoneornil(L, 4) then |
893 vg^.dX:= lua_tonumber(L, 4); |
937 vg^.dX:= lua_tonumber(L, 4); |
894 if not lua_isnoneornil(L, 5) then |
938 if not lua_isnoneornil(L, 5) then |
895 vg^.dY:= lua_tonumber(L, 5); |
939 vg^.dY:= lua_tonumber(L, 5); |
896 if not lua_isnoneornil(L, 6) then |
940 if not lua_isnoneornil(L, 6) then |
897 vg^.Angle:= lua_tonumber(L, 6); |
941 vg^.Angle:= lua_tonumber(L, 6); |
898 if not lua_isnoneornil(L, 7) then |
942 if not lua_isnoneornil(L, 7) then |
899 vg^.Frame:= lua_tointeger(L, 7); |
943 vg^.Frame:= Trunc(lua_tonumber(L, 7)); |
900 if not lua_isnoneornil(L, 8) then |
944 if not lua_isnoneornil(L, 8) then |
901 vg^.FrameTicks:= lua_tointeger(L, 8); |
945 vg^.FrameTicks:= Trunc(lua_tonumber(L, 8)); |
902 if not lua_isnoneornil(L, 9) then |
946 if not lua_isnoneornil(L, 9) then |
903 vg^.State:= lua_tointeger(L, 9); |
947 vg^.State:= Trunc(lua_tonumber(L, 9)); |
904 if not lua_isnoneornil(L, 10) then |
948 if not lua_isnoneornil(L, 10) then |
905 vg^.Timer:= lua_tointeger(L, 10); |
949 vg^.Timer:= Trunc(lua_tonumber(L, 10)); |
906 if not lua_isnoneornil(L, 11) then |
950 if not lua_isnoneornil(L, 11) then |
907 vg^.Tint:= lua_tointeger(L, 11) |
951 vg^.Tint:= Trunc(lua_tonumber(L, 11)) |
908 end; |
952 end; |
909 // end |
953 // end |
910 // else |
954 // else |
911 // lua_pushnil(L); // return value on stack (nil) |
955 // lua_pushnil(L); // return value on stack (nil) |
912 lc_setvisualgearvalues:= 0 |
956 lc_setvisualgearvalues:= 0 |
917 function lc_getgearvalues(L : Plua_State) : LongInt; Cdecl; |
961 function lc_getgearvalues(L : Plua_State) : LongInt; Cdecl; |
918 var gear: PGear; |
962 var gear: PGear; |
919 begin |
963 begin |
920 if CheckLuaParamCount(L, 1, 'GetGearValues', 'gearUid') then |
964 if CheckLuaParamCount(L, 1, 'GetGearValues', 'gearUid') then |
921 begin |
965 begin |
922 gear:= GearByUID(lua_tointeger(L, 1)); |
966 gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
923 if gear <> nil then |
967 if gear <> nil then |
924 begin |
968 begin |
925 lua_pushinteger(L, gear^.Angle); |
969 lua_pushnumber(L, gear^.Angle); |
926 lua_pushinteger(L, gear^.Power); |
970 lua_pushnumber(L, gear^.Power); |
927 lua_pushinteger(L, gear^.WDTimer); |
971 lua_pushnumber(L, gear^.WDTimer); |
928 lua_pushinteger(L, gear^.Radius); |
972 lua_pushnumber(L, gear^.Radius); |
929 lua_pushinteger(L, hwRound(gear^.Density * _10000)); |
973 lua_pushnumber(L, hwRound(gear^.Density * _10000)); |
930 lua_pushinteger(L, gear^.Karma); |
974 lua_pushnumber(L, gear^.Karma); |
931 lua_pushnumber(L, gear^.DirAngle); |
975 lua_pushnumber(L, gear^.DirAngle); |
932 lua_pushinteger(L, gear^.AdvBounce); |
976 lua_pushnumber(L, gear^.AdvBounce); |
933 lua_pushinteger(L, Integer(gear^.ImpactSound)); |
977 lua_pushnumber(L, Integer(gear^.ImpactSound)); |
934 lua_pushinteger(L, gear^.nImpactSounds); |
978 lua_pushnumber(L, gear^.nImpactSounds); |
935 lua_pushinteger(L, gear^.Tint); |
979 lua_pushnumber(L, gear^.Tint); |
936 lua_pushinteger(L, gear^.Damage); |
980 lua_pushnumber(L, gear^.Damage); |
937 lua_pushinteger(L, gear^.Boom) |
981 lua_pushnumber(L, gear^.Boom) |
938 end |
982 end |
939 else |
983 else |
940 begin |
984 begin |
941 lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); |
985 lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); |
942 lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); |
986 lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); |
956 var gear : PGear; |
1000 var gear : PGear; |
957 begin |
1001 begin |
958 // Currently allows 1-14 params |
1002 // Currently allows 1-14 params |
959 // if CheckLuaParamCount(L, 14, 'SetGearValues', 'gearUid, Angle, Power, WDTimer, Radius, Density, Karma, DirAngle, AdvBounce, ImpactSound, # ImpactSounds, Tint, Damage, Boom') then |
1003 // if CheckLuaParamCount(L, 14, 'SetGearValues', 'gearUid, Angle, Power, WDTimer, Radius, Density, Karma, DirAngle, AdvBounce, ImpactSound, # ImpactSounds, Tint, Damage, Boom') then |
960 // begin |
1004 // begin |
961 gear:= GearByUID(lua_tointeger(L, 1)); |
1005 gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
962 if gear <> nil then |
1006 if gear <> nil then |
963 begin |
1007 begin |
964 if not lua_isnoneornil(L, 2) then |
1008 if not lua_isnoneornil(L, 2) then |
965 gear^.Angle := lua_tointeger(L, 2); |
1009 gear^.Angle := Trunc(lua_tonumber(L, 2)); |
966 if not lua_isnoneornil(L, 3) then |
1010 if not lua_isnoneornil(L, 3) then |
967 gear^.Power := lua_tointeger(L, 3); |
1011 gear^.Power := Trunc(lua_tonumber(L, 3)); |
968 if not lua_isnoneornil(L, 4) then |
1012 if not lua_isnoneornil(L, 4) then |
969 gear^.WDTimer := lua_tointeger(L, 4); |
1013 gear^.WDTimer := Trunc(lua_tonumber(L, 4)); |
970 if not lua_isnoneornil(L, 5) then |
1014 if not lua_isnoneornil(L, 5) then |
971 gear^.Radius := lua_tointeger(L, 5); |
1015 gear^.Radius := Trunc(lua_tonumber(L, 5)); |
972 if not lua_isnoneornil(L, 6) then |
1016 if not lua_isnoneornil(L, 6) then |
973 gear^.Density:= int2hwFloat(lua_tointeger(L, 6)) / 10000; |
1017 gear^.Density:= int2hwFloat(Trunc(lua_tonumber(L, 6))) / 10000; |
974 if not lua_isnoneornil(L, 7) then |
1018 if not lua_isnoneornil(L, 7) then |
975 gear^.Karma := lua_tointeger(L, 7); |
1019 gear^.Karma := Trunc(lua_tonumber(L, 7)); |
976 if not lua_isnoneornil(L, 8) then |
1020 if not lua_isnoneornil(L, 8) then |
977 gear^.DirAngle:= lua_tonumber(L, 8); |
1021 gear^.DirAngle:= lua_tonumber(L, 8); |
978 if not lua_isnoneornil(L, 9) then |
1022 if not lua_isnoneornil(L, 9) then |
979 gear^.AdvBounce := lua_tointeger(L, 9); |
1023 gear^.AdvBounce := Trunc(lua_tonumber(L, 9)); |
980 if not lua_isnoneornil(L, 10) then |
1024 if not lua_isnoneornil(L, 10) then |
981 gear^.ImpactSound := TSound(lua_tointeger(L, 10)); |
1025 gear^.ImpactSound := TSound(Trunc(lua_tonumber(L, 10))); |
982 if not lua_isnoneornil(L, 11) then |
1026 if not lua_isnoneornil(L, 11) then |
983 gear^.nImpactSounds := lua_tointeger(L, 11); |
1027 gear^.nImpactSounds := Trunc(lua_tonumber(L, 11)); |
984 if not lua_isnoneornil(L, 12) then |
1028 if not lua_isnoneornil(L, 12) then |
985 gear^.Tint := lua_tointeger(L, 12); |
1029 gear^.Tint := Trunc(lua_tonumber(L, 12)); |
986 if not lua_isnoneornil(L, 13) then |
1030 if not lua_isnoneornil(L, 13) then |
987 gear^.Damage := lua_tointeger(L, 13); |
1031 gear^.Damage := Trunc(lua_tonumber(L, 13)); |
988 if not lua_isnoneornil(L, 14) then |
1032 if not lua_isnoneornil(L, 14) then |
989 gear^.Boom := lua_tointeger(L, 14); |
1033 gear^.Boom := Trunc(lua_tonumber(L, 14)); |
990 end; |
1034 end; |
991 // end |
1035 // end |
992 // else |
1036 // else |
993 // lua_pushnil(L); // return value on stack (nil) |
1037 // lua_pushnil(L); // return value on stack (nil) |
994 lc_setgearvalues:= 0 |
1038 lc_setgearvalues:= 0 |
1059 function lc_setgearelasticity(L : Plua_State) : LongInt; Cdecl; |
1103 function lc_setgearelasticity(L : Plua_State) : LongInt; Cdecl; |
1060 var gear: PGear; |
1104 var gear: PGear; |
1061 begin |
1105 begin |
1062 if CheckLuaParamCount(L, 2, 'SetGearElasticity', 'gearUid, Elasticity') then |
1106 if CheckLuaParamCount(L, 2, 'SetGearElasticity', 'gearUid, Elasticity') then |
1063 begin |
1107 begin |
1064 gear:= GearByUID(lua_tointeger(L, 1)); |
1108 gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
1065 if gear <> nil then |
1109 if gear <> nil then |
1066 gear^.Elasticity:= int2hwFloat(lua_tointeger(L, 2)) / 10000 |
1110 gear^.Elasticity:= int2hwFloat(Trunc(lua_tonumber(L, 2))) / 10000 |
1067 end; |
1111 end; |
1068 lc_setgearelasticity:= 0 |
1112 lc_setgearelasticity:= 0 |
1069 end; |
1113 end; |
1070 |
1114 |
1071 function lc_getgearfriction(L : Plua_State) : LongInt; Cdecl; |
1115 function lc_getgearfriction(L : Plua_State) : LongInt; Cdecl; |
1072 var gear : PGear; |
1116 var gear : PGear; |
1073 begin |
1117 begin |
1074 if CheckLuaParamCount(L, 1, 'GetGearFriction', 'gearUid') then |
1118 if CheckLuaParamCount(L, 1, 'GetGearFriction', 'gearUid') then |
1075 begin |
1119 begin |
1076 gear:= GearByUID(lua_tointeger(L, 1)); |
1120 gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
1077 if gear <> nil then |
1121 if gear <> nil then |
1078 lua_pushinteger(L, hwRound(gear^.friction * _10000)) |
1122 lua_pushnumber(L, hwRound(gear^.friction * _10000)) |
1079 else |
1123 else |
1080 lua_pushnil(L); |
1124 lua_pushnil(L); |
1081 end |
1125 end |
1082 else |
1126 else |
1083 lua_pushnil(L); // return value on stack (nil) |
1127 lua_pushnil(L); // return value on stack (nil) |
1087 function lc_setgearfriction(L : Plua_State) : LongInt; Cdecl; |
1131 function lc_setgearfriction(L : Plua_State) : LongInt; Cdecl; |
1088 var gear: PGear; |
1132 var gear: PGear; |
1089 begin |
1133 begin |
1090 if CheckLuaParamCount(L, 2, 'SetGearFriction', 'gearUid, Friction') then |
1134 if CheckLuaParamCount(L, 2, 'SetGearFriction', 'gearUid, Friction') then |
1091 begin |
1135 begin |
1092 gear:= GearByUID(lua_tointeger(L, 1)); |
1136 gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
1093 if gear <> nil then |
1137 if gear <> nil then |
1094 gear^.Friction:= int2hwFloat(lua_tointeger(L, 2)) / 10000 |
1138 gear^.Friction:= int2hwFloat(Trunc(lua_tonumber(L, 2))) / 10000 |
1095 end; |
1139 end; |
1096 lc_setgearfriction:= 0 |
1140 lc_setgearfriction:= 0 |
1097 end; |
1141 end; |
1098 |
1142 |
1099 function lc_setgearmessage(L : Plua_State) : LongInt; Cdecl; |
1143 function lc_setgearmessage(L : Plua_State) : LongInt; Cdecl; |
1100 var gear : PGear; |
1144 var gear : PGear; |
1101 begin |
1145 begin |
1102 if CheckLuaParamCount(L, 2, 'SetGearMessage', 'gearUid, message') then |
1146 if CheckLuaParamCount(L, 2, 'SetGearMessage', 'gearUid, message') then |
1103 begin |
1147 begin |
1104 gear:= GearByUID(lua_tointeger(L, 1)); |
1148 gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
1105 if gear <> nil then |
1149 if gear <> nil then |
1106 gear^.message:= lua_tointeger(L, 2); |
1150 gear^.message:= Trunc(lua_tonumber(L, 2)); |
1107 end; |
1151 end; |
1108 lc_setgearmessage:= 0 |
1152 lc_setgearmessage:= 0 |
1109 end; |
1153 end; |
1110 |
1154 |
1111 function lc_getgearpos(L : Plua_State) : LongInt; Cdecl; |
1155 function lc_getgearpos(L : Plua_State) : LongInt; Cdecl; |
1112 var gear : PGear; |
1156 var gear : PGear; |
1113 begin |
1157 begin |
1114 if CheckLuaParamCount(L, 1, 'GetGearPos', 'gearUid') then |
1158 if CheckLuaParamCount(L, 1, 'GetGearPos', 'gearUid') then |
1115 begin |
1159 begin |
1116 gear:= GearByUID(lua_tointeger(L, 1)); |
1160 gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
1117 if gear <> nil then |
1161 if gear <> nil then |
1118 lua_pushinteger(L, gear^.Pos) |
1162 lua_pushnumber(L, gear^.Pos) |
1119 else |
1163 else |
1120 lua_pushnil(L); |
1164 lua_pushnil(L); |
1121 end |
1165 end |
1122 else |
1166 else |
1123 lua_pushnil(L); // return value on stack (nil) |
1167 lua_pushnil(L); // return value on stack (nil) |
1127 function lc_setgearpos(L : Plua_State) : LongInt; Cdecl; |
1171 function lc_setgearpos(L : Plua_State) : LongInt; Cdecl; |
1128 var gear : PGear; |
1172 var gear : PGear; |
1129 begin |
1173 begin |
1130 if CheckLuaParamCount(L, 2, 'SetGearPos', 'gearUid, value') then |
1174 if CheckLuaParamCount(L, 2, 'SetGearPos', 'gearUid, value') then |
1131 begin |
1175 begin |
1132 gear:= GearByUID(lua_tointeger(L, 1)); |
1176 gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
1133 if gear <> nil then |
1177 if gear <> nil then |
1134 gear^.Pos:= lua_tointeger(L, 2); |
1178 gear^.Pos:= Trunc(lua_tonumber(L, 2)); |
1135 end; |
1179 end; |
1136 lc_setgearpos:= 0 |
1180 lc_setgearpos:= 0 |
1137 end; |
1181 end; |
1138 |
1182 |
1139 function lc_getgearcollisionmask(L : Plua_State) : LongInt; Cdecl; |
1183 function lc_getgearcollisionmask(L : Plua_State) : LongInt; Cdecl; |
1140 var gear : PGear; |
1184 var gear : PGear; |
1141 begin |
1185 begin |
1142 if CheckLuaParamCount(L, 1, 'GetGearCollisionMask', 'gearUid') then |
1186 if CheckLuaParamCount(L, 1, 'GetGearCollisionMask', 'gearUid') then |
1143 begin |
1187 begin |
1144 gear:= GearByUID(lua_tointeger(L, 1)); |
1188 gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
1145 if gear <> nil then |
1189 if gear <> nil then |
1146 lua_pushinteger(L, gear^.CollisionMask) |
1190 lua_pushnumber(L, gear^.CollisionMask) |
1147 else |
1191 else |
1148 lua_pushnil(L); |
1192 lua_pushnil(L); |
1149 end |
1193 end |
1150 else |
1194 else |
1151 lua_pushnil(L); // return value on stack (nil) |
1195 lua_pushnil(L); // return value on stack (nil) |
1155 function lc_setgearcollisionmask(L : Plua_State) : LongInt; Cdecl; |
1199 function lc_setgearcollisionmask(L : Plua_State) : LongInt; Cdecl; |
1156 var gear : PGear; |
1200 var gear : PGear; |
1157 begin |
1201 begin |
1158 if CheckLuaParamCount(L, 2, 'SetGearCollisionMask', 'gearUid, mask') then |
1202 if CheckLuaParamCount(L, 2, 'SetGearCollisionMask', 'gearUid, mask') then |
1159 begin |
1203 begin |
1160 gear:= GearByUID(lua_tointeger(L, 1)); |
1204 gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
1161 if gear <> nil then |
1205 if gear <> nil then |
1162 gear^.CollisionMask:= lua_tointeger(L, 2); |
1206 gear^.CollisionMask:= Trunc(lua_tonumber(L, 2)); |
1163 end; |
1207 end; |
1164 lc_setgearcollisionmask:= 0 |
1208 lc_setgearcollisionmask:= 0 |
1165 end; |
1209 end; |
1166 |
1210 |
1167 function lc_gethoglevel(L : Plua_State): LongInt; Cdecl; |
1211 function lc_gethoglevel(L : Plua_State): LongInt; Cdecl; |
1168 var gear : PGear; |
1212 var gear : PGear; |
1169 begin |
1213 begin |
1170 if CheckLuaParamCount(L, 1, 'GetHogLevel', 'gearUid') then |
1214 if CheckLuaParamCount(L, 1, 'GetHogLevel', 'gearUid') then |
1171 begin |
1215 begin |
1172 gear := GearByUID(lua_tointeger(L, 1)); |
1216 gear := GearByUID(Trunc(lua_tonumber(L, 1))); |
1173 if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then |
1217 if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then |
1174 lua_pushinteger(L, gear^.Hedgehog^.BotLevel) |
1218 lua_pushnumber(L, gear^.Hedgehog^.BotLevel) |
1175 else |
1219 else |
1176 lua_pushnil(L); |
1220 lua_pushnil(L); |
1177 end; |
1221 end; |
1178 lc_gethoglevel := 1; |
1222 lc_gethoglevel := 1; |
1179 end; |
1223 end; |
1181 function lc_sethoglevel(L : Plua_State) : LongInt; Cdecl; |
1225 function lc_sethoglevel(L : Plua_State) : LongInt; Cdecl; |
1182 var gear : PGear; |
1226 var gear : PGear; |
1183 begin |
1227 begin |
1184 if CheckLuaParamCount(L, 2, 'SetHogLevel', 'gearUid, level') then |
1228 if CheckLuaParamCount(L, 2, 'SetHogLevel', 'gearUid, level') then |
1185 begin |
1229 begin |
1186 gear:= GearByUID(lua_tointeger(L, 1)); |
1230 gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
1187 if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
1231 if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
1188 gear^.Hedgehog^.BotLevel:= lua_tointeger(L, 2); |
1232 gear^.Hedgehog^.BotLevel:= Trunc(lua_tonumber(L, 2)); |
1189 end; |
1233 end; |
1190 lc_sethoglevel:= 0 |
1234 lc_sethoglevel:= 0 |
1191 end; |
1235 end; |
1192 |
1236 |
1193 function lc_gethogclan(L : Plua_State) : LongInt; Cdecl; |
1237 function lc_gethogclan(L : Plua_State) : LongInt; Cdecl; |
1194 var gear : PGear; |
1238 var gear : PGear; |
1195 begin |
1239 begin |
1196 if CheckLuaParamCount(L, 1, 'GetHogClan', 'gearUid') then |
1240 if CheckLuaParamCount(L, 1, 'GetHogClan', 'gearUid') then |
1197 begin |
1241 begin |
1198 gear:= GearByUID(lua_tointeger(L, 1)); |
1242 gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
1199 if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then |
1243 if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then |
1200 begin |
1244 begin |
1201 lua_pushinteger(L, gear^.Hedgehog^.Team^.Clan^.ClanIndex) |
1245 lua_pushnumber(L, gear^.Hedgehog^.Team^.Clan^.ClanIndex) |
1202 end |
1246 end |
1203 else |
1247 else |
1204 lua_pushnil(L); |
1248 lua_pushnil(L); |
1205 end |
1249 end |
1206 else |
1250 else |
1304 function lc_gethogflag(L : Plua_State) : LongInt; Cdecl; |
1348 function lc_gethogflag(L : Plua_State) : LongInt; Cdecl; |
1305 var gear : PGear; |
1349 var gear : PGear; |
1306 begin |
1350 begin |
1307 if CheckLuaParamCount(L, 1, 'GetHogFlag', 'gearUid') then |
1351 if CheckLuaParamCount(L, 1, 'GetHogFlag', 'gearUid') then |
1308 begin |
1352 begin |
1309 gear:= GearByUID(lua_tointeger(L, 1)); |
1353 gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
|
1354 // TODO error messages |
1310 if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
1355 if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
1311 lua_pushstring(L, str2pchar(gear^.Hedgehog^.Team^.Flag)) |
1356 lua_pushstring(L, str2pchar(gear^.Hedgehog^.Team^.Flag)) |
1312 else |
1357 else |
1313 lua_pushnil(L); |
1358 lua_pushnil(L); |
1314 end |
1359 end |
1315 else |
1360 else |
1316 lua_pushnil(L); // return value on stack (nil) |
1361 lua_pushnil(L); // return value on stack (nil) |
1317 lc_gethogflag:= 1 |
1362 lc_gethogflag:= 1 |
1318 end; |
1363 end; |
1319 |
1364 |
|
1365 function lc_gethogfort(L : Plua_State) : LongInt; Cdecl; |
|
1366 var gear : PGear; |
|
1367 begin |
|
1368 if CheckLuaParamCount(L, 1, 'GetHogFort', 'gearUid') then |
|
1369 begin |
|
1370 gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
|
1371 // TODO error messages |
|
1372 if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
|
1373 lua_pushstring(L, str2pchar(gear^.Hedgehog^.Team^.FortName)) |
|
1374 else |
|
1375 lua_pushnil(L); |
|
1376 end |
|
1377 else |
|
1378 lua_pushnil(L); // return value on stack (nil) |
|
1379 lc_gethogfort:= 1 |
|
1380 end; |
|
1381 |
|
1382 function lc_ishoglocal(L : Plua_State) : LongInt; Cdecl; |
|
1383 var gear : PGear; |
|
1384 begin |
|
1385 if CheckLuaParamCount(L, 1, 'IsHogLocal', 'gearUid') then |
|
1386 begin |
|
1387 gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
|
1388 // TODO error messages |
|
1389 if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
|
1390 lua_pushboolean(L, IsHogLocal(gear^.Hedgehog)) |
|
1391 else |
|
1392 lua_pushnil(L); |
|
1393 end |
|
1394 else |
|
1395 lua_pushnil(L); // return value on stack (nil) |
|
1396 lc_ishoglocal:= 1 |
|
1397 end; |
|
1398 |
1320 function lc_gethogteamname(L : Plua_State) : LongInt; Cdecl; |
1399 function lc_gethogteamname(L : Plua_State) : LongInt; Cdecl; |
1321 var gear : PGear; |
1400 var gear : PGear; |
1322 begin |
1401 begin |
1323 if CheckLuaParamCount(L, 1, 'GetHogTeamName', 'gearUid') then |
1402 if CheckLuaParamCount(L, 1, 'GetHogTeamName', 'gearUid') then |
1324 begin |
1403 begin |
1325 gear:= GearByUID(lua_tointeger(L, 1)); |
1404 gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
|
1405 // TODO error messages |
1326 if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then |
1406 if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then |
1327 lua_pushstring(L, str2pchar(gear^.Hedgehog^.Team^.TeamName)) |
1407 lua_pushstring(L, str2pchar(gear^.Hedgehog^.Team^.TeamName)) |
1328 else |
1408 else |
1329 lua_pushnil(L); |
1409 lua_pushnil(L); |
1330 end |
1410 end |
1472 function lc_copypv(L : Plua_State) : LongInt; Cdecl; |
1552 function lc_copypv(L : Plua_State) : LongInt; Cdecl; |
1473 var gears, geard : PGear; |
1553 var gears, geard : PGear; |
1474 begin |
1554 begin |
1475 if CheckLuaParamCount(L, 2, 'CopyPV', 'fromGearUid, toGearUid') then |
1555 if CheckLuaParamCount(L, 2, 'CopyPV', 'fromGearUid, toGearUid') then |
1476 begin |
1556 begin |
1477 gears:= GearByUID(lua_tointeger(L, 1)); |
1557 gears:= GearByUID(Trunc(lua_tonumber(L, 1))); |
1478 geard:= GearByUID(lua_tointeger(L, 2)); |
1558 geard:= GearByUID(Trunc(lua_tonumber(L, 2))); |
1479 if (gears <> nil) and (geard <> nil) then |
1559 if (gears <> nil) and (geard <> nil) then |
1480 begin |
1560 begin |
1481 geard^.X:= gears^.X; |
1561 geard^.X:= gears^.X; |
1482 geard^.Y:= gears^.Y; |
1562 geard^.Y:= gears^.Y; |
1483 geard^.dX:= gears^.dX; |
1563 geard^.dX:= gears^.dX; |
1504 s : LongWord; |
1584 s : LongWord; |
1505 n : LongInt; |
1585 n : LongInt; |
1506 begin |
1586 begin |
1507 if CheckAndFetchParamCount(L, 3, 4, 'HogSay', 'gearUid, text, manner [, vgState]', n) then |
1587 if CheckAndFetchParamCount(L, 3, 4, 'HogSay', 'gearUid, text, manner [, vgState]', n) then |
1508 begin |
1588 begin |
1509 gear:= GearByUID(lua_tointeger(L, 1)); |
1589 gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
1510 if gear <> nil then |
1590 if gear <> nil then |
1511 begin |
1591 begin |
1512 // state defaults to 0 if state param is given |
1592 // state defaults to 0 if state param is given |
1513 if n = 4 then |
1593 if n = 4 then |
1514 s:= lua_tointeger(L, 4) |
1594 s:= Trunc(lua_tonumber(L, 4)) |
1515 else |
1595 else |
1516 s:= 0; |
1596 s:= 0; |
1517 vgear:= AddVisualGear(0, 0, vgtSpeechBubble, s, true); |
1597 vgear:= AddVisualGear(0, 0, vgtSpeechBubble, s, true); |
1518 if vgear <> nil then |
1598 if vgear <> nil then |
1519 begin |
1599 begin |
1542 function lc_switchhog(L : Plua_State) : LongInt; Cdecl; |
1622 function lc_switchhog(L : Plua_State) : LongInt; Cdecl; |
1543 var gear, prevgear : PGear; |
1623 var gear, prevgear : PGear; |
1544 begin |
1624 begin |
1545 if CheckLuaParamCount(L, 1, 'SwitchHog', 'gearUid') then |
1625 if CheckLuaParamCount(L, 1, 'SwitchHog', 'gearUid') then |
1546 begin |
1626 begin |
1547 gear:= GearByUID(lua_tointeger(L, 1)); |
1627 gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
1548 // should we allow this when there is no current hedgehog? might do some odd(er) things to turn sequence. |
1628 // should we allow this when there is no current hedgehog? might do some odd(er) things to turn sequence. |
1549 if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) and (CurrentHedgehog <> nil) then |
1629 if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) and (CurrentHedgehog <> nil) then |
1550 begin |
1630 begin |
1551 prevgear := CurrentHedgehog^.Gear; |
1631 prevgear := CurrentHedgehog^.Gear; |
1552 if prevgear <> nil then |
1632 if prevgear <> nil then |
1579 if CheckAndFetchParamCount(L, 2, 3, call, params, n) then |
1665 if CheckAndFetchParamCount(L, 2, 3, call, params, n) then |
1580 begin |
1666 begin |
1581 at:= LuaToAmmoTypeOrd(L, 2, call, params); |
1667 at:= LuaToAmmoTypeOrd(L, 2, call, params); |
1582 if at >= 0 then |
1668 if at >= 0 then |
1583 begin |
1669 begin |
1584 gear:= GearByUID(lua_tointeger(L, 1)); |
1670 gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
1585 if (gear <> nil) and (gear^.Hedgehog <> nil) then |
1671 if (gear <> nil) and (gear^.Hedgehog <> nil) then |
1586 if n = 2 then |
1672 if n = 2 then |
1587 AddAmmo(gear^.Hedgehog^, TAmmoType(at)) |
1673 AddAmmo(gear^.Hedgehog^, TAmmoType(at)) |
1588 else |
1674 else |
1589 SetAmmo(gear^.Hedgehog^, TAmmoType(at), lua_tointeger(L, 3)) |
1675 SetAmmo(gear^.Hedgehog^, TAmmoType(at), Trunc(lua_tonumber(L, 3))) |
1590 end; |
1676 end; |
1591 end; |
1677 end; |
1592 lc_addammo:= 0 |
1678 lc_addammo:= 0 |
1593 end; |
1679 end; |
1594 |
1680 |
1600 call = 'GetAmmoCount'; |
1686 call = 'GetAmmoCount'; |
1601 params = 'gearUid, ammoType'; |
1687 params = 'gearUid, ammoType'; |
1602 begin |
1688 begin |
1603 if CheckLuaParamCount(L, 2, call, params) then |
1689 if CheckLuaParamCount(L, 2, call, params) then |
1604 begin |
1690 begin |
1605 gear:= GearByUID(lua_tointeger(L, 1)); |
1691 gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
1606 if (gear <> nil) and (gear^.Hedgehog <> nil) then |
1692 if (gear <> nil) and (gear^.Hedgehog <> nil) then |
1607 begin |
1693 begin |
1608 at:= LuaToAmmoTypeOrd(L, 2, call, params); |
1694 at:= LuaToAmmoTypeOrd(L, 2, call, params); |
1609 if at >= 0 then |
1695 if at >= 0 then |
1610 begin |
1696 begin |
1611 ammo:= GetAmmoEntry(gear^.Hedgehog^, TAmmoType(at)); |
1697 ammo:= GetAmmoEntry(gear^.Hedgehog^, TAmmoType(at)); |
1612 if ammo^.AmmoType = amNothing then |
1698 if ammo^.AmmoType = amNothing then |
1613 lua_pushinteger(L, 0) |
1699 lua_pushnumber(L, 0) |
1614 else |
1700 else |
1615 lua_pushinteger(L, ammo^.Count); |
1701 lua_pushnumber(L, ammo^.Count); |
1616 end; |
1702 end; |
1617 end |
1703 end |
1618 else lua_pushinteger(L, 0); |
1704 else lua_pushnumber(L, 0); |
1619 end |
1705 end |
1620 else |
1706 else |
1621 lua_pushnil(L); |
1707 lua_pushnil(L); |
1622 lc_getammocount:= 1 |
1708 lc_getammocount:= 1 |
1623 end; |
1709 end; |
1649 function lc_settimer(L : Plua_State) : LongInt; Cdecl; |
1735 function lc_settimer(L : Plua_State) : LongInt; Cdecl; |
1650 var gear : PGear; |
1736 var gear : PGear; |
1651 begin |
1737 begin |
1652 if CheckLuaParamCount(L, 2, 'SetTimer', 'gearUid, timer') then |
1738 if CheckLuaParamCount(L, 2, 'SetTimer', 'gearUid, timer') then |
1653 begin |
1739 begin |
1654 gear:= GearByUID(lua_tointeger(L, 1)); |
1740 gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
1655 if gear <> nil then gear^.Timer:= lua_tointeger(L, 2) |
1741 if gear <> nil then gear^.Timer:= Trunc(lua_tonumber(L, 2)) |
1656 end; |
1742 end; |
1657 lc_settimer:= 0 |
1743 lc_settimer:= 0 |
1658 end; |
1744 end; |
1659 |
1745 |
1660 function lc_setflighttime(L : Plua_State) : LongInt; Cdecl; |
1746 function lc_setflighttime(L : Plua_State) : LongInt; Cdecl; |
1661 var gear : PGear; |
1747 var gear : PGear; |
1662 begin |
1748 begin |
1663 if CheckLuaParamCount(L, 2, 'SetFlightTime', 'gearUid, flighttime') then |
1749 if CheckLuaParamCount(L, 2, 'SetFlightTime', 'gearUid, flighttime') then |
1664 begin |
1750 begin |
1665 gear:= GearByUID(lua_tointeger(L, 1)); |
1751 gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
1666 if gear <> nil then gear^.FlightTime:= lua_tointeger(L, 2) |
1752 if gear <> nil then gear^.FlightTime:= Trunc(lua_tonumber(L, 2)) |
1667 end; |
1753 end; |
1668 lc_setflighttime:= 0 |
1754 lc_setflighttime:= 0 |
1669 end; |
1755 end; |
1670 |
1756 |
1671 function lc_seteffect(L : Plua_State) : LongInt; Cdecl; |
1757 function lc_seteffect(L : Plua_State) : LongInt; Cdecl; |
1698 if CheckLuaParamCount(L, 2, call, params) then |
1784 if CheckLuaParamCount(L, 2, call, params) then |
1699 begin |
1785 begin |
1700 t:= LuaToHogEffectOrd(L, 2, call, params); |
1786 t:= LuaToHogEffectOrd(L, 2, call, params); |
1701 if t >= 0 then |
1787 if t >= 0 then |
1702 begin |
1788 begin |
1703 gear:= GearByUID(lua_tointeger(L, 1)); |
1789 gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
1704 if (gear <> nil) and (gear^.Hedgehog <> nil) then |
1790 if (gear <> nil) and (gear^.Hedgehog <> nil) then |
1705 lua_pushinteger(L, gear^.Hedgehog^.Effects[THogEffect(t)]) |
1791 lua_pushnumber(L, gear^.Hedgehog^.Effects[THogEffect(t)]) |
1706 else |
1792 else |
1707 lua_pushinteger(L, 0) |
1793 lua_pushnumber(L, 0) |
1708 end; |
1794 end; |
1709 end |
1795 end |
1710 else |
1796 else |
1711 lua_pushinteger(L, 0); |
1797 lua_pushnumber(L, 0); |
1712 lc_geteffect:= 1 |
1798 lc_geteffect:= 1 |
1713 end; |
1799 end; |
1714 |
1800 |
1715 function lc_setstate(L : Plua_State) : LongInt; Cdecl; |
1801 function lc_setstate(L : Plua_State) : LongInt; Cdecl; |
1716 var gear : PGear; |
1802 var gear : PGear; |
1717 begin |
1803 begin |
1718 if CheckLuaParamCount(L, 2, 'SetState', 'gearUid, state') then |
1804 if CheckLuaParamCount(L, 2, 'SetState', 'gearUid, state') then |
1719 begin |
1805 begin |
1720 gear:= GearByUID(lua_tointeger(L, 1)); |
1806 gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
1721 if gear <> nil then |
1807 if gear <> nil then |
1722 begin |
1808 begin |
1723 gear^.State:= lua_tointeger(L, 2); |
1809 gear^.State:= Trunc(lua_tonumber(L, 2)); |
1724 SetAllToActive; |
1810 SetAllToActive; |
1725 end |
1811 end |
1726 end; |
1812 end; |
1727 lc_setstate:= 0 |
1813 lc_setstate:= 0 |
1728 end; |
1814 end; |
1777 function lc_endgame(L : Plua_State) : LongInt; Cdecl; |
1863 function lc_endgame(L : Plua_State) : LongInt; Cdecl; |
1778 begin |
1864 begin |
1779 L:= L; // avoid compiler hint |
1865 L:= L; // avoid compiler hint |
1780 AddGear(0, 0, gtATFinishGame, 0, _0, _0, 3000); |
1866 AddGear(0, 0, gtATFinishGame, 0, _0, _0, 3000); |
1781 lc_endgame:= 0 |
1867 lc_endgame:= 0 |
|
1868 end; |
|
1869 |
|
1870 function lc_endturn(L : Plua_State) : LongInt; Cdecl; |
|
1871 var n: LongInt; |
|
1872 const |
|
1873 call = 'EndTurn'; |
|
1874 params = '[noTaunts]'; |
|
1875 begin |
|
1876 if CheckAndFetchParamCount(L, 0, 1, call, params, n) then |
|
1877 if n >= 1 then |
|
1878 LuaNoEndTurnTaunts:= lua_toboolean(L, 1); |
|
1879 LuaEndTurnRequested:= true; |
|
1880 lc_endturn:= 0 |
1782 end; |
1881 end; |
1783 |
1882 |
1784 function lc_sendstat(L : Plua_State) : LongInt; Cdecl; |
1883 function lc_sendstat(L : Plua_State) : LongInt; Cdecl; |
1785 var statInfo : TStatInfoType; |
1884 var statInfo : TStatInfoType; |
1786 i, n : LongInt; |
1885 i, n : LongInt; |
1857 tryhard: boolean; |
1977 tryhard: boolean; |
1858 left, right, n: LongInt; |
1978 left, right, n: LongInt; |
1859 begin |
1979 begin |
1860 if CheckAndFetchParamCount(L, 4, 5, 'FindPlace', 'gearUid, fall, left, right [, tryHarder]', n) then |
1980 if CheckAndFetchParamCount(L, 4, 5, 'FindPlace', 'gearUid, fall, left, right [, tryHarder]', n) then |
1861 begin |
1981 begin |
1862 gear:= GearByUID(lua_tointeger(L, 1)); |
1982 gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
1863 fall:= lua_toboolean(L, 2); |
1983 fall:= lua_toboolean(L, 2); |
1864 left:= lua_tointeger(L, 3); |
1984 left:= Trunc(lua_tonumber(L, 3)); |
1865 right:= lua_tointeger(L, 4); |
1985 right:= Trunc(lua_tonumber(L, 4)); |
1866 if n = 5 then |
1986 if n = 5 then |
1867 tryhard:= lua_toboolean(L, 5) |
1987 tryhard:= lua_toboolean(L, 5) |
1868 else |
1988 else |
1869 tryhard:= false; |
1989 tryhard:= false; |
1870 if gear <> nil then |
1990 if gear <> nil then |
1871 FindPlace(gear, fall, left, right, tryhard); |
1991 FindPlace(gear, fall, left, right, tryhard); |
1872 if gear <> nil then |
1992 if gear <> nil then |
1873 lua_pushinteger(L, gear^.uid) |
1993 lua_pushnumber(L, gear^.uid) |
1874 else |
1994 else |
1875 lua_pushnil(L); |
1995 lua_pushnil(L); |
1876 end |
1996 end |
1877 else |
1997 else |
1878 lua_pushnil(L); // return value on stack (nil) |
1998 lua_pushnil(L); // return value on stack (nil) |
1965 end; |
2085 end; |
1966 end; |
2086 end; |
1967 lc_dismissteam:= 0; |
2087 lc_dismissteam:= 0; |
1968 end; |
2088 end; |
1969 |
2089 |
|
2090 function lc_getteamstats(L : Plua_State) : LongInt; Cdecl; |
|
2091 var i: LongInt; |
|
2092 begin |
|
2093 if CheckLuaParamCount(L, 1, 'GetTeamStats', 'teamname') then |
|
2094 begin |
|
2095 if TeamsCount > 0 then |
|
2096 for i:= 0 to Pred(TeamsCount) do |
|
2097 begin |
|
2098 // skip teams that don't have matching name |
|
2099 if TeamsArray[i]^.TeamName <> lua_tostring(L, 1) then |
|
2100 continue; |
|
2101 |
|
2102 lua_newtable(L); |
|
2103 |
|
2104 lua_pushstring(L, str2pchar('Kills')); |
|
2105 lua_pushnumber(L, TeamsArray[i]^.stats.Kills); |
|
2106 lua_settable(L, -3); |
|
2107 |
|
2108 lua_pushstring(L, str2pchar('Suicides')); |
|
2109 lua_pushnumber(L, TeamsArray[i]^.stats.Suicides); |
|
2110 lua_settable(L, -3); |
|
2111 |
|
2112 lua_pushstring(L, str2pchar('AIKills')); |
|
2113 lua_pushnumber(L, TeamsArray[i]^.stats.AIKills); |
|
2114 lua_settable(L, -3); |
|
2115 |
|
2116 lua_pushstring(L, str2pchar('TeamKills')); |
|
2117 lua_pushnumber(L, TeamsArray[i]^.stats.TeamKills); |
|
2118 lua_settable(L, -3); |
|
2119 |
|
2120 lua_pushstring(L, str2pchar('TurnSkips')); |
|
2121 lua_pushnumber(L, TeamsArray[i]^.stats.TurnSkips); |
|
2122 lua_settable(L, -3); |
|
2123 |
|
2124 lua_pushstring(L, str2pchar('TeamDamage')); |
|
2125 lua_pushnumber(L, TeamsArray[i]^.stats.TeamDamage); |
|
2126 lua_settable(L, -3); |
|
2127 |
|
2128 end; |
|
2129 end |
|
2130 else |
|
2131 lua_pushnil(L); |
|
2132 lc_getteamstats:= 1; |
|
2133 end; |
|
2134 |
|
2135 |
|
2136 |
1970 function lc_addhog(L : Plua_State) : LongInt; Cdecl; |
2137 function lc_addhog(L : Plua_State) : LongInt; Cdecl; |
1971 var temp: ShortString; |
2138 var temp: ShortString; |
1972 begin |
2139 begin |
1973 if CheckLuaParamCount(L, 4, 'AddHog', 'hogname, botlevel, health, hat') then |
2140 if CheckLuaParamCount(L, 4, 'AddHog', 'hogname, botlevel, health, hat') then |
1974 begin |
2141 begin |
1975 temp:= lua_tostring(L, 4); |
2142 temp:= lua_tostring(L, 4); |
1976 ParseCommand('addhh ' + lua_tostring(L, 2) + ' ' + lua_tostring(L, 3) + ' ' + lua_tostring(L, 1), true, true); |
2143 ParseCommand('addhh ' + lua_tostring(L, 2) + ' ' + lua_tostring(L, 3) + ' ' + lua_tostring(L, 1), true, true); |
1977 ParseCommand('hat ' + temp, true, true); |
2144 ParseCommand('hat ' + temp, true, true); |
1978 lua_pushinteger(L, CurrentHedgehog^.Gear^.uid); |
2145 lua_pushnumber(L, CurrentHedgehog^.Gear^.uid); |
1979 end |
2146 end |
1980 else |
2147 else |
1981 lua_pushnil(L); |
2148 lua_pushnil(L); |
1982 lc_addhog:= 1; |
2149 lc_addhog:= 1; |
1983 end; |
2150 end; |
2156 begin |
2323 begin |
2157 at:= LuaToAmmoTypeOrd(L, 1, call, params); |
2324 at:= LuaToAmmoTypeOrd(L, 1, call, params); |
2158 if at >= 0 then |
2325 if at >= 0 then |
2159 begin |
2326 begin |
2160 if np = 4 then |
2327 if np = 4 then |
2161 ScriptSetAmmo(TAmmoType(at), lua_tointeger(L, 2), lua_tointeger(L, 3), lua_tointeger(L, 4), 1) |
2328 ScriptSetAmmo(TAmmoType(at), Trunc(lua_tonumber(L, 2)), Trunc(lua_tonumber(L, 3)), Trunc(lua_tonumber(L, 4)), 1) |
2162 else |
2329 else |
2163 ScriptSetAmmo(TAmmoType(at), lua_tointeger(L, 2), lua_tointeger(L, 3), lua_tointeger(L, 4), lua_tointeger(L, 5)); |
2330 ScriptSetAmmo(TAmmoType(at), Trunc(lua_tonumber(L, 2)), Trunc(lua_tonumber(L, 3)), Trunc(lua_tonumber(L, 4)), Trunc(lua_tonumber(L, 5))); |
2164 end; |
2331 end; |
2165 end; |
2332 end; |
2166 lc_setammo:= 0 |
2333 lc_setammo:= 0 |
2167 end; |
2334 end; |
2168 |
2335 |
2174 begin |
2341 begin |
2175 if CheckLuaParamCount(L, 2, call, params) then |
2342 if CheckLuaParamCount(L, 2, call, params) then |
2176 begin |
2343 begin |
2177 at:= LuaToAmmoTypeOrd(L, 1, call, params); |
2344 at:= LuaToAmmoTypeOrd(L, 1, call, params); |
2178 if at >= 0 then |
2345 if at >= 0 then |
2179 ScriptSetAmmoDelay(TAmmoType(at), lua_tointeger(L, 2)); |
2346 ScriptSetAmmoDelay(TAmmoType(at), Trunc(lua_tonumber(L, 2))); |
2180 end; |
2347 end; |
2181 lc_setammodelay:= 0 |
2348 lc_setammodelay:= 0 |
2182 end; |
|
2183 |
|
2184 function lc_setammostore(L : Plua_State) : LongInt; Cdecl; |
|
2185 begin |
|
2186 if CheckLuaParamCount(L, 4, 'SetAmmoStore', 'loadouts, probabilities, delays, reinforments') then |
|
2187 begin |
|
2188 ScriptAmmoLoadout:= lua_tostring(L, 1); |
|
2189 ScriptAmmoProbability:= lua_tostring(L, 2); |
|
2190 ScriptAmmoDelay:= lua_tostring(L, 3); |
|
2191 ScriptAmmoReinforcement:= lua_tostring(L, 4); |
|
2192 end; |
|
2193 lc_setammostore:= 0 |
|
2194 end; |
2349 end; |
2195 |
2350 |
2196 function lc_getrandom(L : Plua_State) : LongInt; Cdecl; |
2351 function lc_getrandom(L : Plua_State) : LongInt; Cdecl; |
2197 var m : LongInt; |
2352 var m : LongInt; |
2198 begin |
2353 begin |
2199 if CheckLuaParamCount(L, 1, 'GetRandom', 'number') then |
2354 if CheckLuaParamCount(L, 1, 'GetRandom', 'number') then |
2200 begin |
2355 begin |
2201 m:= lua_tointeger(L, 1); |
2356 m:= Trunc(lua_tonumber(L, 1)); |
2202 if (m > 0) then |
2357 if (m > 0) then |
2203 lua_pushinteger(L, GetRandom(m)) |
2358 lua_pushnumber(L, GetRandom(m)) |
2204 else |
2359 else |
2205 begin |
2360 begin |
2206 LuaError('Lua: Tried to pass 0 to GetRandom!'); |
2361 LuaError('Lua: Tried to pass 0 to GetRandom!'); |
2207 lua_pushnil(L); |
2362 lua_pushnil(L); |
2208 end |
2363 end |
2214 |
2369 |
2215 function lc_setwind(L : Plua_State) : LongInt; Cdecl; |
2370 function lc_setwind(L : Plua_State) : LongInt; Cdecl; |
2216 begin |
2371 begin |
2217 if CheckLuaParamCount(L, 1, 'SetWind', 'windSpeed') then |
2372 if CheckLuaParamCount(L, 1, 'SetWind', 'windSpeed') then |
2218 begin |
2373 begin |
2219 cWindSpeed:= int2hwfloat(lua_tointeger(L, 1)) / 100 * cMaxWindSpeed; |
2374 cWindSpeed:= int2hwfloat(Trunc(lua_tonumber(L, 1))) / 100 * cMaxWindSpeed; |
2220 cWindSpeedf:= SignAs(cWindSpeed,cWindSpeed).QWordValue / SignAs(_1,_1).QWordValue; |
2375 cWindSpeedf:= SignAs(cWindSpeed,cWindSpeed).QWordValue / SignAs(_1,_1).QWordValue; |
2221 if cWindSpeed.isNegative then |
2376 if cWindSpeed.isNegative then |
2222 CWindSpeedf := -cWindSpeedf; |
2377 CWindSpeedf := -cWindSpeedf; |
2223 AddVisualGear(0, 0, vgtSmoothWindBar); |
2378 AddVisualGear(0, 0, vgtSmoothWindBar); |
2224 end; |
2379 end; |
2299 begin |
2454 begin |
2300 placed:= false; |
2455 placed:= false; |
2301 if CheckAndFetchLuaParamMinCount(L, 4, call, params, n) then |
2456 if CheckAndFetchLuaParamMinCount(L, 4, call, params, n) then |
2302 begin |
2457 begin |
2303 if not lua_isnoneornil(L, 5) then |
2458 if not lua_isnoneornil(L, 5) then |
2304 tint := lua_tointeger(L, 5) |
2459 tint := Trunc(lua_tonumber(L, 5)) |
2305 else tint := $FFFFFFFF; |
2460 else tint := $FFFFFFFF; |
2306 if not lua_isnoneornil(L, 6) then |
2461 if not lua_isnoneornil(L, 6) then |
2307 behind := lua_toboolean(L, 6) |
2462 behind := lua_toboolean(L, 6) |
2308 else behind := false; |
2463 else behind := false; |
2309 if not lua_isnoneornil(L, 7) then |
2464 if not lua_isnoneornil(L, 7) then |
2314 else flipVert := false; |
2469 else flipVert := false; |
2315 lf:= 0; |
2470 lf:= 0; |
2316 |
2471 |
2317 // accept any amount of landflags, loop is never executed if n<9 |
2472 // accept any amount of landflags, loop is never executed if n<9 |
2318 for i:= 9 to n do |
2473 for i:= 9 to n do |
2319 lf:= lf or lua_tointeger(L, i); |
2474 lf:= lf or Trunc(lua_tonumber(L, i)); |
2320 |
2475 |
2321 n:= LuaToSpriteOrd(L, 3, call, params); |
2476 n:= LuaToSpriteOrd(L, 3, call, params); |
2322 if n >= 0 then |
2477 if n >= 0 then |
2323 begin |
2478 begin |
2324 spr:= TSprite(n); |
2479 spr:= TSprite(n); |
2325 if SpritesData[spr].Surface = nil then |
2480 if SpritesData[spr].Surface = nil then |
2326 LuaError(call + ': ' + EnumToStr(spr) + ' cannot be placed! (required information not loaded)' ) |
2481 LuaError(call + ': ' + EnumToStr(spr) + ' cannot be placed! (required information not loaded)' ) |
2327 else |
2482 else |
2328 placed:= ForcePlaceOnLand( |
2483 placed:= ForcePlaceOnLand( |
2329 lua_tointeger(L, 1) - SpritesData[spr].Width div 2, |
2484 Trunc(lua_tonumber(L, 1)) - SpritesData[spr].Width div 2, |
2330 lua_tointeger(L, 2) - SpritesData[spr].Height div 2, |
2485 Trunc(lua_tonumber(L, 2)) - SpritesData[spr].Height div 2, |
2331 spr, lua_tointeger(L, 4), lf, tint, behind, flipHoriz, flipVert); |
2486 spr, Trunc(lua_tonumber(L, 4)), lf, tint, behind, flipHoriz, flipVert); |
2332 end; |
2487 end; |
2333 end; |
2488 end; |
2334 |
2489 |
2335 lua_pushboolean(L, placed); |
2490 lua_pushboolean(L, placed); |
2336 lc_placesprite:= 1 |
2491 lc_placesprite:= 1 |
2361 else flipVert := false; |
2516 else flipVert := false; |
2362 lf:= 0; |
2517 lf:= 0; |
2363 |
2518 |
2364 // accept any amount of landflags, loop is never executed if n<9 |
2519 // accept any amount of landflags, loop is never executed if n<9 |
2365 for i:= 9 to n do |
2520 for i:= 9 to n do |
2366 lf:= lf or lua_tointeger(L, i); |
2521 lf:= lf or Trunc(lua_tonumber(L, i)); |
2367 |
2522 |
2368 n:= LuaToSpriteOrd(L, 3, call, params); |
2523 n:= LuaToSpriteOrd(L, 3, call, params); |
2369 if n >= 0 then |
2524 if n >= 0 then |
2370 begin |
2525 begin |
2371 spr:= TSprite(n); |
2526 spr:= TSprite(n); |
2372 if SpritesData[spr].Surface = nil then |
2527 if SpritesData[spr].Surface = nil then |
2373 LuaError(call + ': ' + EnumToStr(spr) + ' cannot be placed! (required information not loaded)' ) |
2528 LuaError(call + ': ' + EnumToStr(spr) + ' cannot be placed! (required information not loaded)' ) |
2374 else |
2529 else |
2375 EraseLand( |
2530 EraseLand( |
2376 lua_tointeger(L, 1) - SpritesData[spr].Width div 2, |
2531 Trunc(lua_tonumber(L, 1)) - SpritesData[spr].Width div 2, |
2377 lua_tointeger(L, 2) - SpritesData[spr].Height div 2, |
2532 Trunc(lua_tonumber(L, 2)) - SpritesData[spr].Height div 2, |
2378 spr, lua_tointeger(L, 4), lf, eraseOnLFMatch, onlyEraseLF, flipHoriz, flipVert); |
2533 spr, Trunc(lua_tonumber(L, 4)), lf, eraseOnLFMatch, onlyEraseLF, flipHoriz, flipVert); |
2379 end; |
2534 end; |
2380 end; |
2535 end; |
2381 lc_erasesprite:= 0 |
2536 lc_erasesprite:= 0 |
2382 end; |
2537 end; |
2383 |
2538 |
2385 var placed: boolean; |
2540 var placed: boolean; |
2386 begin |
2541 begin |
2387 placed:= false; |
2542 placed:= false; |
2388 if CheckLuaParamCount(L, 3, 'PlaceGirder', 'x, y, frameIdx') then |
2543 if CheckLuaParamCount(L, 3, 'PlaceGirder', 'x, y, frameIdx') then |
2389 placed:= TryPlaceOnLandSimple( |
2544 placed:= TryPlaceOnLandSimple( |
2390 lua_tointeger(L, 1) - SpritesData[sprAmGirder].Width div 2, |
2545 Trunc(lua_tonumber(L, 1)) - SpritesData[sprAmGirder].Width div 2, |
2391 lua_tointeger(L, 2) - SpritesData[sprAmGirder].Height div 2, |
2546 Trunc(lua_tonumber(L, 2)) - SpritesData[sprAmGirder].Height div 2, |
2392 sprAmGirder, lua_tointeger(L, 3), true, false); |
2547 sprAmGirder, Trunc(lua_tonumber(L, 3)), true, false); |
2393 |
2548 |
2394 lua_pushboolean(L, placed); |
2549 lua_pushboolean(L, placed); |
2395 lc_placegirder:= 1 |
2550 lc_placegirder:= 1 |
2396 end; |
2551 end; |
2397 |
2552 |
|
2553 function lc_placerubber(L : Plua_State) : LongInt; Cdecl; |
|
2554 var placed: boolean; |
|
2555 begin |
|
2556 placed:= false; |
|
2557 if CheckLuaParamCount(L, 3, 'PlaceRubber', 'x, y, frameIdx') then |
|
2558 placed:= TryPlaceOnLand( |
|
2559 Trunc(lua_tonumber(L, 1)) - SpritesData[sprAmRubber].Width div 2, |
|
2560 Trunc(lua_tonumber(L, 2)) - SpritesData[sprAmRubber].Height div 2, |
|
2561 sprAmRubber, Trunc(lua_tonumber(L, 3)), true, lfBouncy); |
|
2562 |
|
2563 lua_pushboolean(L, placed); |
|
2564 lc_placerubber:= 1 |
|
2565 end; |
|
2566 |
2398 function lc_getcurammotype(L : Plua_State): LongInt; Cdecl; |
2567 function lc_getcurammotype(L : Plua_State): LongInt; Cdecl; |
2399 begin |
2568 begin |
2400 if (CurrentHedgehog <> nil) and (CheckLuaParamCount(L, 0, 'GetCurAmmoType', '')) then |
2569 if (CurrentHedgehog <> nil) and (CheckLuaParamCount(L, 0, 'GetCurAmmoType', '')) then |
2401 lua_pushinteger(L, ord(CurrentHedgehog^.CurAmmoType)) |
2570 lua_pushnumber(L, ord(CurrentHedgehog^.CurAmmoType)) |
2402 else |
2571 else |
2403 lua_pushinteger(L, ord(amNothing)); |
2572 lua_pushnumber(L, ord(amNothing)); |
2404 lc_getcurammotype := 1; |
2573 lc_getcurammotype := 1; |
2405 end; |
2574 end; |
2406 |
2575 |
2407 function lc_savecampaignvar(L : Plua_State): LongInt; Cdecl; |
2576 function lc_savecampaignvar(L : Plua_State): LongInt; Cdecl; |
2408 begin |
2577 begin |
2422 function lc_hidehog(L: Plua_State): LongInt; Cdecl; |
2591 function lc_hidehog(L: Plua_State): LongInt; Cdecl; |
2423 var gear: PGear; |
2592 var gear: PGear; |
2424 begin |
2593 begin |
2425 if CheckLuaParamCount(L, 1, 'HideHog', 'gearUid') then |
2594 if CheckLuaParamCount(L, 1, 'HideHog', 'gearUid') then |
2426 begin |
2595 begin |
2427 gear:= GearByUID(lua_tointeger(L, 1)); |
2596 gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
2428 HideHog(gear^.hedgehog) |
2597 if (gear <> nil) and (gear^.hedgehog <> nil) then |
2429 end; |
2598 begin |
2430 lc_hidehog := 0; |
2599 HideHog(gear^.hedgehog); |
|
2600 lua_pushboolean(L, true); |
|
2601 end |
|
2602 else |
|
2603 lua_pushboolean(L, false); |
|
2604 end; |
|
2605 lc_hidehog := 1; |
2431 end; |
2606 end; |
2432 |
2607 |
2433 function lc_restorehog(L: Plua_State): LongInt; Cdecl; |
2608 function lc_restorehog(L: Plua_State): LongInt; Cdecl; |
2434 var i, h: LongInt; |
2609 var i, h: LongInt; |
2435 uid: LongWord; |
2610 uid: LongWord; |
2436 begin |
2611 begin |
2437 if CheckLuaParamCount(L, 1, 'RestoreHog', 'gearUid') then |
2612 if CheckLuaParamCount(L, 1, 'RestoreHog', 'gearUid') then |
2438 begin |
2613 begin |
2439 uid:= LongWord(lua_tointeger(L, 1)); |
2614 uid:= LongWord(Trunc(lua_tonumber(L, 1))); |
2440 if TeamsCount > 0 then |
2615 if TeamsCount > 0 then |
2441 for i:= 0 to Pred(TeamsCount) do |
2616 for i:= 0 to Pred(TeamsCount) do |
2442 for h:= 0 to cMaxHHIndex do |
2617 for h:= 0 to cMaxHHIndex do |
2443 if (TeamsArray[i]^.Hedgehogs[h].GearHidden <> nil) and (TeamsArray[i]^.Hedgehogs[h].GearHidden^.uid = uid) then |
2618 if (TeamsArray[i]^.Hedgehogs[h].GearHidden <> nil) and (TeamsArray[i]^.Hedgehogs[h].GearHidden^.uid = uid) then |
2444 begin |
2619 begin |
2454 var rtn: Boolean; |
2629 var rtn: Boolean; |
2455 begin |
2630 begin |
2456 if CheckLuaParamCount(L, 5, 'TestRectForObstacle', 'x1, y1, x2, y2, landOnly') then |
2631 if CheckLuaParamCount(L, 5, 'TestRectForObstacle', 'x1, y1, x2, y2, landOnly') then |
2457 begin |
2632 begin |
2458 rtn:= TestRectangleForObstacle( |
2633 rtn:= TestRectangleForObstacle( |
2459 lua_tointeger(L, 1), |
2634 Trunc(lua_tonumber(L, 1)), |
2460 lua_tointeger(L, 2), |
2635 Trunc(lua_tonumber(L, 2)), |
2461 lua_tointeger(L, 3), |
2636 Trunc(lua_tonumber(L, 3)), |
2462 lua_tointeger(L, 4), |
2637 Trunc(lua_tonumber(L, 4)), |
2463 lua_toboolean(L, 5) |
2638 lua_toboolean(L, 5) |
2464 ); |
2639 ); |
2465 lua_pushboolean(L, rtn); |
2640 lua_pushboolean(L, rtn); |
2466 end |
2641 end |
2467 else |
2642 else |
2471 |
2646 |
2472 |
2647 |
2473 function lc_getgravity(L : Plua_State) : LongInt; Cdecl; |
2648 function lc_getgravity(L : Plua_State) : LongInt; Cdecl; |
2474 begin |
2649 begin |
2475 if CheckLuaParamCount(L, 0, 'GetGravity', '') then |
2650 if CheckLuaParamCount(L, 0, 'GetGravity', '') then |
2476 lua_pushinteger(L, hwRound(SignAs(_0_5, cGravity) + (cGravity * 50 / cMaxWindSpeed))); |
2651 lua_pushnumber(L, hwRound(SignAs(_0_5, cGravity) + (cGravity * 50 / cMaxWindSpeed))); |
2477 lc_getgravity:= 1 |
2652 lc_getgravity:= 1 |
2478 end; |
2653 end; |
2479 |
2654 |
2480 function lc_setgravity(L : Plua_State) : LongInt; Cdecl; |
2655 function lc_setgravity(L : Plua_State) : LongInt; Cdecl; |
2481 begin |
2656 begin |
2482 if CheckLuaParamCount(L, 1, 'SetGravity', 'percent') then |
2657 if CheckLuaParamCount(L, 1, 'SetGravity', 'percent') then |
2483 begin |
2658 begin |
2484 cGravity:= _0_02 * lua_tointeger(L, 1) * cMaxWindSpeed; |
2659 cGravity:= _0_02 * Trunc(lua_tonumber(L, 1)) * cMaxWindSpeed; |
2485 cGravityf:= 0.00025 * lua_tointeger(L, 1) * 0.02 |
2660 cGravityf:= 0.00025 * Trunc(lua_tonumber(L, 1)) * 0.02 |
2486 end; |
2661 end; |
2487 lc_setgravity:= 0 |
2662 lc_setgravity:= 0 |
2488 end; |
2663 end; |
2489 |
2664 |
2490 function lc_setwaterline(L : Plua_State) : LongInt; Cdecl; |
2665 function lc_setwaterline(L : Plua_State) : LongInt; Cdecl; |
2491 var iterator: PGear; |
2666 var iterator: PGear; |
2492 begin |
2667 begin |
2493 if CheckLuaParamCount(L, 1, 'SetWaterLine', 'waterline') then |
2668 if CheckLuaParamCount(L, 1, 'SetWaterLine', 'waterline') then |
2494 begin |
2669 begin |
2495 cWaterLine:= lua_tointeger(L,1); |
2670 cWaterLine:= Trunc(lua_tonumber(L,1)); |
2496 AllInactive:= false; |
2671 AllInactive:= false; |
2497 iterator:= GearsList; |
2672 iterator:= GearsList; |
2498 while iterator <> nil do |
2673 while iterator <> nil do |
2499 begin |
2674 begin |
2500 if not (iterator^.Kind in [gtPortal, gtAirAttack]) and (iterator^.Message and (gmAllStoppable or gmLJump or gmHJump) = 0) then |
2675 if not (iterator^.Kind in [gtPortal, gtAirAttack]) and (iterator^.Message and (gmAllStoppable or gmLJump or gmHJump) = 0) then |
2534 |
2709 |
2535 |
2710 |
2536 function lc_declareachievement(L : Plua_State) : LongInt; Cdecl; |
2711 function lc_declareachievement(L : Plua_State) : LongInt; Cdecl; |
2537 begin |
2712 begin |
2538 if CheckLuaParamCount(L, 4, 'DeclareAchievement', 'achievementId, teamname, location, value') then |
2713 if CheckLuaParamCount(L, 4, 'DeclareAchievement', 'achievementId, teamname, location, value') then |
2539 declareAchievement(lua_tostring(L, 1), lua_tostring(L, 2), lua_tostring(L, 3), lua_tointeger(L, 4)); |
2714 declareAchievement(lua_tostring(L, 1), lua_tostring(L, 2), lua_tostring(L, 3), Trunc(lua_tonumber(L, 4))); |
2540 lc_declareachievement:= 0 |
2715 lc_declareachievement:= 0 |
2541 end; |
2716 end; |
2542 |
2717 |
|
2718 function lc_getammoname(L : Plua_state) : LongInt; Cdecl; |
|
2719 var np, at: LongInt; |
|
2720 ignoreOverwrite: Boolean; |
|
2721 const call = 'GetAmmoName'; |
|
2722 params = 'ammoType [, ignoreOverwrite ]'; |
|
2723 begin |
|
2724 if CheckAndFetchParamCountRange(L, 1, 2, call, params, np) then |
|
2725 begin |
|
2726 at:= LuaToAmmoTypeOrd(L, 1, call, params); |
|
2727 ignoreOverwrite := false; |
|
2728 if np > 1 then |
|
2729 ignoreOverwrite := lua_toboolean(L, 2); |
|
2730 if at >= 0 then |
|
2731 if (not ignoreOverwrite) and (length(trluaammo[Ammoz[TAmmoType(at)].NameId]) > 0) then |
|
2732 lua_pushstring(L, PChar(trluaammo[Ammoz[TAmmoType(at)].NameId])) |
|
2733 else |
|
2734 lua_pushstring(L, PChar(trammo[Ammoz[TAmmoType(at)].NameId])); |
|
2735 end |
|
2736 else |
|
2737 lua_pushnil(L); |
|
2738 lc_getammoname:= 1; |
|
2739 end; |
|
2740 |
2543 function lc_startghostpoints(L : Plua_State) : LongInt; Cdecl; |
2741 function lc_startghostpoints(L : Plua_State) : LongInt; Cdecl; |
2544 begin |
2742 begin |
2545 if CheckLuaParamCount(L, 1, 'StartGhostPoints', 'count') then |
2743 if CheckLuaParamCount(L, 1, 'StartGhostPoints', 'count') then |
2546 startGhostPoints(lua_tointeger(L, 1)); |
2744 startGhostPoints(Trunc(lua_tonumber(L, 1))); |
2547 lc_startghostpoints:= 0 |
2745 lc_startghostpoints:= 0 |
2548 end; |
2746 end; |
2549 |
2747 |
2550 function lc_dumppoint(L : Plua_State) : LongInt; Cdecl; |
2748 function lc_dumppoint(L : Plua_State) : LongInt; Cdecl; |
2551 begin |
2749 begin |
2552 if CheckLuaParamCount(L, 2, 'DumpPoint', 'x, y') then |
2750 if CheckLuaParamCount(L, 2, 'DumpPoint', 'x, y') then |
2553 dumpPoint(lua_tointeger(L, 1), lua_tointeger(L, 2)); |
2751 dumpPoint(Trunc(lua_tonumber(L, 1)), Trunc(lua_tonumber(L, 2))); |
2554 lc_dumppoint:= 0 |
2752 lc_dumppoint:= 0 |
2555 end; |
2753 end; |
2556 |
2754 |
2557 |
2755 |
2558 procedure ScriptFlushPoints(); |
2756 procedure ScriptFlushPoints(); |
2566 var np, param: LongInt; |
2764 var np, param: LongInt; |
2567 begin |
2765 begin |
2568 if CheckAndFetchParamCountRange(L, 2, 4, 'AddPoint', 'x, y [, width [, erase] ]', np) then |
2766 if CheckAndFetchParamCountRange(L, 2, 4, 'AddPoint', 'x, y [, width [, erase] ]', np) then |
2569 begin |
2767 begin |
2570 // x |
2768 // x |
2571 param:= LongInt(lua_tointeger(L,1)); |
2769 param:= LongInt(Trunc(lua_tonumber(L,1))); |
2572 PointsBuffer:= PointsBuffer + char((param shr 8) and $FF); |
2770 PointsBuffer:= PointsBuffer + char((param shr 8) and $FF); |
2573 PointsBuffer:= PointsBuffer + char((param and $FF)); |
2771 PointsBuffer:= PointsBuffer + char((param and $FF)); |
2574 // y |
2772 // y |
2575 param:= LongInt(lua_tointeger(L,2)); |
2773 param:= LongInt(Trunc(lua_tonumber(L,2))); |
2576 PointsBuffer:= PointsBuffer + char((param shr 8) and $FF); |
2774 PointsBuffer:= PointsBuffer + char((param shr 8) and $FF); |
2577 PointsBuffer:= PointsBuffer + char((param and $FF)); |
2775 PointsBuffer:= PointsBuffer + char((param and $FF)); |
2578 // width |
2776 // width |
2579 if np > 2 then |
2777 if np > 2 then |
2580 begin |
2778 begin |
2581 param:= lua_tointeger(L,3); |
2779 param:= Trunc(lua_tonumber(L,3)); |
2582 param:= (param or $80); |
2780 param:= (param or $80); |
2583 // erase |
2781 // erase |
2584 if (np > 3) and lua_toboolean(L, 4) then |
2782 if (np > 3) and lua_toboolean(L, 4) then |
2585 param:= (param or $40); |
2783 param:= (param or $40); |
2586 PointsBuffer:= PointsBuffer + char(param); |
2784 PointsBuffer:= PointsBuffer + char(param); |
2676 end; |
2874 end; |
2677 |
2875 |
2678 function ScriptGetInteger(name : shortstring) : LongInt; |
2876 function ScriptGetInteger(name : shortstring) : LongInt; |
2679 begin |
2877 begin |
2680 lua_getglobal(luaState, Str2PChar(name)); |
2878 lua_getglobal(luaState, Str2PChar(name)); |
2681 ScriptGetInteger:= lua_tointeger(luaState, -1); |
2879 ScriptGetInteger:= Trunc(lua_tonumber(luaState, -1)); |
2682 lua_pop(luaState, 1); |
2880 lua_pop(luaState, 1); |
2683 end; |
2881 end; |
2684 |
2882 |
2685 function ScriptGetString(name : shortstring) : shortstring; |
2883 function ScriptGetString(name : shortstring) : shortstring; |
2686 begin |
2884 begin |
2687 lua_getglobal(luaState, Str2PChar(name)); |
2885 lua_getglobal(luaState, Str2PChar(name)); |
2688 ScriptGetString:= lua_tostring(luaState, -1); |
2886 ScriptGetString:= lua_tostring(luaState, -1); |
|
2887 lua_pop(luaState, 1); |
|
2888 end; |
|
2889 |
|
2890 function ScriptGetAnsiString(name : shortstring) : ansistring; |
|
2891 begin |
|
2892 lua_getglobal(luaState, Str2PChar(name)); |
|
2893 ScriptGetAnsiString:= lua_tostringa(luaState, -1); |
2689 lua_pop(luaState, 1); |
2894 lua_pop(luaState, 1); |
2690 end; |
2895 end; |
2691 |
2896 |
2692 procedure ScriptOnPreviewInit; |
2897 procedure ScriptOnPreviewInit; |
2693 begin |
2898 begin |
2719 exit; |
2924 exit; |
2720 |
2925 |
2721 // push game variables so they may be modified by the script |
2926 // push game variables so they may be modified by the script |
2722 ScriptSetInteger('CursorX', CursorPoint.X); |
2927 ScriptSetInteger('CursorX', CursorPoint.X); |
2723 ScriptSetInteger('CursorY', CursorPoint.Y); |
2928 ScriptSetInteger('CursorY', CursorPoint.Y); |
2724 ScriptSetInteger('BorderColor', ExplosionBorderColor); |
|
2725 ScriptSetInteger('GameFlags', GameFlags); |
2929 ScriptSetInteger('GameFlags', GameFlags); |
|
2930 ScriptSetInteger('WorldEdge', ord(WorldEdge)); |
2726 ScriptSetString('Seed', cSeed); |
2931 ScriptSetString('Seed', cSeed); |
2727 ScriptSetInteger('TemplateFilter', cTemplateFilter); |
2932 ScriptSetInteger('TemplateFilter', cTemplateFilter); |
2728 ScriptSetInteger('TemplateNumber', LuaTemplateNumber); |
2933 ScriptSetInteger('TemplateNumber', LuaTemplateNumber); |
2729 ScriptSetInteger('MapGen', ord(cMapGen)); |
2934 ScriptSetInteger('MapGen', ord(cMapGen)); |
2730 ScriptSetInteger('MapFeatureSize', cFeatureSize); |
2935 ScriptSetInteger('MapFeatureSize', cFeatureSize); |
2737 ScriptSetInteger('DamagePercent', cDamagePercent); |
2942 ScriptSetInteger('DamagePercent', cDamagePercent); |
2738 ScriptSetInteger('RopePercent', cRopePercent); |
2943 ScriptSetInteger('RopePercent', cRopePercent); |
2739 ScriptSetInteger('MinesNum', cLandMines); |
2944 ScriptSetInteger('MinesNum', cLandMines); |
2740 ScriptSetInteger('MinesTime', cMinesTime); |
2945 ScriptSetInteger('MinesTime', cMinesTime); |
2741 ScriptSetInteger('MineDudPercent', cMineDudPercent); |
2946 ScriptSetInteger('MineDudPercent', cMineDudPercent); |
|
2947 ScriptSetInteger('AirMinesNum', cAirMines); |
2742 ScriptSetInteger('Explosives', cExplosives); |
2948 ScriptSetInteger('Explosives', cExplosives); |
2743 ScriptSetInteger('Delay', cInactDelay); |
2949 ScriptSetInteger('Delay', cInactDelay); |
2744 ScriptSetInteger('Ready', cReadyDelay); |
2950 ScriptSetInteger('Ready', cReadyDelay); |
2745 ScriptSetInteger('SuddenDeathTurns', cSuddenDTurns); |
2951 ScriptSetInteger('SuddenDeathTurns', cSuddenDTurns); |
2746 ScriptSetInteger('WaterRise', cWaterRise); |
2952 ScriptSetInteger('WaterRise', cWaterRise); |
2747 ScriptSetInteger('HealthDecrease', cHealthDecrease); |
2953 ScriptSetInteger('HealthDecrease', cHealthDecrease); |
2748 ScriptSetInteger('GetAwayTime', cGetAwayTime); |
2954 ScriptSetInteger('GetAwayTime', cGetAwayTime); |
|
2955 ScriptSetInteger('AmmoTypeMax', Ord(High(TAmmoType))); |
2749 ScriptSetString('Map', cMapName); |
2956 ScriptSetString('Map', cMapName); |
2750 ScriptSetString('Theme', Theme); |
2957 ScriptSetString('Theme', Theme); |
2751 ScriptSetString('Goals', ''); |
2958 ScriptSetString('Goals', ''); |
2752 |
2959 |
2753 ScriptCall('onGameInit'); |
2960 ScriptCall('onGameInit'); |
2757 cTemplateFilter := ScriptGetInteger('TemplateFilter'); |
2964 cTemplateFilter := ScriptGetInteger('TemplateFilter'); |
2758 LuaTemplateNumber:= ScriptGetInteger('TemplateNumber'); |
2965 LuaTemplateNumber:= ScriptGetInteger('TemplateNumber'); |
2759 cMapGen := TMapGen(ScriptGetInteger('MapGen')); |
2966 cMapGen := TMapGen(ScriptGetInteger('MapGen')); |
2760 cFeatureSize := ScriptGetInteger('MapFeatureSize'); |
2967 cFeatureSize := ScriptGetInteger('MapFeatureSize'); |
2761 GameFlags := ScriptGetInteger('GameFlags'); |
2968 GameFlags := ScriptGetInteger('GameFlags'); |
|
2969 WorldEdge := TWorldEdge(ScriptGetInteger('WorldEdge')); |
2762 cHedgehogTurnTime:= ScriptGetInteger('TurnTime'); |
2970 cHedgehogTurnTime:= ScriptGetInteger('TurnTime'); |
2763 cCaseFactor := ScriptGetInteger('CaseFreq'); |
2971 cCaseFactor := ScriptGetInteger('CaseFreq'); |
2764 cHealthCaseProb := ScriptGetInteger('HealthCaseProb'); |
2972 cHealthCaseProb := ScriptGetInteger('HealthCaseProb'); |
2765 cHealthCaseAmount:= ScriptGetInteger('HealthCaseAmount'); |
2973 cHealthCaseAmount:= ScriptGetInteger('HealthCaseAmount'); |
2766 cDamagePercent := ScriptGetInteger('DamagePercent'); |
2974 cDamagePercent := ScriptGetInteger('DamagePercent'); |
2767 cRopePercent := ScriptGetInteger('RopePercent'); |
2975 cRopePercent := ScriptGetInteger('RopePercent'); |
2768 cLandMines := ScriptGetInteger('MinesNum'); |
2976 cLandMines := ScriptGetInteger('MinesNum'); |
2769 cMinesTime := ScriptGetInteger('MinesTime'); |
2977 cMinesTime := ScriptGetInteger('MinesTime'); |
2770 cMineDudPercent := ScriptGetInteger('MineDudPercent'); |
2978 cMineDudPercent := ScriptGetInteger('MineDudPercent'); |
|
2979 cAirMines := ScriptGetInteger('AirMinesNum'); |
2771 cExplosives := ScriptGetInteger('Explosives'); |
2980 cExplosives := ScriptGetInteger('Explosives'); |
2772 cInactDelay := ScriptGetInteger('Delay'); |
2981 cInactDelay := ScriptGetInteger('Delay'); |
2773 cReadyDelay := ScriptGetInteger('Ready'); |
2982 cReadyDelay := ScriptGetInteger('Ready'); |
2774 cSuddenDTurns := ScriptGetInteger('SuddenDeathTurns'); |
2983 cSuddenDTurns := ScriptGetInteger('SuddenDeathTurns'); |
2775 cWaterRise := ScriptGetInteger('WaterRise'); |
2984 cWaterRise := ScriptGetInteger('WaterRise'); |
2778 |
2987 |
2779 if cMapName <> ScriptGetString('Map') then |
2988 if cMapName <> ScriptGetString('Map') then |
2780 ParseCommand('map ' + ScriptGetString('Map'), true, true); |
2989 ParseCommand('map ' + ScriptGetString('Map'), true, true); |
2781 if ScriptGetString('Theme') <> '' then |
2990 if ScriptGetString('Theme') <> '' then |
2782 ParseCommand('theme ' + ScriptGetString('Theme'), true, true); |
2991 ParseCommand('theme ' + ScriptGetString('Theme'), true, true); |
2783 LuaGoals:= ScriptGetString('Goals'); |
2992 LuaGoals:= ScriptGetAnsiString('Goals'); |
2784 |
2993 |
2785 // Support lua changing the ammo layout - assume all hogs have same ammo, note this might leave a few ammo stores lying around. |
2994 // Support lua changing the ammo layout - assume all hogs have same ammo, note this might leave a few ammo stores lying around. |
2786 k:= 0; |
2995 k:= 0; |
2787 if (GameFlags and gfSharedAmmo) <> 0 then |
2996 if (GameFlags and gfSharedAmmo) <> 0 then |
2788 for i:= 0 to Pred(ClansCount) do |
2997 for i:= 0 to Pred(ClansCount) do |
2837 end; |
3046 end; |
2838 |
3047 |
2839 // custom script loader via physfs, passed to lua_load |
3048 // custom script loader via physfs, passed to lua_load |
2840 const BUFSIZE = 1024; |
3049 const BUFSIZE = 1024; |
2841 |
3050 |
|
3051 var inComment: boolean; |
|
3052 var inQuote: boolean; |
|
3053 var locSum: LongWord; |
|
3054 var braceCount: LongWord; |
|
3055 var wordCount: LongWord; |
|
3056 var lastChar: char; |
|
3057 // ⭒⭐⭒✨⭐⭒✨⭐☆✨⭐✨✧✨☆✨✧✨☆⭒✨☆⭐⭒☆✧✨⭒✨⭐✧⭒☆⭒✧☆✨✧⭐☆✨☆✧⭒✨✧⭒☆⭐☆✧ |
|
3058 function ScriptReader(L: Plua_State; f: PFSFile; sz: Psize_t) : PChar; Cdecl; |
|
3059 var mybuf: PChar; |
|
3060 i: LongInt; |
|
3061 begin |
|
3062 SetRandomSeed(cSeed,true); |
|
3063 mybuf := physfsReader(L, f, sz); |
|
3064 if (mybuf <> nil) and ((sz^) > 0) then |
|
3065 begin |
|
3066 for i:= 0 to sz^-1 do |
|
3067 begin |
|
3068 if (lastChar = '-') and (mybuf[i] = '-') then |
|
3069 inComment := true |
|
3070 // gonna add any non-magic whitespace and skip - just to make comment avoidance easier |
|
3071 else if not inComment and (byte(mybuf[i]) > $20) and (byte(mybuf[i]) < $7F) and (mybuf[i]<>'-') then |
|
3072 begin |
|
3073 AddRandomness(byte(mybuf[i])); // wish I had the seed... |
|
3074 CheckSum := CheckSum xor GetRandom($FFFFFFFF); |
|
3075 end; |
|
3076 lastChar := mybuf[i]; |
|
3077 if (byte(mybuf[i]) = $0D) or (byte(mybuf[i]) = $0A) then |
|
3078 inComment := false |
|
3079 end; |
|
3080 end; |
|
3081 ScriptReader:= mybuf |
|
3082 end; |
|
3083 function ScriptLocaleReader(L: Plua_State; f: PFSFile; sz: Psize_t) : PChar; Cdecl; |
|
3084 var mybuf: PChar; |
|
3085 i: LongInt; |
|
3086 begin |
|
3087 mybuf := physfsReader(L, f, sz); |
|
3088 if (mybuf <> nil) and ((sz^) > 0) then |
|
3089 begin |
|
3090 for i:= 0 to sz^-1 do |
|
3091 begin |
|
3092 if not inComment and (mybuf[i] = '"') and (lastChar <> '\') then |
|
3093 inQuote := not inQuote; |
|
3094 if not inQuote and (lastChar = '-') and (mybuf[i] = '-') then |
|
3095 inComment := true; |
|
3096 if not inComment and (not inQuote) then |
|
3097 locSum := locSum xor (byte(mybuf[i]) shl (i mod 4)); |
|
3098 if not inComment and (not inQuote) and |
|
3099 ((mybuf[i] = '(') or |
|
3100 (mybuf[i] = ')') or |
|
3101 (mybuf[i] = '+') or |
|
3102 (mybuf[i] = '#') or |
|
3103 (braceCount > 2) or |
|
3104 (wordCount > 6)) then |
|
3105 CheckSum := locSum; |
|
3106 if not inComment and (not inQuote) and ((mybuf[i] = '{') or (mybuf[i] = '}')) then |
|
3107 inc(braceCount); |
|
3108 if not inComment and (not inQuote) and |
|
3109 (((byte(mybuf[i]) > $40) and (byte(mybuf[i]) < $5B)) or |
|
3110 ((byte(mybuf[i]) > $60) and (byte(mybuf[i]) < $7B)) or |
|
3111 ((byte(mybuf[i]) >= $30) and (byte(mybuf[i]) < $3A))) then |
|
3112 inc(wordCount); |
|
3113 lastChar := mybuf[i]; |
|
3114 if (byte(mybuf[i]) = $0D) or (byte(mybuf[i]) = $0A) then |
|
3115 inComment := false |
|
3116 end; |
|
3117 end; |
|
3118 ScriptLocaleReader:= mybuf |
|
3119 end; |
|
3120 // ⭒⭐⭒✨⭐⭒✨⭐☆✨⭐✨✧✨☆✨✧✨☆⭒✨☆⭐⭒☆✧✨⭒✨⭐✧⭒☆⭒✧☆✨✧⭐☆✨☆✧⭒✨✧⭒☆⭐☆✧ |
|
3121 |
2842 procedure ScriptLoad(name : shortstring); |
3122 procedure ScriptLoad(name : shortstring); |
2843 var ret : LongInt; |
3123 var ret : LongInt; |
2844 s : shortstring; |
3124 s : shortstring; |
2845 f : PFSFile; |
3125 f : PFSFile; |
2846 buf : array[0..Pred(BUFSIZE)] of byte; |
3126 buf : array[0..Pred(BUFSIZE)] of byte; |
2847 begin |
3127 begin |
|
3128 inComment:= false; |
|
3129 inQuote:= false; |
|
3130 lastChar:= 'X'; |
|
3131 braceCount:= 0; |
|
3132 wordCount:= 0; |
|
3133 locSum:= 0; |
2848 s:= cPathz[ptData] + name; |
3134 s:= cPathz[ptData] + name; |
2849 if not pfsExists(s) then |
3135 if not pfsExists(s) then |
2850 begin |
3136 begin |
2851 AddFileLog('[LUA] Script not found: ' + name); |
3137 AddFileLog('[LUA] Script not found: ' + name); |
2852 exit; |
3138 exit; |
2870 WriteLnToConsole('Lua: ' + name + ' loaded'); |
3160 WriteLnToConsole('Lua: ' + name + ' loaded'); |
2871 // call the script file |
3161 // call the script file |
2872 lua_pcall(luaState, 0, 0, 0); |
3162 lua_pcall(luaState, 0, 0, 0); |
2873 ScriptLoaded:= true |
3163 ScriptLoaded:= true |
2874 end; |
3164 end; |
2875 hedgewarsMountPackage(Str2PChar(copy(s, 1, length(s)-4)+'.hwp')); |
|
2876 end; |
3165 end; |
2877 |
3166 |
2878 procedure SetGlobals; |
3167 procedure SetGlobals; |
2879 begin |
3168 begin |
2880 ScriptSetInteger('TurnTimeLeft', TurnTimeLeft); |
3169 ScriptSetInteger('TurnTimeLeft', TurnTimeLeft); |
|
3170 ScriptSetInteger('ReadyTimeLeft', ReadyTimeLeft); |
2881 ScriptSetInteger('GameTime', GameTicks); |
3171 ScriptSetInteger('GameTime', GameTicks); |
2882 ScriptSetInteger('TotalRounds', TotalRounds); |
3172 ScriptSetInteger('TotalRounds', TotalRounds); |
2883 ScriptSetInteger('WaterLine', cWaterLine); |
3173 ScriptSetInteger('WaterLine', cWaterLine); |
2884 if isCursorVisible and (not bShowAmmoMenu) then |
3174 if isCursorVisible and (not bShowAmmoMenu) then |
2885 begin |
3175 begin |
2922 // Otherwise globals might be changed by Lua, but then unexpectatly overwritten by engine when a ScriptCall is triggered by whatever Lua is doing! |
3212 // Otherwise globals might be changed by Lua, but then unexpectatly overwritten by engine when a ScriptCall is triggered by whatever Lua is doing! |
2923 // Sure, one could work around that in engine (e.g. by setting writable globals in SetGlobals only when their engine-side value has actually changed since SetGlobals was called the last time...), but things just get messier and messier then. |
3213 // Sure, one could work around that in engine (e.g. by setting writable globals in SetGlobals only when their engine-side value has actually changed since SetGlobals was called the last time...), but things just get messier and messier then. |
2924 // It is inconsistent anyway to have some globals be read-only and others not with no indication whatsoever. |
3214 // It is inconsistent anyway to have some globals be read-only and others not with no indication whatsoever. |
2925 // -- sheepluva |
3215 // -- sheepluva |
2926 TurnTimeLeft:= ScriptGetInteger('TurnTimeLeft'); |
3216 TurnTimeLeft:= ScriptGetInteger('TurnTimeLeft'); |
|
3217 ReadyTimeLeft:= ScriptGetInteger('ReadyTimeLeft'); |
2927 end; |
3218 end; |
2928 |
3219 |
2929 procedure ScriptCall(fname : shortstring); |
3220 procedure ScriptCall(fname : shortstring); |
2930 begin |
3221 begin |
2931 if (not ScriptLoaded) or (not ScriptExists(fname)) then |
3222 if (not ScriptLoaded) or (not ScriptExists(fname)) then |
2981 begin |
3272 begin |
2982 if (not ScriptLoaded) or (not ScriptExists(fname)) then |
3273 if (not ScriptLoaded) or (not ScriptExists(fname)) then |
2983 exit(0); |
3274 exit(0); |
2984 SetGlobals; |
3275 SetGlobals; |
2985 lua_getglobal(luaState, Str2PChar(fname)); |
3276 lua_getglobal(luaState, Str2PChar(fname)); |
2986 lua_pushinteger(luaState, par1); |
3277 lua_pushnumber(luaState, par1); |
2987 lua_pushinteger(luaState, par2); |
3278 lua_pushnumber(luaState, par2); |
2988 lua_pushinteger(luaState, par3); |
3279 lua_pushnumber(luaState, par3); |
2989 lua_pushinteger(luaState, par4); |
3280 lua_pushnumber(luaState, par4); |
2990 ScriptCall:= 0; |
3281 ScriptCall:= 0; |
2991 if lua_pcall(luaState, 4, 1, 0) <> 0 then |
3282 if lua_pcall(luaState, 4, 1, 0) <> 0 then |
2992 begin |
3283 begin |
2993 LuaError('Error while calling ' + fname + ': ' + lua_tostring(luaState, -1)); |
3284 LuaError('Error while calling ' + fname + ': ' + lua_tostring(luaState, -1)); |
2994 lua_pop(luaState, 1) |
3285 lua_pop(luaState, 1) |
2995 end |
3286 end |
2996 else |
3287 else |
2997 begin |
3288 begin |
2998 ScriptCall:= lua_tointeger(luaState, -1); |
3289 ScriptCall:= Trunc(lua_tonumber(luaState, -1)); |
2999 lua_pop(luaState, 1) |
3290 lua_pop(luaState, 1) |
3000 end; |
3291 end; |
3001 GetGlobals; |
3292 GetGlobals; |
3002 end; |
3293 end; |
3003 |
3294 |
3210 ScriptSetInteger(EnumToStr(spr), ord(spr)); |
3502 ScriptSetInteger(EnumToStr(spr), ord(spr)); |
3211 |
3503 |
3212 for mg:= Low(TMapGen) to High(TMapGen) do |
3504 for mg:= Low(TMapGen) to High(TMapGen) do |
3213 ScriptSetInteger(EnumToStr(mg), ord(mg)); |
3505 ScriptSetInteger(EnumToStr(mg), ord(mg)); |
3214 |
3506 |
|
3507 for we:= Low(TWorldEdge) to High(TWorldEdge) do |
|
3508 ScriptSetInteger(EnumToStr(we), ord(we)); |
|
3509 |
3215 ScriptSetInteger('gstDrowning' , gstDrowning); |
3510 ScriptSetInteger('gstDrowning' , gstDrowning); |
3216 ScriptSetInteger('gstHHDriven' , gstHHDriven); |
3511 ScriptSetInteger('gstHHDriven' , gstHHDriven); |
3217 ScriptSetInteger('gstMoving' , gstMoving); |
3512 ScriptSetInteger('gstMoving' , gstMoving); |
3218 ScriptSetInteger('gstAttacked' , gstAttacked); |
3513 ScriptSetInteger('gstAttacked' , gstAttacked); |
3219 ScriptSetInteger('gstAttacking' , gstAttacking); |
3514 ScriptSetInteger('gstAttacking' , gstAttacking); |
3263 lua_register(luaState, _P'ClearGameFlags', @lc_cleargameflags); |
3558 lua_register(luaState, _P'ClearGameFlags', @lc_cleargameflags); |
3264 lua_register(luaState, _P'GetGameFlag', @lc_getgameflag); |
3559 lua_register(luaState, _P'GetGameFlag', @lc_getgameflag); |
3265 lua_register(luaState, _P'DeleteGear', @lc_deletegear); |
3560 lua_register(luaState, _P'DeleteGear', @lc_deletegear); |
3266 lua_register(luaState, _P'AddVisualGear', @lc_addvisualgear); |
3561 lua_register(luaState, _P'AddVisualGear', @lc_addvisualgear); |
3267 lua_register(luaState, _P'DeleteVisualGear', @lc_deletevisualgear); |
3562 lua_register(luaState, _P'DeleteVisualGear', @lc_deletevisualgear); |
|
3563 lua_register(luaState, _P'GetVisualGearType', @lc_getvisualgeartype); |
3268 lua_register(luaState, _P'GetVisualGearValues', @lc_getvisualgearvalues); |
3564 lua_register(luaState, _P'GetVisualGearValues', @lc_getvisualgearvalues); |
3269 lua_register(luaState, _P'SetVisualGearValues', @lc_setvisualgearvalues); |
3565 lua_register(luaState, _P'SetVisualGearValues', @lc_setvisualgearvalues); |
3270 lua_register(luaState, _P'GetGearValues', @lc_getgearvalues); |
3566 lua_register(luaState, _P'GetGearValues', @lc_getgearvalues); |
3271 lua_register(luaState, _P'SetGearValues', @lc_setgearvalues); |
3567 lua_register(luaState, _P'SetGearValues', @lc_setgearvalues); |
3272 lua_register(luaState, _P'SpawnHealthCrate', @lc_spawnhealthcrate); |
3568 lua_register(luaState, _P'SpawnHealthCrate', @lc_spawnhealthcrate); |
3276 lua_register(luaState, _P'SpawnFakeAmmoCrate', @lc_spawnfakeammocrate); |
3572 lua_register(luaState, _P'SpawnFakeAmmoCrate', @lc_spawnfakeammocrate); |
3277 lua_register(luaState, _P'SpawnFakeUtilityCrate', @lc_spawnfakeutilitycrate); |
3573 lua_register(luaState, _P'SpawnFakeUtilityCrate', @lc_spawnfakeutilitycrate); |
3278 lua_register(luaState, _P'WriteLnToConsole', @lc_writelntoconsole); |
3574 lua_register(luaState, _P'WriteLnToConsole', @lc_writelntoconsole); |
3279 lua_register(luaState, _P'GetGearType', @lc_getgeartype); |
3575 lua_register(luaState, _P'GetGearType', @lc_getgeartype); |
3280 lua_register(luaState, _P'EndGame', @lc_endgame); |
3576 lua_register(luaState, _P'EndGame', @lc_endgame); |
|
3577 lua_register(luaState, _P'EndTurn', @lc_endturn); |
|
3578 lua_register(luaState, _P'GetTeamStats', @lc_getteamstats); |
3281 lua_register(luaState, _P'SendStat', @lc_sendstat); |
3579 lua_register(luaState, _P'SendStat', @lc_sendstat); |
|
3580 lua_register(luaState, _P'SendGameResultOff', @lc_sendgameresultoff); |
|
3581 lua_register(luaState, _P'SendRankingStatsOff', @lc_sendrankingstatsoff); |
|
3582 lua_register(luaState, _P'SendAchievementsStatsOff', @lc_sendachievementsstatsoff); |
3282 lua_register(luaState, _P'SendHealthStatsOff', @lc_sendhealthstatsoff); |
3583 lua_register(luaState, _P'SendHealthStatsOff', @lc_sendhealthstatsoff); |
3283 lua_register(luaState, _P'FindPlace', @lc_findplace); |
3584 lua_register(luaState, _P'FindPlace', @lc_findplace); |
3284 lua_register(luaState, _P'SetGearPosition', @lc_setgearposition); |
3585 lua_register(luaState, _P'SetGearPosition', @lc_setgearposition); |
3285 lua_register(luaState, _P'GetGearPosition', @lc_getgearposition); |
3586 lua_register(luaState, _P'GetGearPosition', @lc_getgearposition); |
3286 lua_register(luaState, _P'SetGearTarget', @lc_setgeartarget); |
3587 lua_register(luaState, _P'SetGearTarget', @lc_setgeartarget); |
3288 lua_register(luaState, _P'SetGearVelocity', @lc_setgearvelocity); |
3589 lua_register(luaState, _P'SetGearVelocity', @lc_setgearvelocity); |
3289 lua_register(luaState, _P'GetGearVelocity', @lc_getgearvelocity); |
3590 lua_register(luaState, _P'GetGearVelocity', @lc_getgearvelocity); |
3290 lua_register(luaState, _P'ParseCommand', @lc_parsecommand); |
3591 lua_register(luaState, _P'ParseCommand', @lc_parsecommand); |
3291 lua_register(luaState, _P'ShowMission', @lc_showmission); |
3592 lua_register(luaState, _P'ShowMission', @lc_showmission); |
3292 lua_register(luaState, _P'HideMission', @lc_hidemission); |
3593 lua_register(luaState, _P'HideMission', @lc_hidemission); |
|
3594 lua_register(luaState, _P'SetAmmoTexts', @lc_setammotexts); |
|
3595 lua_register(luaState, _P'SetAmmoDescriptionAppendix', @lc_setammodescriptionappendix); |
3293 lua_register(luaState, _P'AddCaption', @lc_addcaption); |
3596 lua_register(luaState, _P'AddCaption', @lc_addcaption); |
3294 lua_register(luaState, _P'SetAmmo', @lc_setammo); |
3597 lua_register(luaState, _P'SetAmmo', @lc_setammo); |
3295 lua_register(luaState, _P'SetAmmoDelay', @lc_setammodelay); |
3598 lua_register(luaState, _P'SetAmmoDelay', @lc_setammodelay); |
3296 lua_register(luaState, _P'SetAmmoStore', @lc_setammostore); |
|
3297 lua_register(luaState, _P'PlaySound', @lc_playsound); |
3599 lua_register(luaState, _P'PlaySound', @lc_playsound); |
3298 lua_register(luaState, _P'AddTeam', @lc_addteam); |
3600 lua_register(luaState, _P'AddTeam', @lc_addteam); |
3299 lua_register(luaState, _P'AddHog', @lc_addhog); |
3601 lua_register(luaState, _P'AddHog', @lc_addhog); |
3300 lua_register(luaState, _P'AddAmmo', @lc_addammo); |
3602 lua_register(luaState, _P'AddAmmo', @lc_addammo); |
3301 lua_register(luaState, _P'GetAmmoCount', @lc_getammocount); |
3603 lua_register(luaState, _P'GetAmmoCount', @lc_getammocount); |
3306 lua_register(luaState, _P'GetHogClan', @lc_gethogclan); |
3608 lua_register(luaState, _P'GetHogClan', @lc_gethogclan); |
3307 lua_register(luaState, _P'GetClanColor', @lc_getclancolor); |
3609 lua_register(luaState, _P'GetClanColor', @lc_getclancolor); |
3308 lua_register(luaState, _P'SetClanColor', @lc_setclancolor); |
3610 lua_register(luaState, _P'SetClanColor', @lc_setclancolor); |
3309 lua_register(luaState, _P'GetHogVoicepack', @lc_gethogvoicepack); |
3611 lua_register(luaState, _P'GetHogVoicepack', @lc_gethogvoicepack); |
3310 lua_register(luaState, _P'GetHogFlag', @lc_gethogflag); |
3612 lua_register(luaState, _P'GetHogFlag', @lc_gethogflag); |
|
3613 lua_register(luaState, _P'GetHogFort', @lc_gethogfort); |
3311 lua_register(luaState, _P'GetHogGrave', @lc_gethoggrave); |
3614 lua_register(luaState, _P'GetHogGrave', @lc_gethoggrave); |
|
3615 lua_register(luaState, _P'IsHogLocal', @lc_ishoglocal); |
3312 lua_register(luaState, _P'GetHogTeamName', @lc_gethogteamname); |
3616 lua_register(luaState, _P'GetHogTeamName', @lc_gethogteamname); |
3313 lua_register(luaState, _P'SetHogTeamName', @lc_sethogteamname); |
3617 lua_register(luaState, _P'SetHogTeamName', @lc_sethogteamname); |
3314 lua_register(luaState, _P'GetHogName', @lc_gethogname); |
3618 lua_register(luaState, _P'GetHogName', @lc_gethogname); |
3315 lua_register(luaState, _P'SetHogName', @lc_sethogname); |
3619 lua_register(luaState, _P'SetHogName', @lc_sethogname); |
3316 lua_register(luaState, _P'GetHogLevel', @lc_gethoglevel); |
3620 lua_register(luaState, _P'GetHogLevel', @lc_gethoglevel); |
3352 lua_register(luaState, _P'GetHogHat', @lc_gethoghat); |
3656 lua_register(luaState, _P'GetHogHat', @lc_gethoghat); |
3353 lua_register(luaState, _P'SetHogHat', @lc_sethoghat); |
3657 lua_register(luaState, _P'SetHogHat', @lc_sethoghat); |
3354 lua_register(luaState, _P'EraseSprite', @lc_erasesprite); |
3658 lua_register(luaState, _P'EraseSprite', @lc_erasesprite); |
3355 lua_register(luaState, _P'PlaceSprite', @lc_placesprite); |
3659 lua_register(luaState, _P'PlaceSprite', @lc_placesprite); |
3356 lua_register(luaState, _P'PlaceGirder', @lc_placegirder); |
3660 lua_register(luaState, _P'PlaceGirder', @lc_placegirder); |
|
3661 lua_register(luaState, _P'PlaceRubber', @lc_placerubber); |
3357 lua_register(luaState, _P'GetCurAmmoType', @lc_getcurammotype); |
3662 lua_register(luaState, _P'GetCurAmmoType', @lc_getcurammotype); |
3358 lua_register(luaState, _P'TestRectForObstacle', @lc_testrectforobstacle); |
3663 lua_register(luaState, _P'TestRectForObstacle', @lc_testrectforobstacle); |
3359 lua_register(luaState, _P'GetGravity', @lc_getgravity); |
3664 lua_register(luaState, _P'GetGravity', @lc_getgravity); |
3360 lua_register(luaState, _P'SetGravity', @lc_setgravity); |
3665 lua_register(luaState, _P'SetGravity', @lc_setgravity); |
3361 lua_register(luaState, _P'SetWaterLine', @lc_setwaterline); |
3666 lua_register(luaState, _P'SetWaterLine', @lc_setwaterline); |
3362 lua_register(luaState, _P'SetNextWeapon', @lc_setnextweapon); |
3667 lua_register(luaState, _P'SetNextWeapon', @lc_setnextweapon); |
3363 lua_register(luaState, _P'SetWeapon', @lc_setweapon); |
3668 lua_register(luaState, _P'SetWeapon', @lc_setweapon); |
3364 lua_register(luaState, _P'SetCinematicMode', @lc_setcinematicmode); |
3669 lua_register(luaState, _P'SetCinematicMode', @lc_setcinematicmode); |
3365 lua_register(luaState, _P'SetMaxBuildDistance', @lc_setmaxbuilddistance); |
3670 lua_register(luaState, _P'SetMaxBuildDistance', @lc_setmaxbuilddistance); |
|
3671 lua_register(luaState, _P'GetAmmoName', @lc_getammoname); |
3366 // drawn map functions |
3672 // drawn map functions |
3367 lua_register(luaState, _P'AddPoint', @lc_addPoint); |
3673 lua_register(luaState, _P'AddPoint', @lc_addPoint); |
3368 lua_register(luaState, _P'FlushPoints', @lc_flushPoints); |
3674 lua_register(luaState, _P'FlushPoints', @lc_flushPoints); |
3369 |
3675 |
3370 lua_register(luaState, _P'SetGearAIHints', @lc_setgearaihints); |
3676 lua_register(luaState, _P'SetGearAIHints', @lc_setgearaihints); |