share/hedgewars/Data/Scripts/Multiplayer/Gravity.lua
author unc0rr
Wed, 01 Jan 2014 23:41:49 +0400
changeset 9906 93c16a4b0c6a
parent 9902 eb8e8b09b2f0
child 9908 81eb25ddf594
permissions -rw-r--r--
Only emit roomNameUpdated when it actually is changed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9836
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
     1
HedgewarsScriptLoad("/Scripts/Locale.lua")
9906
93c16a4b0c6a Only emit roomNameUpdated when it actually is changed
unc0rr
parents: 9902
diff changeset
     2
HedgewarsScriptLoad("/Scripts/Params.lua")
9836
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
     3
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
     4
local gravity = 100
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
     5
local wdGameTicks = 0
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
     6
local wdTTL = 0
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
     7
9816
e71188c140ee No gravity mode
unc0rr
parents:
diff changeset
     8
function onNewTurn()
9836
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
     9
    SetGravity(gravity)
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
    10
    wdGameTicks = GameTime
9816
e71188c140ee No gravity mode
unc0rr
parents:
diff changeset
    11
end
e71188c140ee No gravity mode
unc0rr
parents:
diff changeset
    12
e71188c140ee No gravity mode
unc0rr
parents:
diff changeset
    13
function onGameTick20()
9898
b87695f82d2e Don't set gravity to normal immediately on turn end, let watchdog do its job if game gets frozen
unc0rr
parents: 9836
diff changeset
    14
    if wdGameTicks + 15000 < GameTime then
9816
e71188c140ee No gravity mode
unc0rr
parents:
diff changeset
    15
        SetGravity(100)
9836
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
    16
    elseif wdTTL ~= TurnTimeLeft then
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
    17
        wdGameTicks = GameTime
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
    18
        SetGravity(gravity)
9816
e71188c140ee No gravity mode
unc0rr
parents:
diff changeset
    19
    end
9836
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
    20
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
    21
    wdTTL = TurnTimeLeft
9816
e71188c140ee No gravity mode
unc0rr
parents:
diff changeset
    22
end
9836
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
    23
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
    24
function onGameInit()
9906
93c16a4b0c6a Only emit roomNameUpdated when it actually is changed
unc0rr
parents: 9902
diff changeset
    25
    parseParams()
9902
eb8e8b09b2f0 Special script parameter variable in game scheme
unc0rr
parents: 9898
diff changeset
    26
    gravity = ScriptParam
9836
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
    27
end
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
    28
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
    29
function onGameStart()
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
    30
    ShowMission(loc("Gravity"),
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
    31
                loc("Current value is ") .. gravity .. "%",
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
    32
                loc("Set any gravity value you want by adjusting get away time"),
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
    33
                0, 5000)
9902
eb8e8b09b2f0 Special script parameter variable in game scheme
unc0rr
parents: 9898
diff changeset
    34
end