daily pastebin goal
3%
SHARE
TWEET

VX Ace Choice Injection demo script

Balrogic Dec 27th, 2014 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Choice Injector by Balrogic
  2. #
  3. # This is a hack, not a finished script. Is is
  4. # intended to demonstrate the feasibility of
  5. # certain scripting approaches within the system.
  6. # I'd have used accessor methods if they didn't
  7. # keep CTDing me. Uncooperative in parts of this
  8. # or maybe I'm just doing it wrong, I'm still
  9. # really new to all of this but I've chased it
  10. # several levels deep until it still crashes with
  11. # a warning that there's no @variable= method set.
  12. # ...Even after creating that specific method.
  13.  
  14. module Test
  15.  
  16.   def self.run
  17.     @override = true
  18.     Test::add("Hey! Where do you think you're going!?
  19. Go find some villages and I'll teleport you.") unless @teleport
  20.     if @teleport
  21.       Test::choice_cancel(0)
  22.       Test::add("There's no backing out now!")
  23.       @teleport.each {|x|
  24.       case x
  25.       when 1
  26.         Test::choice("Village A")
  27.       when 2
  28.         Test::choice("Village B")
  29.       when 3
  30.         Test::choice("Village C")
  31.       end
  32.       }
  33.       Test::add("Where would you like to go!?")
  34.       @chain = 1
  35.     end
  36.   end
  37.  
  38.   def self.chain
  39.     @override = nil unless @chain
  40.     case @chain
  41.     when nil
  42.       # Do nothing.
  43.     when 1
  44.       Test::teleport
  45.     when 2
  46.       # Do-me-do-me-dooooooo... If you ever... Need me to!
  47.     end
  48.   end
  49.  
  50.   def self.teleport
  51.     case @teleport[@index]
  52.     when 1
  53.       $game_player.reserve_transfer(3, 21, 39, 8)
  54.     when 2
  55.       $game_player.reserve_transfer(4, 20, 40, 8)
  56.     when 3
  57.       $game_player.reserve_transfer(5, 17, 41, 8)
  58.     end
  59.     $game_temp.fade_type = 1
  60.     RPG::SE.new("Teleport", 100, 100).play
  61.     Test::clear
  62.   end
  63.  
  64. #######################################################################
  65. #     Everything below this point relates to basic functionality.     #
  66. #######################################################################
  67.  
  68.   @chain    = nil # Selector for next method in chain.
  69.   @index    = nil # Remembers previous menu choice.
  70.   @loop     = nil # Prevents side-effects.
  71.   @override = nil # Prevents CTD when set, also breaks event set choices.
  72.   @teleport = nil # Teleportation array.
  73.  
  74.   def self.index(index)
  75.     @index = index
  76.   end
  77.  
  78.   def self.loop
  79.     @loop
  80.   end
  81.  
  82.   def self.loop_set(x)
  83.     @loop = x
  84.   end
  85.  
  86.   def self.override
  87.     @override
  88.   end
  89.  
  90.   def self.add(text)
  91.     $game_message.add(text)
  92.   end
  93.  
  94.   def self.choice(text)
  95.     $game_message.choices.push(text)
  96.   end
  97.  
  98.   def self.choice_cancel(type)
  99.     $game_message.choice_cancel_type = type
  100.   end
  101.  
  102.   def self.teleport_set(town)
  103.     @teleport ||= []
  104.     @teleport.push(town)
  105.   end
  106.  
  107.   def self.clear
  108.     @chain    = nil
  109.     @index    = nil
  110.     @loop     = nil
  111.     @override = nil
  112.   end
  113.  
  114. end
  115.  
  116. class Window_ChoiceList < Window_Command
  117.  
  118.   def call_ok_handler
  119.     $game_message.choice_proc.call(index) unless Test::override
  120.     close
  121.     Test::index(index)
  122.     Test::loop_set(true)
  123.   end
  124.  
  125.   def call_cancel_handler
  126.     $game_message.choice_proc.call($game_message.choice_cancel_type - 1) unless Test::override
  127.     Test::index($game_message.choice_cancel_type - 1)
  128.     close
  129.     Test::loop_set(true)
  130.   end
  131.  
  132. end
  133.  
  134. class Window_Base < Window
  135.  
  136.   def update_close
  137.     self.openness -= 48
  138.     @closing = false if close?
  139.     Test::chain if Test::loop
  140.     Test::loop_set(nil) if Test::loop
  141.   end
  142.  
  143. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top