Guest User

Untitled

a guest
Jan 15th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.03 KB | None | 0 0
  1. if true #Set to false to disable script.
  2. # (C) Copyright Erisa Arrowsmith (Seriel) 2019
  3. ###############################################################################
  4. # Seriel ~ Dynamic Variables #
  5. # See under this notice for some help. #
  6. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=#
  7. # The code here can be reused for any purpose, with credit given. #
  8. # This includes both Commercial and Non-Commercial use. #
  9. # However, contact is appreciated before Commercial use. #
  10. # Modified versions must give credit, however it must not be implied that the #
  11. # modifications were carried out by me. #
  12. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=#
  13. # Contact: | erisa.arrow@gmail.com | seriel@erisa.moe #
  14. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=#
  15. # Created with ♥ by Erisa Arrowsmith (Seriel) in 2019 #
  16. # Last edited: 2019-01-15 19:16:53 +0000 #
  17. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=#
  18. # This script works by intercepting any call to get a variable and replacing #
  19. # the result with the result of whatever script you have specified below. #
  20. # Using this, you can create "Dynamic" variables which change based on #
  21. # different factors, for example a variable which always displays the #
  22. # current map ID, or the health of the first party member. #
  23. # Due to the nature of how this works, trying to set one of these variables #
  24. # to a specific value in-game will NOT WORK. These only support get. #
  25. ###############################################################################
  26.  
  27. # Config is down here somewhere :)
  28. module Serie_DynVar
  29. ## START CONFIG
  30.  
  31. # Make sure to add a comma on the end of the previous line.
  32. # Basic format:
  33. # 1 => "script_to_execute",
  34. # No comma on the last one!
  35. VAR_ASSIGNMENTS = {
  36. 500 => "$game_map.map_id",
  37. 501 => "$game_party.members[0].hp"
  38. }
  39.  
  40. ## END CONFIG
  41. end
  42.  
  43.  
  44. #==============================================================================
  45. # ** Game_Variables
  46. #------------------------------------------------------------------------------
  47. # This class handles variables. It's a wrapper for the built-in class "Array."
  48. # The instance of this class is referenced by $game_variables.
  49. #==============================================================================
  50.  
  51. class Game_Variables
  52. alias :eri_getvar :[]
  53.  
  54. #--------------------------------------------------------------------------
  55. # * Get Variable
  56. #--------------------------------------------------------------------------
  57. def [](variable_id)
  58. if Serie_DynVar::VAR_ASSIGNMENTS.key?(variable_id)
  59. eval(Serie_DynVar::VAR_ASSIGNMENTS[variable_id])
  60. else
  61. eri_getvar(variable_id)
  62. end
  63. end
  64.  
  65. end
  66.  
  67. end # if true
Add Comment
Please, Sign In to add comment