equal
deleted
inserted
replaced
42 {$IFNDEF IPHONEOS} |
42 {$IFNDEF IPHONEOS} |
43 uses LuaPas in 'LuaPas.pas', |
43 uses LuaPas in 'LuaPas.pas', |
44 uConsole, |
44 uConsole, |
45 uMisc, |
45 uMisc, |
46 uConsts, |
46 uConsts, |
|
47 uVisualGears, |
47 uGears, |
48 uGears, |
48 uFloat, |
49 uFloat, |
49 uWorld, |
50 uWorld, |
50 uAmmos, |
51 uAmmos, |
51 uSound, |
52 uSound, |
411 if gear <> nil then FollowGear:= gear |
412 if gear <> nil then FollowGear:= gear |
412 end; |
413 end; |
413 lc_followgear:= 0 |
414 lc_followgear:= 0 |
414 end; |
415 end; |
415 |
416 |
|
417 function lc_hogsay(L : Plua_State) : LongInt; Cdecl; |
|
418 var gear : PGear; |
|
419 vgear : PVisualGear; |
|
420 text : ShortString; |
|
421 begin |
|
422 if lua_gettop(L) <> 3 then |
|
423 begin |
|
424 LuaError('Lua: Wrong number of parameters passed to HogSay!'); |
|
425 end |
|
426 else |
|
427 begin |
|
428 gear:= GearByUID(lua_tointeger(L, 1)); |
|
429 if gear <> nil then |
|
430 begin |
|
431 vgear:= AddVisualGear(0, 0, vgtSpeechBubble); |
|
432 if vgear <> nil then |
|
433 begin |
|
434 vgear^.Text:= lua_tostring(L, 2); |
|
435 vgear^.Hedgehog:= gear^.Hedgehog; |
|
436 vgear^.FrameTicks:= lua_tointeger(L, 3); |
|
437 if (vgear^.FrameTicks < 1) or (vgear^.FrameTicks > 3) then vgear^.FrameTicks:= 1; |
|
438 end; |
|
439 end |
|
440 end; |
|
441 lc_hogsay:= 0 |
|
442 end; |
|
443 |
416 function lc_sethealth(L : Plua_State) : LongInt; Cdecl; |
444 function lc_sethealth(L : Plua_State) : LongInt; Cdecl; |
417 var gear : PGear; |
445 var gear : PGear; |
418 begin |
446 begin |
419 if lua_gettop(L) <> 2 then |
447 if lua_gettop(L) <> 2 then |
420 begin |
448 begin |
585 ParseCommand('addhh ' + lua_tostring(L, 2) + ' ' + lua_tostring(L, 3) + ' ' + lua_tostring(L, 1), true); |
613 ParseCommand('addhh ' + lua_tostring(L, 2) + ' ' + lua_tostring(L, 3) + ' ' + lua_tostring(L, 1), true); |
586 ParseCommand('hat ' + temp, true); |
614 ParseCommand('hat ' + temp, true); |
587 lua_pushinteger(L, CurrentHedgehog^.Gear^.uid); |
615 lua_pushinteger(L, CurrentHedgehog^.Gear^.uid); |
588 end; |
616 end; |
589 lc_addhog:= 1; |
617 lc_addhog:= 1; |
|
618 end; |
|
619 |
|
620 function lc_hogturnleft(L : Plua_State) : LongInt; Cdecl; |
|
621 var gear: PGear; |
|
622 begin |
|
623 if lua_gettop(L) <> 2 then |
|
624 begin |
|
625 LuaError('Lua: Wrong number of parameters passed to HogTurnLeft!'); |
|
626 end |
|
627 else |
|
628 begin |
|
629 gear:= GearByUID(lua_tointeger(L, 1)); |
|
630 if gear <> nil then |
|
631 gear^.dX.isNegative:= lua_toboolean(L, 2); |
|
632 end; |
|
633 lc_hogturnleft:= 0; |
590 end; |
634 end; |
591 |
635 |
592 function lc_getgearposition(L : Plua_State) : LongInt; Cdecl; |
636 function lc_getgearposition(L : Plua_State) : LongInt; Cdecl; |
593 var gear: PGear; |
637 var gear: PGear; |
594 begin |
638 begin |
788 end; |
832 end; |
789 |
833 |
790 procedure SetGlobals; |
834 procedure SetGlobals; |
791 begin |
835 begin |
792 ScriptSetInteger('TurnTimeLeft', TurnTimeLeft); |
836 ScriptSetInteger('TurnTimeLeft', TurnTimeLeft); |
|
837 ScriptSetInteger('GameTime', GameTicks); |
|
838 ScriptSetInteger('RealTime', RealTicks); |
793 if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil) then |
839 if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil) then |
794 ScriptSetInteger('CurrentHedgehog', CurrentHedgehog^.Gear^.UID) |
840 ScriptSetInteger('CurrentHedgehog', CurrentHedgehog^.Gear^.UID) |
795 else |
841 else |
796 ScriptSetNil('CurrentHedgehog'); |
842 ScriptSetNil('CurrentHedgehog'); |
797 end; |
843 end; |
944 ScriptSetInteger('gfKing', gfKing); |
990 ScriptSetInteger('gfKing', gfKing); |
945 ScriptSetInteger('gfPlaceHog', gfPlaceHog); |
991 ScriptSetInteger('gfPlaceHog', gfPlaceHog); |
946 ScriptSetInteger('gfSharedAmmo', gfSharedAmmo); |
992 ScriptSetInteger('gfSharedAmmo', gfSharedAmmo); |
947 ScriptSetInteger('gfDisableGirders', gfDisableGirders); |
993 ScriptSetInteger('gfDisableGirders', gfDisableGirders); |
948 ScriptSetInteger('gfExplosives', gfExplosives); |
994 ScriptSetInteger('gfExplosives', gfExplosives); |
|
995 |
|
996 // speech bubbles |
|
997 ScriptSetInteger('SAY_SAY', 1); |
|
998 ScriptSetInteger('SAY_THINK', 2); |
|
999 ScriptSetInteger('SAY_SHOUT', 3); |
949 |
1000 |
950 // register gear types |
1001 // register gear types |
951 for at:= Low(TGearType) to High(TGearType) do |
1002 for at:= Low(TGearType) to High(TGearType) do |
952 ScriptSetInteger(EnumToStr(at), ord(at)); |
1003 ScriptSetInteger(EnumToStr(at), ord(at)); |
953 |
1004 |
997 lua_register(luaState, 'SetTimer', @lc_settimer); |
1048 lua_register(luaState, 'SetTimer', @lc_settimer); |
998 lua_register(luaState, 'GetTimer', @lc_gettimer); |
1049 lua_register(luaState, 'GetTimer', @lc_gettimer); |
999 lua_register(luaState, 'GetHealth', @lc_gethealth); |
1050 lua_register(luaState, 'GetHealth', @lc_gethealth); |
1000 lua_register(luaState, 'SetZoom', @lc_setzoom); |
1051 lua_register(luaState, 'SetZoom', @lc_setzoom); |
1001 lua_register(luaState, 'GetZoom', @lc_getzoom); |
1052 lua_register(luaState, 'GetZoom', @lc_getzoom); |
|
1053 lua_register(luaState, 'HogSay', @lc_hogsay); |
|
1054 lua_register(luaState, 'HogTurnLeft', @lc_hogturnleft); |
1002 |
1055 |
1003 |
1056 |
1004 ScriptClearStack; // just to be sure stack is empty |
1057 ScriptClearStack; // just to be sure stack is empty |
1005 ScriptLoaded:= false; |
1058 ScriptLoaded:= false; |
1006 end; |
1059 end; |