1289 function lc_sendstat(L : Plua_State) : LongInt; Cdecl; |
1289 function lc_sendstat(L : Plua_State) : LongInt; Cdecl; |
1290 var statInfo : TStatInfoType; |
1290 var statInfo : TStatInfoType; |
1291 var i : LongInt; |
1291 var i : LongInt; |
1292 var color : shortstring; |
1292 var color : shortstring; |
1293 begin |
1293 begin |
1294 //TODO print better error messages |
|
1295 statInfo := TStatInfoType(GetEnumValue(TypeInfo(TStatInfoType),lua_tostring(L, 1))); |
1294 statInfo := TStatInfoType(GetEnumValue(TypeInfo(TStatInfoType),lua_tostring(L, 1))); |
1296 if (lua_gettop(L) <> 2) and ((statInfo <> siPlayerKills) |
1295 if (lua_gettop(L) <> 2) and ((statInfo <> siPlayerKills) |
1297 and (statInfo <> siClanHealth)) then |
1296 and (statInfo <> siClanHealth)) then |
1298 begin |
1297 begin |
1299 LuaError('Lua: Wrong number of parameters passed to SendStat!'); |
1298 LuaError('Lua: Wrong number of parameters passed to SendStat! Expected 2 parameters.'); |
1300 end |
1299 end |
1301 else if (lua_gettop(L) <> 3) and ((statInfo = siPlayerKills) |
1300 else if (lua_gettop(L) <> 3) and ((statInfo = siPlayerKills) |
1302 or (statInfo = siClanHealth)) then |
1301 or (statInfo = siClanHealth)) then |
1303 begin |
1302 begin |
1304 LuaError('Lua: Wrong number of parameters passed to SendStat!'); |
1303 LuaError('Lua: Wrong number of parameters passed to SendStat! Expected 3 parameters.'); |
1305 end |
1304 end |
1306 else |
1305 else |
1307 begin |
1306 begin |
1308 if ((statInfo = siPlayerKills) or (statInfo = siClanHealth)) then |
1307 if ((statInfo = siPlayerKills) or (statInfo = siClanHealth)) then |
1309 begin |
1308 begin |
1343 L:= L; // avoid compiler hint |
1342 L:= L; // avoid compiler hint |
1344 uStats.SendStatsOn := false; |
1343 uStats.SendStatsOn := false; |
1345 lc_sendstatsoff:= 0 |
1344 lc_sendstatsoff:= 0 |
1346 end; |
1345 end; |
1347 |
1346 |
1348 function lc_sendstats(L : Plua_State) : LongInt; Cdecl; |
|
1349 begin |
|
1350 L:= L; // avoid compiler hint |
|
1351 SendStats; |
|
1352 lc_sendstats:= 0 |
|
1353 end; |
|
1354 |
|
1355 function lc_findplace(L : Plua_State) : LongInt; Cdecl; |
1347 function lc_findplace(L : Plua_State) : LongInt; Cdecl; |
1356 var gear: PGear; |
1348 var gear: PGear; |
1357 fall: boolean; |
1349 fall: boolean; |
1358 tryhard: boolean; |
1350 tryhard: boolean; |
1359 left, right: LongInt; |
1351 left, right: LongInt; |
2449 lua_register(luaState, _P'WriteLnToConsole', @lc_writelntoconsole); |
2441 lua_register(luaState, _P'WriteLnToConsole', @lc_writelntoconsole); |
2450 lua_register(luaState, _P'GetGearType', @lc_getgeartype); |
2442 lua_register(luaState, _P'GetGearType', @lc_getgeartype); |
2451 lua_register(luaState, _P'EndGame', @lc_endgame); |
2443 lua_register(luaState, _P'EndGame', @lc_endgame); |
2452 lua_register(luaState, _P'SendStat', @lc_sendstat); |
2444 lua_register(luaState, _P'SendStat', @lc_sendstat); |
2453 lua_register(luaState, _P'SendStatsOff', @lc_sendstatsoff); |
2445 lua_register(luaState, _P'SendStatsOff', @lc_sendstatsoff); |
2454 lua_register(luaState, _P'SendStats', @lc_sendstats); |
|
2455 lua_register(luaState, _P'FindPlace', @lc_findplace); |
2446 lua_register(luaState, _P'FindPlace', @lc_findplace); |
2456 lua_register(luaState, _P'SetGearPosition', @lc_setgearposition); |
2447 lua_register(luaState, _P'SetGearPosition', @lc_setgearposition); |
2457 lua_register(luaState, _P'GetGearPosition', @lc_getgearposition); |
2448 lua_register(luaState, _P'GetGearPosition', @lc_getgearposition); |
2458 lua_register(luaState, _P'SetGearTarget', @lc_setgeartarget); |
2449 lua_register(luaState, _P'SetGearTarget', @lc_setgeartarget); |
2459 lua_register(luaState, _P'GetGearTarget', @lc_getgeartarget); |
2450 lua_register(luaState, _P'GetGearTarget', @lc_getgeartarget); |