Advertisement
dalvorsn

Untitled

Oct 26th, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 3.00 KB | None | 0 0
  1. diff --git a/modules/game_playerdeath/playerdeath.lua b/modules/game_playerdeath/playerdeath.lua
  2. index 736f86e..53ddf7a 100644
  3. --- a/modules/game_playerdeath/playerdeath.lua
  4. +++ b/modules/game_playerdeath/playerdeath.lua
  5. @@ -1,5 +1,7 @@
  6.  deathWindow = nil
  7.  
  8. +local timeToLogin = 5
  9. +
  10.  local deathTexts = {
  11.    regular = {text = 'Alas! Brave adventurer, you have met a sad fate.\nBut do not despair, for the gods will bring you back\ninto this world in exchange for a small sacrifice\n\nSimply click on Ok to resume your journeys!', height = 140, width = 0},
  12.    unfair = {text = 'Alas! Brave adventurer, you have met a sad fate.\nBut do not despair, for the gods will bring you back\ninto this world in exchange for a small sacrifice\n\nThis death penalty has been reduced by %i%%\nbecause it was an unfair fight.\n\nSimply click on Ok to resume your journeys!', height = 185, width = 0},
  13. @@ -48,25 +50,37 @@ function openWindow(deathType, penalty)
  14.    deathWindow = g_ui.createWidget('DeathWindow', rootWidget)
  15.  
  16.    local textLabel = deathWindow:getChildById('labelText')
  17. +  local text
  18.    if deathType == DeathType.Regular then
  19.      if penalty == 100 then
  20. -      textLabel:setText(deathTexts.regular.text)
  21. +      text = deathTexts.regular.text
  22.        deathWindow:setHeight(deathWindow.baseHeight + deathTexts.regular.height)
  23.        deathWindow:setWidth(deathWindow.baseWidth + deathTexts.regular.width)
  24.      else
  25. -      textLabel:setText(string.format(deathTexts.unfair.text, 100 - penalty))
  26. +      text = string.format(deathTexts.unfair.text, 100 - penalty)
  27.        deathWindow:setHeight(deathWindow.baseHeight + deathTexts.unfair.height)
  28.        deathWindow:setWidth(deathWindow.baseWidth + deathTexts.unfair.width)
  29.      end
  30.    elseif deathType == DeathType.Blessed then
  31. -    textLabel:setText(deathTexts.blessed.text)
  32. +    text = deathTexts.blessed.text
  33.      deathWindow:setHeight(deathWindow.baseHeight + deathTexts.blessed.height)
  34.      deathWindow:setWidth(deathWindow.baseWidth + deathTexts.blessed.width)
  35.    end
  36.  
  37. +
  38. +  local timerText = '\nYou will be logged in %d seconds.'
  39.    local okButton = deathWindow:getChildById('buttonOk')
  40.    local cancelButton = deathWindow:getChildById('buttonCancel')
  41. -
  42. +  
  43. +  for i = 0, timeToLogin do
  44. +    scheduleEvent(function ()
  45. +      local dt = rootWidget:recursiveGetChildById('deathWindow')
  46. +      if dt then
  47. +        dt:getChildById('labelText'):setText(text .. string.format(timerText, timeToLogin - i))
  48. +      end
  49. +    end, i * 1000)
  50. +  end
  51. +  
  52.    local okFunc = function()
  53.      CharacterList.doLogin()
  54.      okButton:getParent():destroy()
  55. @@ -77,7 +91,13 @@ function openWindow(deathType, penalty)
  56.      cancelButton:getParent():destroy()
  57.      deathWindow = nil
  58.    end
  59. -
  60. +  scheduleEvent(function ()
  61. +    local dt = rootWidget:recursiveGetChildById('deathWindow')
  62. +    local ok = dt:getChildById('buttonOk')
  63. +    if dt then
  64. +      signalcall(ok.onClick, ok)
  65. +    end
  66. +  end, timeToLogin * 1000)
  67.    deathWindow.onEnter = okFunc
  68.    deathWindow.onEscape = cancelFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement