equal
deleted
inserted
replaced
1026 CWindSpeedf := -cWindSpeedf; |
1026 CWindSpeedf := -cWindSpeedf; |
1027 AddGear(0, 0, gtATSmoothWindCh, 0, _0, _0, 1)^.Tag:= hwRound(cWindSpeed * 72 / cMaxWindSpeed); |
1027 AddGear(0, 0, gtATSmoothWindCh, 0, _0, _0, 1)^.Tag:= hwRound(cWindSpeed * 72 / cMaxWindSpeed); |
1028 end; |
1028 end; |
1029 lc_setwind:= 0 |
1029 lc_setwind:= 0 |
1030 end; |
1030 end; |
|
1031 |
|
1032 function lc_getdatapath(L : Plua_State) : LongInt; Cdecl; |
|
1033 begin |
|
1034 if lua_gettop(L) <> 0 then |
|
1035 begin |
|
1036 LuaError('Lua: Wrong number of parameters passed to GetDataPath!'); |
|
1037 lua_pushnil(L); |
|
1038 end |
|
1039 else |
|
1040 lua_pushstring(L, str2pchar(Pathz[ptData])); |
|
1041 lc_getdatapath:= 1 |
|
1042 end; |
1031 /////////////////// |
1043 /////////////////// |
1032 |
1044 |
1033 procedure ScriptPrintStack; |
1045 procedure ScriptPrintStack; |
1034 var n, i : LongInt; |
1046 var n, i : LongInt; |
1035 begin |
1047 begin |
1080 ScriptGetString:= lua_tostring(luaState, -1); |
1092 ScriptGetString:= lua_tostring(luaState, -1); |
1081 lua_pop(luaState, 1); |
1093 lua_pop(luaState, 1); |
1082 end; |
1094 end; |
1083 |
1095 |
1084 procedure ScriptOnGameInit; |
1096 procedure ScriptOnGameInit; |
1085 var s, t : ansistring; |
|
1086 begin |
1097 begin |
1087 // not required if there is no script to run |
1098 // not required if there is no script to run |
1088 if not ScriptLoaded then |
1099 if not ScriptLoaded then |
1089 exit; |
1100 exit; |
1090 |
1101 |
1105 ScriptSetInteger('SuddenDeathTurns', cSuddenDTurns); |
1116 ScriptSetInteger('SuddenDeathTurns', cSuddenDTurns); |
1106 ScriptSetInteger('WaterRise', cWaterRise); |
1117 ScriptSetInteger('WaterRise', cWaterRise); |
1107 ScriptSetInteger('HealthDecrease', cHealthDecrease); |
1118 ScriptSetInteger('HealthDecrease', cHealthDecrease); |
1108 ScriptSetString('Map', ''); |
1119 ScriptSetString('Map', ''); |
1109 ScriptSetString('Theme', ''); |
1120 ScriptSetString('Theme', ''); |
1110 |
|
1111 // import locale |
|
1112 s:= cLocaleFName; |
|
1113 t:= ''; |
|
1114 SplitByChar(s, t, '.'); |
|
1115 ScriptSetString('L', s); |
|
1116 |
1121 |
1117 ScriptCall('onGameInit'); |
1122 ScriptCall('onGameInit'); |
1118 |
1123 |
1119 // pop game variables |
1124 // pop game variables |
1120 ParseCommand('seed ' + ScriptGetString('Seed'), true); |
1125 ParseCommand('seed ' + ScriptGetString('Seed'), true); |
1293 var at : TGearType; |
1298 var at : TGearType; |
1294 vgt: TVisualGearType; |
1299 vgt: TVisualGearType; |
1295 am : TAmmoType; |
1300 am : TAmmoType; |
1296 st : TSound; |
1301 st : TSound; |
1297 he: THogEffect; |
1302 he: THogEffect; |
|
1303 s, t : ansistring; |
1298 begin |
1304 begin |
1299 // initialize lua |
1305 // initialize lua |
1300 luaState:= lua_open; |
1306 luaState:= lua_open; |
1301 TryDo(luaState <> nil, 'lua_open failed', true); |
1307 TryDo(luaState <> nil, 'lua_open failed', true); |
1302 |
1308 |
1307 luaopen_table(luaState); |
1313 luaopen_table(luaState); |
1308 |
1314 |
1309 // import some variables |
1315 // import some variables |
1310 ScriptSetInteger('LAND_WIDTH', LAND_WIDTH); |
1316 ScriptSetInteger('LAND_WIDTH', LAND_WIDTH); |
1311 ScriptSetInteger('LAND_HEIGHT', LAND_HEIGHT); |
1317 ScriptSetInteger('LAND_HEIGHT', LAND_HEIGHT); |
|
1318 |
|
1319 // import locale |
|
1320 s:= cLocaleFName; |
|
1321 t:= ''; |
|
1322 SplitByChar(s, t, '.'); |
|
1323 ScriptSetString('L', s); |
1312 |
1324 |
1313 // import game flags |
1325 // import game flags |
1314 ScriptSetInteger('gfForts', gfForts); |
1326 ScriptSetInteger('gfForts', gfForts); |
1315 ScriptSetInteger('gfMultiWeapon', gfMultiWeapon); |
1327 ScriptSetInteger('gfMultiWeapon', gfMultiWeapon); |
1316 ScriptSetInteger('gfSolidLand', gfSolidLand); |
1328 ScriptSetInteger('gfSolidLand', gfSolidLand); |
1432 lua_register(luaState, 'CampaignUnlock', @lc_campaignunlock); |
1444 lua_register(luaState, 'CampaignUnlock', @lc_campaignunlock); |
1433 lua_register(luaState, 'GetGearMessage', @lc_getgearmessage); |
1445 lua_register(luaState, 'GetGearMessage', @lc_getgearmessage); |
1434 lua_register(luaState, 'SetGearMessage', @lc_setgearmessage); |
1446 lua_register(luaState, 'SetGearMessage', @lc_setgearmessage); |
1435 lua_register(luaState, 'GetRandom', @lc_getrandom); |
1447 lua_register(luaState, 'GetRandom', @lc_getrandom); |
1436 lua_register(luaState, 'SetWind', @lc_setwind); |
1448 lua_register(luaState, 'SetWind', @lc_setwind); |
|
1449 lua_register(luaState, 'GetDataPath', @lc_getdatapath); |
1437 |
1450 |
1438 |
1451 |
1439 ScriptClearStack; // just to be sure stack is empty |
1452 ScriptClearStack; // just to be sure stack is empty |
1440 ScriptLoaded:= false; |
1453 ScriptLoaded:= false; |
1441 end; |
1454 end; |