DaxSoft

Block Variables & Switches 1.1

Mar 6th, 2014
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #==============================================================================
  2. # • Block Variables & Switche
  3. #==============================================================================
  4. # Autor: Dax
  5. # Versão: 1.1
  6. # Site: www.dax-soft.weebly.com
  7. # Requerimento: Dax Core
  8. #==============================================================================
  9. # • Descrição:
  10. #------------------------------------------------------------------------------
  11. # Quando a variável ou switche estiver com um determinado valor um bloco(que você
  12. # define) irá executar.
  13. #==============================================================================
  14. # • Como usar: CHAMAR SCRIPT|Ou numa classe ou método.
  15. #------------------------------------------------------------------------------
  16. # ************************ Variáveis ******************************************
  17. # var_block(id, value, type) { command }
  18. # * id : ID da variável.
  19. # * value : Quando ela estiver com esse valor.
  20. # * type : Tipo da condição. Exemplo ">="
  21. # * command : Comando que irá executar.
  22. # Exemplo:
  23. # var_block(1, 50) { $game_variables[2] = 100 }
  24. # ************************ Switches ******************************************
  25. # sw_block(id, value) { command }
  26. # * id : ID da switche.
  27. # * value : Quando ela estiver com esse valor.
  28. # * command : Comando que irá executar.
  29. # Exemplo:
  30. # sw_block(1, false) { msgbox("Ativar Switche")
  31. # $game_switches[1] = true
  32. # }
  33. #==============================================================================
  34. Dax.register(:block_variables_and_switches, "Dax", 1.1, "06/03/14")
  35. #==============================================================================
  36. # • Object
  37. #==============================================================================
  38. class Object
  39. #----------------------------------------------------------------------------
  40. # • Variáveis.
  41. #----------------------------------------------------------------------------
  42. def var_block(id, value, cod=">=", &block)
  43. return unless block_given?
  44. eval("block.call if $game_variables[id] #{cod} value")
  45. end
  46. #----------------------------------------------------------------------------
  47. # • Switches.
  48. #----------------------------------------------------------------------------
  49. def sw_block(id, value, &block)
  50. return unless block_given?
  51. block.call if $game_switches[id] == value
  52. end
  53. end
Advertisement
Add Comment
Please, Sign In to add comment