TheoAllen

Theo - Page Condition Eval Script (ENG)

Oct 4th, 2013
321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.33 KB | None | 0 0
  1. # =============================================================================
  2. # TheoAllen - Page Condition Eval Script
  3. # Version : 1.0
  4. # Contact : www.rpgmakerid.com (or) http://theolized.blogspot.com
  5. # (English Documentation)
  6. # =============================================================================
  7. ($imported ||= {})[:Theo_PageConditionScript] = true
  8. # =============================================================================
  9. # CHANGE LOGS:
  10. # -----------------------------------------------------------------------------
  11. # 2013.08.11 - Finished script
  12. # =============================================================================
  13. =begin
  14.  
  15.   Introduction :
  16.   By default, there's no such a thing called event page condition eval script
  17.   like in conditional branch. This script allow you to add page condition
  18.   depends on script eval
  19.  
  20.   How to use :
  21.   Put this script below material but above main
  22.   Use this following tags in event comments
  23.  
  24.   <eval cond>
  25.   script
  26.   </eval cond>
  27.  
  28.   If you use many lines, it will be considered as one line
  29.  
  30.   Terms of use :
  31.   Credit me, TheoAllen. You are free to edit this script by your own. As long
  32.   as you don't claim it yours. For commercial purpose, don't forget to give me
  33.   a free copy of the game.
  34.  
  35. =end
  36. # =============================================================================
  37. # No configuration
  38. # =============================================================================
  39. class Game_Event < Game_Character
  40.   alias theo_eval_script_conditions_met? conditions_met?
  41.   def conditions_met?(page)
  42.     script = obtain_script_condition(page.list)
  43.     unless script.empty?
  44.       return eval(script)
  45.     end
  46.     return theo_eval_script_conditions_met?(page)
  47.   end
  48.  
  49.   def obtain_script_condition(list)
  50.     result = ""
  51.     add_string = false
  52.     list.each do |cmd|
  53.       code = cmd.code
  54.       next unless code == 108 || code == 408
  55.       case cmd.parameters[0]
  56.       when /<(?:EVAL_COND|eval cond)>/i
  57.         add_string = true
  58.       when /<\/(?:EVAL_COND|eval cond)>/i
  59.         add_string = false
  60.       else
  61.         next unless add_string
  62.         result += cmd.parameters[0]
  63.       end
  64.     end
  65.     return result
  66.   end
  67.  
  68.   def variables
  69.     if $imported[:THEO_EventVariable]
  70.       return $game_self_variables[$game_map.id,@id]
  71.     end
  72.   end
  73.  
  74. end
Advertisement
Add Comment
Please, Sign In to add comment