dsiver144

Dark's Set Move Route IF Conditional

Mar 22nd, 2016
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.88 KB | None | 0 0
  1. #===============================================================================
  2. #                     ╔════════════════════════════════════════╗
  3. #                     ║ ▼ Dark's Set Move Route IF Conditional ║  
  4. #                     ║ ▼ Author: Nhat Nguyen (Dark Sky)       ║
  5. #                     ║ ▼ Release Date: March 23rd 2016        ║
  6. #                     ║ ▼ Forum: TaoTroChoi.com                ║
  7. #                     ╚════════════════════════════════════════╝
  8. #-------------------------------------------------------------------------------
  9. #                           Version 1.0: Release!
  10. #-------------------------------------------------------------------------------
  11. # Yêu cầu: None
  12. #-------------------------------------------------------------------------------
  13. # Chức năng: Set Self Switch bằng lệnh IF trong Set Move Route. (Event Only)
  14. #-------------------------------------------------------------------------------
  15. # Script call (Trong Set Move Route): =if("Điều kiện",KEY,BOOLEAN)
  16. # "Điều kiện" : Điều kiện bật/tắt self switch.
  17. # "KEY"       : Là tên self switch gồm A,B,C,D.
  18. # "BOOLEAN    : true (bật) hoặc false (tắt).
  19. # Ví dụ: =if("\v[1] >= 5 && \s[4] == false",A,true)
  20. # Công dụng: Nếu var có id là 1 >= 5 và switch có id là 4 = false thì Bật self switch A.
  21. #===============================================================================
  22. VAR_TOKEN    = /=if\(\s*"(.+)"\s*,\s*(A|B|C|D),(true|false)\)/i
  23. #===============================================================================
  24. class Game_Event
  25.   alias :dark_if_condition_setmoveroute_process_move_command :process_move_command
  26.   #--------------------------------------------------------------------------
  27.   # * Process Move Command
  28.   #--------------------------------------------------------------------------
  29.   def process_move_command(command)
  30.     if command.code == ROUTE_SCRIPT
  31.       params = command.parameters
  32.       if params[0] =~ VAR_TOKEN
  33.         self_switch_key = $2.to_s
  34.         self_switch_status = $3.to_s
  35.         if $1.to_s.include?("v[") || $1.to_s.include?("s[")
  36.           check = false
  37.           var_s = $1.to_s.gsub("\\v[") { "$game_variables[" }
  38.           var_s.gsub!("\\s[") { "$game_switches[" }
  39.           var_s = "if #{var_s};check = true;end;"
  40.           eval(var_s)
  41.           if check == true
  42.             key = [@map_id, @event.id, self_switch_key]
  43.             eval("$game_self_switches[#{key}] = #{self_switch_status}")
  44.             setup_page_settings
  45.             refresh
  46.           end
  47.           return
  48.         end
  49.       end
  50.       eval(params[0])
  51.     else
  52.       dark_if_condition_setmoveroute_process_move_command(command)
  53.     end
  54.   end
  55. end
Advertisement
Add Comment
Please, Sign In to add comment