9 local periodtimer = 0 |
9 local periodtimer = 0 |
10 local wdGameTicks = 0 |
10 local wdGameTicks = 0 |
11 local wdTTL = 0 |
11 local wdTTL = 0 |
12 local mln = 1000000 |
12 local mln = 1000000 |
13 |
13 |
14 function onNewTurn() |
14 local script2_onNewTurn |
|
15 local script2_onGameTick20 |
|
16 local script2_onGameStart |
|
17 |
|
18 |
|
19 function grav_onNewTurn() |
15 SetGravity(gravity) |
20 SetGravity(gravity) |
16 wdGameTicks = GameTime |
21 wdGameTicks = GameTime |
|
22 |
|
23 if script2_onNewTurn ~= nil then |
|
24 script2_onNewTurn() |
|
25 end |
17 end |
26 end |
18 |
27 |
19 function onGameTick20() |
28 function grav_onGameTick20() |
20 if wdGameTicks + 15000 < GameTime then |
29 if wdGameTicks + 15000 < GameTime then |
21 SetGravity(100) |
30 SetGravity(100) |
22 else |
31 else |
23 if wdTTL ~= TurnTimeLeft then |
32 if wdTTL ~= TurnTimeLeft then |
24 wdGameTicks = GameTime |
33 wdGameTicks = GameTime |
84 end |
97 end |
85 |
98 |
86 if gravity == nil then |
99 if gravity == nil then |
87 gravity = 100 |
100 gravity = 100 |
88 end |
101 end |
|
102 |
|
103 secondScript = params["script2"] |
|
104 |
|
105 if secondScript ~= nil then |
|
106 onParameters = nil |
|
107 HedgewarsScriptLoad("/Scripts/Multiplayer/" .. secondScript .. ".lua") |
|
108 |
|
109 script2_onNewTurn = onNewTurn |
|
110 script2_onGameTick20 = onGameTick20 |
|
111 script2_onGameStart = onGameStart |
|
112 |
|
113 if onParameters ~= nil then |
|
114 onParameters() |
|
115 end |
|
116 end |
|
117 |
|
118 onNewTurn = grav_onNewTurn |
|
119 onGameTick20 = grav_onGameTick20 |
|
120 onGameStart = grav_onGameStart |
89 end |
121 end |
90 |
122 |
91 function onGameStart() |
123 function grav_onGameStart() |
92 if delta == nil then |
124 if delta == nil then |
93 v = string.format(loc("random in range from %i%% to %i%% with period of %i msec"), div(mingravity, mln), div(maxgravity, mln), period * 40) |
125 v = string.format(loc("random in range from %i%% to %i%% with period of %i msec"), div(mingravity, mln), div(maxgravity, mln), period * 40) |
94 elseif period ~= nil then |
126 elseif period ~= nil then |
95 v = string.format(loc("changing range from %i%% to %i%% with period of %i msec"), div(mingravity, mln), div(maxgravity, mln), period * 40) |
127 v = string.format(loc("changing range from %i%% to %i%% with period of %i msec"), div(mingravity, mln), div(maxgravity, mln), period * 40) |
96 else |
128 else |
101 loc("Current setting is ") .. v, |
133 loc("Current setting is ") .. v, |
102 loc("Setup:|'g=150', where 150 is 150% of normal gravity") .. "|" |
134 loc("Setup:|'g=150', where 150 is 150% of normal gravity") .. "|" |
103 .. loc("or 'g=50, g2=150, period=4000' for gravity changing|from 50 to 150 and back with period of 4000 msec") |
135 .. loc("or 'g=50, g2=150, period=4000' for gravity changing|from 50 to 150 and back with period of 4000 msec") |
104 .. "||" .. loc("Set period to negative value for random gravity"), |
136 .. "||" .. loc("Set period to negative value for random gravity"), |
105 0, 5000) |
137 0, 5000) |
|
138 |
|
139 if script2_onGameStart ~= nil then |
|
140 script2_onGameStart() |
|
141 end |
106 end |
142 end |
|
143 |
|
144 |