timerobject final


/ Published in: C++
Save to your folder(s)



Copy this code and paste it in your HTML
  1. ;======================
  2. /* Timers
  3.  
  4. Usage
  5. ____________________________________
  6.  
  7. **Place the following line at the top of your .iss file
  8. #include "${LavishScript.CurrentDirectory}/Scripts/vg_objects/Obj_Timers.iss"
  9.  
  10. **In your script call the following object with these commands, or type this in the console
  11.  
  12. Timers Methods(Things you can do)
  13. obj_timer:Add["Name of Timer" "Time in 1/10 Seconds"]
  14. obj_timer:Remove[Name of Timer]
  15. obj_timer:ClearAllTimers
  16.  
  17.   Timers Members(Things you can question of Timers)
  18. obj_timer.TimeRemaining["Name of Timer"]
  19.  
  20.  
  21. Notes
  22. ____________________________________
  23. ** You dont need to know how an object works to use it.
  24. ** Objects are bits of code that perform specific functions.
  25. ** This function specifically Creates Timers for you
  26. ** You should clear all timers at the beginning and end of your script
  27.  
  28.  
  29. Credits
  30. ____________________________________
  31.   * Created by mmoaddict
  32. * Special Thanks to Amadeus and Lax for all their work
  33.  
  34. */
  35. ;======================
  36. variable settingsetref Timers_ssr
  37.  
  38. objectdef obj_timer
  39. {
  40. ;======================
  41. /* Object Variables */
  42. ;======================
  43.  
  44.  
  45.  
  46. ;===================================================
  47. ;=== Methods/Members to be Used ====
  48. ;===================================================
  49.  
  50. method Add(string TimerName, int TimeSet)
  51. {
  52. if ( ${TimerName.Length} > 1 && ${TimeSet} > 1)
  53. {
  54. echo adding ${Script.Filename} ${TimerName} ${Script.RunningTime} ${TimeSet} ${Math.Calc[(${TimeSet} + ${Script.RunningTime}]}
  55. This:LS
  56. LavishSettings[Timers].FindSet[TimersList]:AddSetting[${TimerName}, ${Math.Calc[(${TimeSet} + ${Script.RunningTime}]}]
  57. This:XMLSave
  58. }
  59.  
  60. }
  61. method Remove(string TimerName)
  62. {
  63. if ( ${TimerName.Length} > 1 )
  64. {
  65. This:LS
  66. Timers_ssr.FindSetting[${TimerName}]:Remove
  67. This:XMLSave
  68. }
  69. }
  70. method ClearAllTimers()
  71. {
  72. This:LS
  73. variable iterator Iter
  74. Timers_ssr:GetSettingIterator[Iter]
  75. Iter:First
  76. while ( ${Iter.Key(exists)} )
  77. {
  78. Timers_ssr.FindSetting[${Iter.Key}]:Remove
  79. Iter:Next
  80. }
  81. This:XMLSave
  82. }
  83. member:uint TimeRemaining(string TimerName)
  84. {
  85. This:LS
  86. variable iterator Iter
  87. Timers_ssr:GetSettingIterator[Iter]
  88. Iter:First
  89. while ( ${Iter.Key(exists)} )
  90. {
  91. if ${Iter.Key.Equal[${TimerName}]}
  92. {
  93. if ${Script.RunningTime}>=${Iter.Value}
  94. return 0
  95. return ${Math.Calc[${Iter.Value}-${Script.RunningTime}]}
  96. }
  97. Iter:Next
  98. }
  99. return 0
  100. }
  101.  
  102. ;===================================================
  103. ;=== DO NOT USE THESE ROUTINES ====
  104. ;===================================================
  105.  
  106.  
  107. ;============================
  108. /* LavishSettings */
  109. ;============================
  110. method LS()
  111. {
  112. LavishSettings[Timers]:Clear
  113. LavishSettings:AddSet[Timers]
  114. LavishSettings[Timers]:AddSet[TimersList]
  115. LavishSettings[Timers]:Import[${LavishScript.CurrentDirectory}/scripts/vg_objects/save/Obj_Timers_${Script.Filename}_${Me.FName}.xml]
  116. Timers_ssr:Set[${LavishSettings[Timers].FindSet[TimersList]}]
  117. }
  118.  
  119. ;============================
  120. /* Save Variables to XML */
  121. ;============================
  122. method XMLSave()
  123. {
  124. LavishSettings[Timers]:Export[${LavishScript.CurrentDirectory}/scripts/vg_objects/save/Obj_Timers_${Script.Filename}_${Me.FName}.xml]
  125. }
  126.  
  127. }
  128.  
  129.  
  130.  
  131. variable(global) obj_timer obj_timer

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.