The RPG Maker Resource Kit

RMRK RPG Maker Creation => VX => VX Scripts Database => Topic started by: IXFURU on August 12, 2012, 01:50:22 AM

Title: Ixfuru's ToolBox
Post by: IXFURU on August 12, 2012, 01:50:22 AM
IXFURU'S TOOLBOX 1.0

INTRODUCTION

This little script calls a window where you can display often-used items.

FEATURES

The script has several customization options which include height, width, x and y location, colors and more!

SCREENSHOTS

Spoiler for Notice, when party is out of tool, it shows up RED.:
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi16.photobucket.com%2Falbums%2Fb38%2FDwiguitar%2Ftoolboxpic.jpg&hash=39581132d061a5ff9bcef5e08cea5f7c78b060d6)

HOW TO USE

Just copy the script from below and paste it in the script editor below materials and above main.  The script uses a single switch and a toggle key which is used to activate/deactivate the switch.  You can set these things up in the configuration section, along with other more cosmetic features.

DEMO
This is a small and basically self-explanatory script.  I may upload a demo soon if the need requires, but just try it out first by taking the script.

SCRIPT
Spoiler for Ixfuru's ToolBox:
Code: [Select]
################################################################################
# IXFURU'S TOOLBOX
#   Written By: IXFURU
# 8/11/12
################################################################################

################################################################################
#    This script allows you to add a 'callable' window through player
# input which will show a quick window with icons of items and a value next
# to it showing the amount of the item which is currently in possession.
################################################################################

################################################################################
#   Credit: IXFURU
#  Please give credit if you use, a link to the project would be thanks enough
################################################################################

################################################################################
# CONFIGURATION SECTION
################################################################################
module ITB
  TOOLS = [3, 5, 8, 12, 21] #item ids of tools to display
  TOOLSWITCH = 20 # Switch toggled to open/close window if above is true
  TOOLSWITCH_INPUT = Input::R  # This is the input key
# used to open and close the toolbox window.
  TOOL_TEXT = "Tools"   #Text displayed at top of toolbox window
  TOOL_TEXT_COLOR = 29 # Text color for TOOL_TEXT.  Integer 0-31
  TOOLBOX_X = 440 #X location of where the toolbox opens
  TOOLBOX_Y = 100 #Y location of where the toolbox opens
  NO_TOOLS_COLOR = 18   #Color of tool amount when zero are in possession
  SOME_TOOLS_COLOR = 0 #Color of tool amount when one or more are in possession
  TOOLBOX_WIDTH = 100  #width of the window
  TOOLBOX_HEIGHT_MULTIPLIER = 38  #height of the window is based on amount of tools
  #multiplied by this value
end
################################################################################
#    END CONFIGURATION SECTION 
################################################################################

class Window_Toolbox < Window_Base
 
  def initialize
super(ITB::TOOLBOX_X, ITB::TOOLBOX_Y, ITB::TOOLBOX_WIDTH, ITB::TOOLS.size * ITB::TOOLBOX_HEIGHT_MULTIPLIER)
@x = ITB::TOOLBOX_X #set the x position of toolbox
@y = ITB::TOOLBOX_Y #set teh y position of toolbox
draw_toolbox_text    #call method to draw text
  end
 
 
  def draw_toolbox_text
self.contents.font.color = text_color(ITB::TOOL_TEXT_COLOR)  #set color of text
self.contents.draw_text((ITB::TOOLBOX_WIDTH-self.width)/2, 4, self.width, WLH, ITB::TOOL_TEXT) # draw the text
  end
 

  def refresh
contents.clear
draw_toolbox_text
tib = 0   # create the iteration variable
tibsy = 30   #set iteration variable used for y positioning
for i in ITB::TOOLS  #  once for each item in the toolbox
  tool = $data_items[ITB::TOOLS[tib]]
  draw_icon(tool.icon_index, 4, tibsy, enabled = true)
  if $game_party.item_number($data_items[ITB::TOOLS[tib]]) == 0   # if party doesn't have this item
self.contents.font.color = text_color(ITB::NO_TOOLS_COLOR)
  else
self.contents.font.color = text_color(ITB::SOME_TOOLS_COLOR)
  end
  self.contents.draw_text(40, tibsy, self.width, WLH, $game_party.item_number($data_items[ITB::TOOLS[tib]]))
  tibsy += 24
  tib += 1
end
  end    #End of Method
 
end #End of Class

 
  ##############################################################################
  # Scene_Map
  ##############################################################################
 
  class Scene_Map < Scene_Base

def close_toolbox
  Sound.play_decision
  $game_switches[ITB::TOOLSWITCH] = false
  @tool_window.dispose
end

def update_toolbox
  @tool_window.refresh
end

def open_toolbox
  Sound.play_decision
  $game_switches[ITB::TOOLSWITCH] = true
  @tool_window = Window_Toolbox.new
end


def check_for_toolbox_input
  if Input.trigger?(ITB::TOOLSWITCH_INPUT)
if $game_switches[ITB::TOOLSWITCH] == false
  open_toolbox
else
  close_toolbox
end
  end
end


 

alias itb_sm_update update
def update
  itb_sm_update
  if $game_switches[ITB::TOOLSWITCH] == true
update_toolbox
check_for_toolbox_input
  else
check_for_toolbox_input
  end
end


  alias itb_sm_call_battle call_battle
  def call_battle
itb_sm_call_battle
$game_switches[ITB::TOOLSWITCH] = false
  end

  alias itb_sm_call_shop call_shop
  def call_shop
itb_sm_call_shop
$game_switches[ITB::TOOLSWITCH] = false
  end

  alias itb_sm_call_name call_name
  def call_name
itb_sm_call_name
$game_switches[ITB::TOOLSWITCH] = false
  end

  alias itb_sm_call_menu call_menu
  def call_menu
itb_sm_call_menu
$game_switches[ITB::TOOLSWITCH] = false
  end
 
  alias itb_sm_call_save call_save
  def call_save
itb_sm_call_save
$game_switches[ITB::TOOLSWITCH] = false
  end

  alias itb_sm_call_debug call_debug
  def call_debug
itb_sm_call_debug
$game_switches[ITB::TOOLSWITCH] = false
  end

  alias itb_sm_call_gameover call_gameover
  def call_gameover
itb_sm_call_gameover
$game_switches[ITB::TOOLSWITCH] = false
  end
 
  alias itb_sm_call_title call_title
  def call_title
itb_sm_call_title
$game_switches[ITB::TOOLSWITCH] = false
  end
 
end

INCOMPATIBLE SCRIPTS

I don't think there should be any problems.  As this script aliases existing methods in Game Map and changes little else.
I'll be working to make it compatible with individual inventories, as I know that will be a request soon enough.

CREDIT
Credit me if you use the script and a link to the project would be nice, you can PM it or just post it here.  Thanks.

AUTHORS NOTE

If you have any problems with the script or find a bug, let me know by posting in this topic, PMing me here on the site or drop a topic in the FINISH LINE forum at RPGMakerVX.net.
Title: Re: Ixfuru's ToolBox
Post by: modern algebra on August 12, 2012, 03:03:38 AM
Nice idea!
Title: Re: Ixfuru's ToolBox
Post by: IXFURU on August 12, 2012, 03:49:33 AM
Thanks, Modern. 

I'm still no good at scripting, but I've been throwing caution to the wind lately!   

I was kind of inspired by another script I saw that only allowed one item and ran off a lot of game variables.


I'm hoping to make it compatible with your Grid Inventory script.

I set it up this way first so I could share it with the forums.