Greetings.
I'm looking for a script that allows you to bring up your items on map and use them on other events.
Doctor was kind enough to provide me with an RGSS script created by RPG that does exactly this.
But I need it in RGSS2 for VX.
So, here it is for your reference or converting.
I hope this is the right place for this (and not the RGSS support forum)
Anyway if someone could do it I'd be a happy panda.
I'm looking for a script that allows you to bring up your items on map and use them on other events.
Doctor was kind enough to provide me with an RGSS script created by RPG that does exactly this.
But I need it in RGSS2 for VX.
So, here it is for your reference or converting.
#=========================================================
# Field_Item - Script by RPG -
# - A class that calls a small item menu and
# handles using/giving an item on/to an event.
#=========================================================
class Field_Item
#---------------------------------------------------------------
# The main method and loop.
#---------------------------------------------------------------
def main
# This variable is used to exit the main loop
@done = false
# Setup the new item window with the small flag
@item_window = Window_Special.new(true)
@item_window.refresh
# The main loop
loop do
# Update graphics, input and this class
Graphics.update
Input.update
update
# Break out of loop if the value of done is true
if @done == true
break
end
end
# Get rid of the window
@item_window.dispose
end
#---------------------------------------------------------------
# Check for input and update the item window.
#---------------------------------------------------------------
def update
# Call the item window update method
@item_window.update
# If the cancel key was pressed, close the window
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@done = true
return
end
#If it was the decision key, and an item is selected...
if Input.trigger?(Input::C)
unless @item_window.item.is_a?(RPG::Item) or
@item_window.item.is_a?(RPG::Weapon) or
@item_window.item.is_a?(RPG::Armor)
$game_system.se_play($data_system.buzzer_se)
return
end
# then try using it then close the window
use_item
@done = true
return
end
end
#---------------------------------------------------------------
# Make changes to indicate that an item was used.
#---------------------------------------------------------------
def use_item
# Get the id of the event the hero is facing
x, y, dir = $game_player.x, $game_player.y, $game_player.direction
newx = x + (dir == 6 ? 1 : dir == 4 ? -1 : 0)
newy = y + (dir == 2 ? 1 : dir == 8 ? -1 : 0)
event_id = $game_map.check_event(newx, newy)
# Check if there is an event and get the map id
if event_id == nil
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
map_id = $game_map.map_id
# Set the value of self switch D of that event to true (ON)
key = [map_id, event_id, "D"]
$game_self_switches[key] = true
# Store the selected item in the global variable $field_item
$field_item = @item_window.item
# Refresh the map to reflect any changes
$game_map.need_refresh = true
end
end
# Field_Item - Script by RPG -
# - A class that calls a small item menu and
# handles using/giving an item on/to an event.
#=========================================================
class Field_Item
#---------------------------------------------------------------
# The main method and loop.
#---------------------------------------------------------------
def main
# This variable is used to exit the main loop
@done = false
# Setup the new item window with the small flag
@item_window = Window_Special.new(true)
@item_window.refresh
# The main loop
loop do
# Update graphics, input and this class
Graphics.update
Input.update
update
# Break out of loop if the value of done is true
if @done == true
break
end
end
# Get rid of the window
@item_window.dispose
end
#---------------------------------------------------------------
# Check for input and update the item window.
#---------------------------------------------------------------
def update
# Call the item window update method
@item_window.update
# If the cancel key was pressed, close the window
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@done = true
return
end
#If it was the decision key, and an item is selected...
if Input.trigger?(Input::C)
unless @item_window.item.is_a?(RPG::Item) or
@item_window.item.is_a?(RPG::Weapon) or
@item_window.item.is_a?(RPG::Armor)
$game_system.se_play($data_system.buzzer_se)
return
end
# then try using it then close the window
use_item
@done = true
return
end
end
#---------------------------------------------------------------
# Make changes to indicate that an item was used.
#---------------------------------------------------------------
def use_item
# Get the id of the event the hero is facing
x, y, dir = $game_player.x, $game_player.y, $game_player.direction
newx = x + (dir == 6 ? 1 : dir == 4 ? -1 : 0)
newy = y + (dir == 2 ? 1 : dir == 8 ? -1 : 0)
event_id = $game_map.check_event(newx, newy)
# Check if there is an event and get the map id
if event_id == nil
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
map_id = $game_map.map_id
# Set the value of self switch D of that event to true (ON)
key = [map_id, event_id, "D"]
$game_self_switches[key] = true
# Store the selected item in the global variable $field_item
$field_item = @item_window.item
# Refresh the map to reflect any changes
$game_map.need_refresh = true
end
end
I hope this is the right place for this (and not the RGSS support forum)
Anyway if someone could do it I'd be a happy panda.