1641 ScriptGetString:= lua_tostring(luaState, -1); |
1641 ScriptGetString:= lua_tostring(luaState, -1); |
1642 lua_pop(luaState, 1); |
1642 lua_pop(luaState, 1); |
1643 end; |
1643 end; |
1644 |
1644 |
1645 procedure ScriptOnGameInit; |
1645 procedure ScriptOnGameInit; |
|
1646 var i, j, k: LongInt; |
1646 begin |
1647 begin |
1647 // not required if there is no script to run |
1648 // not required if there is no script to run |
1648 if not ScriptLoaded then |
1649 if not ScriptLoaded then |
1649 exit; |
1650 exit; |
1650 |
1651 |
1702 ParseCommand('map ' + ScriptGetString('Map'), true); |
1703 ParseCommand('map ' + ScriptGetString('Map'), true); |
1703 if ScriptGetString('Theme') <> '' then |
1704 if ScriptGetString('Theme') <> '' then |
1704 ParseCommand('theme ' + ScriptGetString('Theme'), true); |
1705 ParseCommand('theme ' + ScriptGetString('Theme'), true); |
1705 LuaGoals:= ScriptGetString('Goals'); |
1706 LuaGoals:= ScriptGetString('Goals'); |
1706 |
1707 |
|
1708 // Support lua changing the ammo layout - assume all hogs have same ammo, note this might leave a few ammo stores lying around. |
|
1709 k:= 0; |
|
1710 if (GameFlags and gfSharedAmmo) <> 0 then |
|
1711 for i:= 0 to Pred(ClansCount) do |
|
1712 for j:= 0 to Pred(ClansArray[i]^.TeamsNumber) do |
|
1713 for k:= 0 to Pred(ClansArray[i]^.Teams[j]^.HedgehogsNumber) do |
|
1714 ClansArray[i]^.Teams[j]^.Hedgehogs[k].AmmoStore:= i |
|
1715 else if (GameFlags and gfPerHogAmmo) <> 0 then |
|
1716 for i:= 0 to Pred(TeamsCount) do |
|
1717 for j:= 0 to Pred(TeamsArray[i]^.HedgehogsNumber) do |
|
1718 begin |
|
1719 TeamsArray[i]^.Hedgehogs[j].AmmoStore:= k; |
|
1720 if StoreCnt-1 < k then AddAmmoStore; |
|
1721 inc(k) |
|
1722 end |
|
1723 else |
|
1724 for i:= 0 to Pred(TeamsCount) do |
|
1725 begin |
|
1726 for j:= 0 to Pred(TeamsArray[i]^.HedgehogsNumber) do |
|
1727 TeamsArray[i]^.Hedgehogs[j].AmmoStore:= k; |
|
1728 if StoreCnt-1 < k then AddAmmoStore; |
|
1729 inc(k) |
|
1730 end; |
1707 if ScriptExists('onAmmoStoreInit') then |
1731 if ScriptExists('onAmmoStoreInit') then |
1708 begin |
1732 begin |
1709 ScriptPrepareAmmoStore; |
1733 ScriptPrepareAmmoStore; |
1710 ScriptCall('onAmmoStoreInit'); |
1734 ScriptCall('onAmmoStoreInit'); |
1711 ScriptApplyAmmoStore |
1735 ScriptApplyAmmoStore |