Advertisement
Guest User

Untitled

a guest
Feb 12th, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 KB | None | 0 0
  1. -- Motown
  2. -- Author: kadacorp
  3. -- DateCreated: 2/12/2016 5:12:36 PM
  4. --------------------------------------------------------------
  5. local bDummy = GameInfoTypes.BUILDING_DUMMY_UNEMPLOYED;
  6. local bDummy1 = GameInfoTypes.BUILDING_DUMMY_TOURISM_1;
  7. local bDummy2 = GameInfoTypes.BUILDING_DUMMY_TOURISM_2;
  8. local bDummy4 = GameInfoTypes.BUILDING_DUMMY_TOURISM_4;
  9. local bDummy8 = GameInfoTypes.BUILDING_DUMMY_TOURISM_8;
  10. local bDummy16 = GameInfoTypes.BUILDING_DUMMY_TOURISM_16;
  11. local bDummy32 = GameInfoTypes.BUILDING_DUMMY_TOURISM_32;
  12. local bDummy64 = GameInfoTypes.BUILDING_DUMMY_TOURISM_64;
  13. local bDummy128 = GameInfoTypes.BUILDING_DUMMY_TOURISM_128;
  14.  
  15.  
  16.  
  17. function toBits(num)
  18. -- returns a table of bits, least significant first.
  19. t={} -- will contain the bits
  20. while num>0 do
  21. local rest=math.fmod(num,2)
  22. t[#t+1]=rest
  23. num=(num-rest)/2
  24. end
  25. return t
  26. end
  27.  
  28.  
  29.  
  30. --Define DummyFromUnemployed function
  31. function DummyFromUnemployed(iPlayer, pPlayer)
  32. local pPlayer = Players[iPlayer];
  33. if (pPlayer:IsAlive()) then
  34. for pCity in pPlayer:Cities() do
  35. if pCity:IsHasBuilding(GameInfoTypes.BUILDING_KADA_MOTOWN) then
  36. for p2City in pPlayer:Cities() do
  37. tCity = {}
  38. tCity[p2City:GetJONSCulturePerTurn()] = p2City
  39. end
  40. for iLowestCulture,p3City in pairs(tCity) do
  41. local p4City = p3City
  42. break
  43. end
  44. --local cCitizen = pCity:GetSpecialistCount(sCitizen);
  45. local num = p4City:GetJONSCulturePerTurn()/25;
  46. toBits(num)
  47. pCity:SetNumRealBuilding(bDummy, num);
  48. pCity:SetNumRealBuilding(bDummy1, t[1]);
  49. pCity:SetNumRealBuilding(bDummy2, t[2]);
  50. pCity:SetNumRealBuilding(bDummy4, t[3]);
  51. pCity:SetNumRealBuilding(bDummy8, t[4]);
  52. pCity:SetNumRealBuilding(bDummy16, t[5]);
  53. pCity:SetNumRealBuilding(bDummy32, t[6]);
  54. pCity:SetNumRealBuilding(bDummy64, t[7]);
  55. pCity:SetNumRealBuilding(bDummy128, t[8]);
  56. end
  57. end
  58. end
  59. end
  60.  
  61.  
  62. function DummyFromUnemployedTurnStart(iPlayer, pPlayer)
  63. --print ("Turn Trigger")
  64. local pPlayer = Players[iPlayer]
  65. local bIsTurnStart = true
  66. DummyFromUnemployed(iPlayer, pPlayer)
  67. end
  68.  
  69. function DummyFromUnemployedDirty()
  70. local iPlayer = Game.GetActivePlayer()
  71. local pPlayer = Players[iPlayer]
  72. if pPlayer:IsTurnActive() then
  73. --print ("Swap Trigger")
  74. local bIsTurnStart = false
  75. DummyFromUnemployed(iPlayer, pPlayer)
  76. end
  77. end
  78.  
  79. GameEvents.PlayerDoTurn.Add(DummyFromUnemployedTurnStart)
  80. Events.SerialEventCityInfoDirty.Add(DummyFromUnemployedDirty)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement