44 function ScriptCall(fname : shortstring; par1, par2, par3: LongInt) : LongInt; |
44 function ScriptCall(fname : shortstring; par1, par2, par3: LongInt) : LongInt; |
45 function ScriptCall(fname : shortstring; par1, par2, par3, par4 : LongInt) : LongInt; |
45 function ScriptCall(fname : shortstring; par1, par2, par3, par4 : LongInt) : LongInt; |
46 function ScriptExists(fname : shortstring) : boolean; |
46 function ScriptExists(fname : shortstring) : boolean; |
47 |
47 |
48 |
48 |
49 function ParseCommandOverride(key, value : shortstring) : shortstring; |
49 //function ParseCommandOverride(key, value : shortstring) : shortstring; This did not work out well |
50 |
50 |
51 procedure initModule; |
51 procedure initModule; |
52 procedure freeModule; |
52 procedure freeModule; |
53 |
53 |
54 implementation |
54 implementation |
194 t:= lua_tolstring(L,1,@c); |
194 t:= lua_tolstring(L,1,@c); |
195 |
195 |
196 for i:= 1 to c do s[i]:= t[i-1]; |
196 for i:= 1 to c do s[i]:= t[i-1]; |
197 s[0]:= char(c); |
197 s[0]:= char(c); |
198 |
198 |
199 ParseCommand(s, true); |
199 ParseCommand(s, true, true); |
200 |
200 |
201 end |
201 end |
202 else |
202 else |
203 LuaError('Lua: Wrong number of parameters passed to ParseCommand!'); |
203 LuaError('Lua: Wrong number of parameters passed to ParseCommand!'); |
204 lc_parsecommand:= 0; |
204 lc_parsecommand:= 0; |
1304 LuaError('Lua: Wrong number of parameters passed to AddTeam!'); |
1304 LuaError('Lua: Wrong number of parameters passed to AddTeam!'); |
1305 //lua_pushnil(L) |
1305 //lua_pushnil(L) |
1306 end |
1306 end |
1307 else |
1307 else |
1308 begin |
1308 begin |
1309 ParseCommand('addteam x ' + lua_tostring(L, 2) + ' ' + lua_tostring(L, 1), true); |
1309 ParseCommand('addteam x ' + lua_tostring(L, 2) + ' ' + lua_tostring(L, 1), true, true); |
1310 ParseCommand('grave ' + lua_tostring(L, 3), true); |
1310 ParseCommand('grave ' + lua_tostring(L, 3), true, true); |
1311 ParseCommand('fort ' + lua_tostring(L, 4), true); |
1311 ParseCommand('fort ' + lua_tostring(L, 4), true, true); |
1312 ParseCommand('voicepack ' + lua_tostring(L, 5), true); |
1312 ParseCommand('voicepack ' + lua_tostring(L, 5), true, true); |
1313 if (np = 6) then ParseCommand('flag ' + lua_tostring(L, 6), true); |
1313 if (np = 6) then ParseCommand('flag ' + lua_tostring(L, 6), true, true); |
1314 CurrentTeam^.Binds:= DefaultBinds |
1314 CurrentTeam^.Binds:= DefaultBinds |
1315 // fails on x64 |
1315 // fails on x64 |
1316 //lua_pushinteger(L, LongInt(CurrentTeam)); |
1316 //lua_pushinteger(L, LongInt(CurrentTeam)); |
1317 end; |
1317 end; |
1318 lc_addteam:= 0;//1; |
1318 lc_addteam:= 0;//1; |
1327 lua_pushnil(L) |
1327 lua_pushnil(L) |
1328 end |
1328 end |
1329 else |
1329 else |
1330 begin |
1330 begin |
1331 temp:= lua_tostring(L, 4); |
1331 temp:= lua_tostring(L, 4); |
1332 ParseCommand('addhh ' + lua_tostring(L, 2) + ' ' + lua_tostring(L, 3) + ' ' + lua_tostring(L, 1), true); |
1332 ParseCommand('addhh ' + lua_tostring(L, 2) + ' ' + lua_tostring(L, 3) + ' ' + lua_tostring(L, 1), true, true); |
1333 ParseCommand('hat ' + temp, true); |
1333 ParseCommand('hat ' + temp, true, true); |
1334 lua_pushinteger(L, CurrentHedgehog^.Gear^.uid); |
1334 lua_pushinteger(L, CurrentHedgehog^.Gear^.uid); |
1335 end; |
1335 end; |
1336 lc_addhog:= 1; |
1336 lc_addhog:= 1; |
1337 end; |
1337 end; |
1338 |
1338 |
1667 begin |
1667 begin |
1668 gear:= GearByUID(lua_tointeger(L, 1)); |
1668 gear:= GearByUID(lua_tointeger(L, 1)); |
1669 if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
1669 if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
1670 hat:= lua_tostring(L, 2); |
1670 hat:= lua_tostring(L, 2); |
1671 gear^.Hedgehog^.Hat:= hat; |
1671 gear^.Hedgehog^.Hat:= hat; |
1672 LoadHedgehogHat(gear^.Hedgehog^, hat); |
1672 AddFileLog('Changed hat to: '+hat); |
|
1673 if (Length(hat) > 39) and (Copy(hat,1,8) = 'Reserved') and (Copy(hat,9,32) = gear^.Hedgehog^.Team^.PlayerHash) then |
|
1674 LoadHedgehogHat(gear^.Hedgehog^, 'Reserved/' + Copy(hat,9,Length(hat)-8)) |
|
1675 else |
|
1676 LoadHedgehogHat(gear^.Hedgehog^, hat); |
1673 end; |
1677 end; |
1674 lc_sethoghat:= 0; |
1678 lc_sethoghat:= 0; |
1675 end; |
1679 end; |
1676 |
1680 |
1677 function lc_placegirder(L : Plua_State) : LongInt; Cdecl; |
1681 function lc_placegirder(L : Plua_State) : LongInt; Cdecl; |
1869 ScriptSetString('Goals', ''); |
1873 ScriptSetString('Goals', ''); |
1870 |
1874 |
1871 ScriptCall('onGameInit'); |
1875 ScriptCall('onGameInit'); |
1872 |
1876 |
1873 // pop game variables |
1877 // pop game variables |
1874 ParseCommand('seed ' + ScriptGetString('Seed'), true); |
1878 ParseCommand('seed ' + ScriptGetString('Seed'), true, true); |
1875 cTemplateFilter := ScriptGetInteger('TemplateFilter'); |
1879 cTemplateFilter := ScriptGetInteger('TemplateFilter'); |
1876 LuaTemplateNumber:= ScriptGetInteger('TemplateNumber'); |
1880 LuaTemplateNumber:= ScriptGetInteger('TemplateNumber'); |
1877 cMapGen := ScriptGetInteger('MapGen'); |
1881 cMapGen := ScriptGetInteger('MapGen'); |
1878 GameFlags := ScriptGetInteger('GameFlags'); |
1882 GameFlags := ScriptGetInteger('GameFlags'); |
1879 cHedgehogTurnTime:= ScriptGetInteger('TurnTime'); |
1883 cHedgehogTurnTime:= ScriptGetInteger('TurnTime'); |
1890 cReadyDelay := ScriptGetInteger('Ready'); |
1894 cReadyDelay := ScriptGetInteger('Ready'); |
1891 cSuddenDTurns := ScriptGetInteger('SuddenDeathTurns'); |
1895 cSuddenDTurns := ScriptGetInteger('SuddenDeathTurns'); |
1892 cWaterRise := ScriptGetInteger('WaterRise'); |
1896 cWaterRise := ScriptGetInteger('WaterRise'); |
1893 cHealthDecrease := ScriptGetInteger('HealthDecrease'); |
1897 cHealthDecrease := ScriptGetInteger('HealthDecrease'); |
1894 |
1898 |
1895 ParseCommand('map ' + ScriptGetString('Map'), true); |
1899 if cMapName <> ScriptGetString('Map') then |
|
1900 ParseCommand('map ' + ScriptGetString('Map'), true, true); |
1896 if ScriptGetString('Theme') <> '' then |
1901 if ScriptGetString('Theme') <> '' then |
1897 ParseCommand('theme ' + ScriptGetString('Theme'), true); |
1902 ParseCommand('theme ' + ScriptGetString('Theme'), true, true); |
1898 LuaGoals:= ScriptGetString('Goals'); |
1903 LuaGoals:= ScriptGetString('Goals'); |
1899 |
1904 |
1900 // Support lua changing the ammo layout - assume all hogs have same ammo, note this might leave a few ammo stores lying around. |
1905 // Support lua changing the ammo layout - assume all hogs have same ammo, note this might leave a few ammo stores lying around. |
1901 k:= 0; |
1906 k:= 0; |
1902 if (GameFlags and gfSharedAmmo) <> 0 then |
1907 if (GameFlags and gfSharedAmmo) <> 0 then |
2033 begin |
2039 begin |
2034 ParseCommandOverride:= lua_tostring(luaState, -1); |
2040 ParseCommandOverride:= lua_tostring(luaState, -1); |
2035 lua_pop(luaState, 1) |
2041 lua_pop(luaState, 1) |
2036 end; |
2042 end; |
2037 end; |
2043 end; |
|
2044 *) |
2038 |
2045 |
2039 function ScriptCall(fname : shortstring; par1: LongInt) : LongInt; |
2046 function ScriptCall(fname : shortstring; par1: LongInt) : LongInt; |
2040 begin |
2047 begin |
2041 ScriptCall:= ScriptCall(fname, par1, 0, 0, 0) |
2048 ScriptCall:= ScriptCall(fname, par1, 0, 0, 0) |
2042 end; |
2049 end; |
2447 function ScriptExists(fname : shortstring) : boolean; |
2454 function ScriptExists(fname : shortstring) : boolean; |
2448 begin |
2455 begin |
2449 fname:= fname; // avoid hint |
2456 fname:= fname; // avoid hint |
2450 ScriptExists:= false |
2457 ScriptExists:= false |
2451 end; |
2458 end; |
2452 |
2459 (* |
2453 function ParseCommandOverride(key, value : shortstring) : shortstring; |
2460 function ParseCommandOverride(key, value : shortstring) : shortstring; |
2454 begin |
2461 begin |
2455 // avoid hints |
2462 // avoid hints |
2456 key:= key; |
2463 key:= key; |
2457 value:= value; |
2464 value:= value; |
2458 ParseCommandOverride:= '' |
2465 ParseCommandOverride:= '' |
2459 end; |
2466 end; |
|
2467 *) |
2460 |
2468 |
2461 procedure ScriptOnScreenResize; |
2469 procedure ScriptOnScreenResize; |
2462 begin |
2470 begin |
2463 end; |
2471 end; |
2464 |
2472 |