Advertisement
dsiver144

DSI Limit Variable Range

Aug 10th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. #==============================================================================
  2. # DSI Limit Variable Range
  3. # -- Last Updated: 2017.08.11
  4. # -- Author: dsiver144
  5. # -- Level: Easy
  6. # -- Requires: n/a
  7. #==============================================================================
  8. $imported = {} if $imported.nil?
  9. $imported["DSI-LimitVariableRange"] = true
  10. #==============================================================================
  11. # + Updates
  12. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  13. # 2017.08.11 - Finish first version.
  14. #==============================================================================
  15. # + Instructions
  16. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  17. # To install this script, open up your script editor and copy/paste this script
  18. # to an open slot below ▼Materials but above ▼Main. Remember to save.
  19. #==============================================================================
  20. module DSIVER144
  21. module VARIABLE
  22. LIMITS = {} # Do not delete this line.
  23. #--------------------------------------------------------------------------
  24. # Configurable [Start]
  25. #--------------------------------------------------------------------------
  26. # LIMIT[ variable_id ] = [ min_value, max_value ]
  27. # You can add as much as you want.
  28. #--------------------------------------------------------------------------
  29. LIMITS[63] = [0, 100]
  30. LIMITS[64] = [0, 100]
  31. #--------------------------------------------------------------------------
  32. # Configurable [End]
  33. #--------------------------------------------------------------------------
  34. end # VARIABLE
  35. end # DSIVER144
  36.  
  37. class Game_Variables
  38. #--------------------------------------------------------------------------
  39. # * Set Variable [Overwrite]
  40. #--------------------------------------------------------------------------
  41. def []=(variable_id, value)
  42. @data[variable_id] = value
  43. if DSIVER144::VARIABLE::LIMITS.has_key?(variable_id)
  44. min_value = DSIVER144::VARIABLE::LIMITS[variable_id][0]
  45. max_value = DSIVER144::VARIABLE::LIMITS[variable_id][1]
  46. # This line for comparing between 3 values and return the value in range.
  47. get_min_max = [[min_value, value].max, max_value].min
  48. @data[variable_id] = get_min_max
  49. end
  50. on_change
  51. end
  52. end # Game_Variables
  53. #===============================================================================
  54. # END OF SCRIPT
  55. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement