Script Request
Hello all, I am requesting what I hope is a small edit of Near Fantastica's NPC Interactions script. All I want it to do is while I am in the scroll window, If I press a certain button (doesn't matter, I should be able to change it through the input line) it will pop up a picture with the same file name as the information being displayed.
Script Title:
Here is the script
Here is the link
http://punk.ohsk.net/forums/index.php?show...ction"
RMXP or RMVX:
XP
Screenshots: The picture should be in the middle of the screen and if possible in a different window that adapts to the size of the picture (if possible or easy)
Other Scripts I am using (in order):
Would adding a picture to this script really conflict with anything else if it working fine already? If it would, I will post my scripts.rxdata.
Hello all, I am requesting what I hope is a small edit of Near Fantastica's NPC Interactions script. All I want it to do is while I am in the scroll window, If I press a certain button (doesn't matter, I should be able to change it through the input line) it will pop up a picture with the same file name as the information being displayed.
Script Title:
Here is the script
Code:
#======================================
# â– NPC Interactions
#======================================
#  By: Near Fantastica
# Â Date: 17.06.05
# Â Version: 1
#======================================
#
#================================
# â– Player Log
#================================
Â
class Player_Log
 #--------------------------------------------------------------
 attr_accessor :keys
 #--------------------------------------------------------------
 def initialize
  @keys = []
 end
 #--------------------------------------------------------------
end
Â
#================================
# â– Scene Player Log
#================================
Â
class Scene_Player_Log
 #--------------------------------------------------------------
 def initialize
  @spriteset = nil
  @keys = []
  @replaces = []
  @text = ""
  @list = $player_log.keys
  file = $player_log.keys[0]
  file.upcase!
  setup(file)
 end
 #--------------------------------------------------------------
 def setup(file)
  @list.push(file) if not @list.include?(file)
  @keys = []
  @replaces = []
  @file = file + ".rxdata"
  @text = IO.readlines("NPC Interactions/#{@file}")
  find_keys
  find_text
 end
 #--------------------------------------------------------------
 def find_keys
  for line in @text
   x = @text.index(line)
   words = line.split
   for word in words
    if word.include?("[") and word.include?("]")
     @replaces.push(x)
     word.delete!("[")
     word.delete!("]")
     word.gsub!(/_/, ' ')
     @keys.push(word)
     if not @list.include?(word)
      @list.push(word)
     end
    end
   end
  end
 end
 #--------------------------------------------------------------
 def find_text
  for replace in @replaces
   line = @text[replace]
   line.delete!("[")
   line.delete!("]")
   line.gsub!(/_/, ' ')
   @text[replace] = line
  end
 end
 #--------------------------------------------------------------
 def main
  @spriteset = Spriteset_Map.new
  @command_window = Window_Command.new(180, @list)
  @command_window.height = 480
  @command_window.opacity = 100
  @scroll_window = Window_Scrolling.new(@keys, @replaces, @text)
  Graphics.transition
  loop do
   Graphics.update
   Input.update
   update
   if $scene != self
    break
   end
  end
  Graphics.freeze
  @spriteset.dispose
  @command_window.dispose
  @scroll_window.dispose
 end
 #--------------------------------------------------------------
 def update
  @command_window.update
  @scroll_window.update
  if @command_window.active
   update_command
   return
  end
  if @scroll_window.active
   update_scroll
   return
  end
 end
 #--------------------------------------------------------------
 def update_command
  if Input.trigger?(Input::B)
   $game_system.se_play($data_system.cancel_se)
   $scene = Scene_Map.new
   return
  end
  if Input.trigger?(Input::C)
   $game_system.se_play($data_system.decision_se)
   setup(@list[@command_window.index])
   @command_window.setup(@list)
   @scroll_window.y = 0
   @scroll_window.setup(@keys, @replaces, @text)
   @command_window.active = false
   @scroll_window.active = true
   return
  end
 end
 #--------------------------------------------------------------
 def update_scroll
  if Input.trigger?(Input::B)
   $game_system.se_play($data_system.cancel_se)
   @command_window.active = true
   @scroll_window.active = false
   return
  end
  if Input.repeat?(Input::UP)
   return if @scroll_window.y == 0
   @scroll_window.y+=16
  end Â
  if Input.repeat?(Input::DOWN)
   return if (@scroll_window.sy - 480) <= (@scroll_window.y * -1)
   @scroll_window.y-=16
  end Â
 end
end
Â
#================================
# â– Scene Interaction
#================================
Â
class Scene_NPC_Interaction
 #--------------------------------------------------------------
 def initialize(interpreter, file = nil)
  @spriteset = nil
  @interpreter = interpreter
  @name = @interpreter.event.name
  file = @name if file == nil
  @keys = []
  @replaces = []
  @text = ""
  @list = []
  file.upcase!
  setup(file)
 end
 #--------------------------------------------------------------
 def setup(file)
  @list.push(file) if not @list.include?(file)
  @keys = []
  @replaces = []
  @file = file + ".rxdata"
  @text = IO.readlines("NPC Interactions/#{@file}")
  find_keys
  find_text
 end
 #--------------------------------------------------------------
 def find_keys
  for line in @text
   x = @text.index(line)
   words = line.split
   for word in words
    if word.include?("[") and word.include?("]")
     @replaces.push(x)
     word.delete!("[")
     word.delete!("]")
     word.gsub!(/_/, ' ')
     @keys.push(word)
     if not @list.include?(word)
      @list.push(word)
     end
    end
   end
  end
 end
 #--------------------------------------------------------------
 def find_text
  for replace in @replaces
   line = @text[replace]
   line.delete!("[")
   line.delete!("]")
   line.gsub!(/_/, ' ')
   @text[replace] = line
  end
 end
 #--------------------------------------------------------------
 def main
  @spriteset = Spriteset_Map.new
  @name_window = Window_Name.new(@name)
  @command_window = Window_Command.new(180, @list)
  @command_window.y = 64
  @command_window.height = 416
  @command_window.opacity = 100
  @scroll_window = Window_Scrolling.new(@keys, @replaces, @text)
  Graphics.transition
  loop do
   Graphics.update
   Input.update
   update
   if $scene != self
    break
   end
  end
  player_keys = $player_log.keys
  @list.shift
  npc_keys = @list
  temp = player_keys | npc_keys
  $player_log.keys = temp
  Graphics.freeze
  @spriteset.dispose
  @name_window.dispose
  @command_window.dispose
  @scroll_window.dispose
 end
 #--------------------------------------------------------------
 def update
  @command_window.update
  @scroll_window.update
  if @command_window.active
   update_command
   return
  end
  if @scroll_window.active
   update_scroll
   return
  end
 end
 #--------------------------------------------------------------
 def update_command
  if Input.trigger?(Input::B)
   $game_system.se_play($data_system.cancel_se)
   $scene = Scene_Map.new
   return
  end
  if Input.trigger?(Input::C)
   $game_system.se_play($data_system.decision_se)
   setup(@list[@command_window.index])
   @command_window.setup(@list)
   @scroll_window.y = 0
   @scroll_window.setup(@keys, @replaces, @text)
   @command_window.active = false
   @scroll_window.active = true
   return
  end
 end
 #--------------------------------------------------------------
 def update_scroll
  if Input.trigger?(Input::B)
   $game_system.se_play($data_system.cancel_se)
   @command_window.active = true
   @scroll_window.active = false
   return
  end
  if Input.repeat?(Input::UP)
   return if @scroll_window.y == 0
   @scroll_window.y+=16
  end Â
  if Input.repeat?(Input::DOWN)
   return if (@scroll_window.sy - 480) <= (@scroll_window.y * -1)
   @scroll_window.y-=16
  end Â
 end
end
Â
#================================
# â– Window Scroll
#================================
Â
class Window_Scrolling < Window_Base
 #--------------------------------------------------------------
 attr_reader  :sy
 #--------------------------------------------------------------
 def initialize(keys, replaces, text)
  @sx = 460
  if text.size * 32 >= 480
   @sy = (text.size+1) * 32
  else
   @sy = 480
  end
  super(180, 0, @sx, @sy)
  @keys = keys
  @replaces = replaces
  @text= text
  self.opacity = 100
  self.contents = Bitmap.new(@sx - 32, @sy - 32)
  self.contents.font.name = $defaultfonttype
  self.contents.font.size = $defaultfontsize
  refresh
 end
 #--------------------------------------------------------------
 def refresh
  self.contents.clear
  y=0
  for i in [email=0...@text.size]0...@text.size[/email]
   if @replaces.include?(i)
    id = @replaces.index(i)
    words = @text[i].split
    lenght = 0
    for word in words
     key_words = @keys[id].split
     if key_words.include?(word)
      self.contents.font.color = text_color(6)
      self.contents.draw_text(lenght, y, @sx, 32, word)
      temp = self.contents.text_size(word)
      lenght += temp.width
      lenght += 8
     else
      self.contents.font.color = normal_color
      self.contents.draw_text(lenght, y, @sx, 32, word)
      temp = self.contents.text_size(word)
      lenght += temp.width
      lenght += 8
     end
    end
   else
    self.contents.font.color = normal_color
    self.contents.draw_text(0, y, @sx, 32, @text[i])
   end
   y+=32
  end
 end
 #--------------------------------------------------------------
 def setup(keys, replaces, text)
  @keys = keys
  @replaces = replaces
  @text= text
  if @text.size * 32 >= 480
   @sy = (text.size+1) * 32
  else
   @sy = 480
  end
  self.height = @sy
  self.contents.dispose
  self.contents = Bitmap.new(@sx - 32, @sy - 32)
  self.contents.font.name = $defaultfonttype
  self.contents.font.size = $defaultfontsize
  refresh
 end
end
Â
#================================
# â– Window Name
#================================
Â
class Window_Name < Window_Base
 #--------------------------------------------------------------------------
 def initialize(name)
  @name = name
  super(0, 0, 180, 64)
  self.contents = Bitmap.new(width - 32, height - 32)
  self.contents.font.name = $defaultfonttype  # "Gold" window font
  self.contents.font.size = $defaultfontsize
  self.opacity = 100
  refresh
 end
 #--------------------------------------------------------------------------
 def refresh
  self.contents.clear
  self.contents.draw_text(0, 0, 160, 32, @name, 1)
 end
end
Â
Â
#================================
# â– Window Command
#================================
Â
class Window_Command < Window_Selectable
  #--------------------------------------------------------------
 def setup(commands)
  @commands = commands
  @item_max = commands.size
  self.contents.dispose
  self.contents = Bitmap.new(width - 32, @item_max * 32)
  self.contents.font.name = $defaultfonttype
  self.contents.font.size = $defaultfontsize
  refresh
 end
end
Â
#======================================
# â– Interpreter
#======================================
Â
class Interpreter
 def event
  return $game_map.events[@event_id]
 end
end
Â
#======================================
# â– Game Event
#======================================
Â
class Game_Event < Game_Character
 #--------------------------------------------------------------------------
 def name
  return @event.name
 end
end
Here is the link
http://punk.ohsk.net/forums/index.php?show...ction"
RMXP or RMVX:
XP
Screenshots: The picture should be in the middle of the screen and if possible in a different window that adapts to the size of the picture (if possible or easy)
Other Scripts I am using (in order):
Would adding a picture to this script really conflict with anything else if it working fine already? If it would, I will post my scripts.rxdata.