41 function ScriptCall(fname : shortstring; par1: LongInt) : LongInt; |
41 function ScriptCall(fname : shortstring; par1: LongInt) : LongInt; |
42 function ScriptCall(fname : shortstring; par1, par2: LongInt) : LongInt; |
42 function ScriptCall(fname : shortstring; par1, par2: LongInt) : LongInt; |
43 function ScriptCall(fname : shortstring; par1, par2, par3: LongInt) : LongInt; |
43 function ScriptCall(fname : shortstring; par1, par2, par3: LongInt) : LongInt; |
44 function ScriptCall(fname : shortstring; par1, par2, par3, par4 : LongInt) : LongInt; |
44 function ScriptCall(fname : shortstring; par1, par2, par3, par4 : LongInt) : LongInt; |
45 function ScriptExists(fname : shortstring) : boolean; |
45 function ScriptExists(fname : shortstring) : boolean; |
46 function ParseCommandOverride(key, value : shortstring) : shortstring; |
|
47 |
46 |
48 procedure initModule; |
47 procedure initModule; |
49 procedure freeModule; |
48 procedure freeModule; |
50 |
49 |
51 implementation |
50 implementation |
1113 lc_playsound:= 0; |
1112 lc_playsound:= 0; |
1114 end; |
1113 end; |
1115 |
1114 |
1116 function lc_addteam(L : Plua_State) : LongInt; Cdecl; |
1115 function lc_addteam(L : Plua_State) : LongInt; Cdecl; |
1117 var np: LongInt; |
1116 var np: LongInt; |
1118 color, name, grave, fort, voice, flag: shortstring; |
|
1119 begin |
1117 begin |
1120 np:= lua_gettop(L); |
1118 np:= lua_gettop(L); |
1121 if (np < 5) or (np > 6) then |
1119 if (np < 5) or (np > 6) then |
1122 begin |
1120 begin |
1123 LuaError('Lua: Wrong number of parameters passed to AddTeam!'); |
1121 LuaError('Lua: Wrong number of parameters passed to AddTeam!'); |
1124 //lua_pushnil(L) |
1122 //lua_pushnil(L) |
1125 end |
1123 end |
1126 else |
1124 else |
1127 begin |
1125 begin |
1128 (* |
1126 ParseCommand('addteam x ' + lua_tostring(L, 2) + ' ' + lua_tostring(L, 1), true); |
1129 FIXME FIXME FIXME FIXME |
1127 ParseCommand('grave ' + lua_tostring(L, 3), true); |
1130 Something is very wrong here. |
1128 ParseCommand('fort ' + lua_tostring(L, 4), true); |
1131 For some reason, the lua_tostring after the first ParseCommand, are empty. Is ParseCommand scribbling on stuff? |
1129 ParseCommand('voicepack ' + lua_tostring(L, 5), true); |
1132 *) |
1130 if (np = 6) then ParseCommand('flag ' + lua_tostring(L, 6), true); |
1133 color:= lua_tostring(L, 1); |
|
1134 name := lua_tostring(L, 2); |
|
1135 grave:= lua_tostring(L, 3); |
|
1136 fort := lua_tostring(L, 4); |
|
1137 voice:= lua_tostring(L, 5); |
|
1138 if (np = 6) flag:= lua_tostring(L, 6); |
|
1139 ParseCommand('addteam x ' + name + ' ' + color, true); |
|
1140 ParseCommand('grave ' + grave, true); |
|
1141 ParseCommand('fort ' + fort, true); |
|
1142 ParseCommand('voicepack ' + voice, true); |
|
1143 if (np = 6) then ParseCommand('flag ' + flag, true); |
|
1144 CurrentTeam^.Binds:= DefaultBinds |
1131 CurrentTeam^.Binds:= DefaultBinds |
1145 // fails on x64 |
1132 // fails on x64 |
1146 //lua_pushinteger(L, LongInt(CurrentTeam)); |
1133 //lua_pushinteger(L, LongInt(CurrentTeam)); |
1147 end; |
1134 end; |
1148 lc_addteam:= 0;//1; |
1135 lc_addteam:= 0;//1; |
1654 begin |
1641 begin |
1655 LuaError('Lua: Error while calling ' + fname + ': ' + lua_tostring(luaState, -1)); |
1642 LuaError('Lua: Error while calling ' + fname + ': ' + lua_tostring(luaState, -1)); |
1656 lua_pop(luaState, 1) |
1643 lua_pop(luaState, 1) |
1657 end; |
1644 end; |
1658 GetGlobals; |
1645 GetGlobals; |
1659 end; |
|
1660 |
|
1661 function ParseCommandOverride(key, value : shortstring) : shortstring; |
|
1662 begin |
|
1663 ParseCommandOverride:= value; |
|
1664 if not ScriptExists('ParseCommandOverride') then exit; |
|
1665 lua_getglobal(luaState, Str2PChar('ParseCommandOverride')); |
|
1666 lua_pushstring(luaState, Str2PChar(key)); |
|
1667 lua_pushstring(luaState, Str2PChar(value)); |
|
1668 if lua_pcall(luaState, 2, 1, 0) <> 0 then |
|
1669 begin |
|
1670 LuaError('Lua: Error while calling ParseCommandOverride: ' + lua_tostring(luaState, -1)); |
|
1671 lua_pop(luaState, 1) |
|
1672 end |
|
1673 else |
|
1674 begin |
|
1675 ParseCommandOverride:= lua_tostring(luaState, -1); |
|
1676 lua_pop(luaState, 1) |
|
1677 end; |
|
1678 end; |
1646 end; |
1679 |
1647 |
1680 function ScriptCall(fname : shortstring; par1: LongInt) : LongInt; |
1648 function ScriptCall(fname : shortstring; par1: LongInt) : LongInt; |
1681 begin |
1649 begin |
1682 ScriptCall:= ScriptCall(fname, par1, 0, 0, 0) |
1650 ScriptCall:= ScriptCall(fname, par1, 0, 0, 0) |