Notice: fwrite(): Write of 465 bytes failed with errno=28 No space left on device in /home/rmrk/domains/rmrk.net/public_html/Sources/Cache/APIs/FileBased.php on line 96

Notice: fwrite(): Write of 59 bytes failed with errno=28 No space left on device in /home/rmrk/domains/rmrk.net/public_html/Sources/Cache/APIs/FileBased.php on line 96

Notice: fwrite(): Write of 1714 bytes failed with errno=28 No space left on device in /home/rmrk/domains/rmrk.net/public_html/Sources/Cache/APIs/FileBased.php on line 96

Notice: fwrite(): Write of 44 bytes failed with errno=28 No space left on device in /home/rmrk/domains/rmrk.net/public_html/Sources/Cache/APIs/FileBased.php on line 96

Notice: fwrite(): Write of 8192 bytes failed with errno=28 No space left on device in /home/rmrk/domains/rmrk.net/public_html/Sources/Cache/APIs/FileBased.php on line 96
Print Page - [VXA] Call Scene from Items & Skills

The RPG Maker Resource Kit

RMRK RPG Maker Creation => VX Ace => VXA Scripts Database => Topic started by: modern algebra on February 05, 2012, 07:09:19 PM

Title: [VXA] Call Scene from Items & Skills
Post by: modern algebra on February 05, 2012, 07:09:19 PM
Call Scene from Items & Skills
Version: 1.0
Author: modern algebra
Date: February 5, 2012

Version History




Description



This script allows you to call a scene directly after using an item or skill. While it is always available simply to call a common event and call the scene from that, this script allows it to happen directly without going back to the map, so that when the scene is exited, it goes straight back to the scene that called it. In that regard, the script doesn't add functionality so much as it simply makes it smoother to call a scene from an item or skill in the menu.

Naturally, this script will not work if the item or skill also calls a common event. In that event, you can just simply call the scene out of the common event.

Please note that this script does not work in battle and is not intended to work in battle since, generally speaking, you do not want the player to be able to escape the battle by calling a scene. Besides, you can use common events in battles directly.

Features


Instructions

Paste this script into its own slot in the Script Editor, above Main but below Materials.

To have an item or skill call a scene, just place the following code into its notebox:

      \scene[Scene_Name]

Where Scene_Name is the name of the scene you want to call.

Examples

Script




#==============================================================================
#    Call Scene from Items & Skills
#    Version: 1.0
#    Author: modern algebra (rmrk.net)
#    Date: February 5, 2012
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#
#    This script allows you to call a scene directly after using an item or
#   skill. While it is always available simply to call a common event and call
#   the scene from that, this script allows it to happen directly without going
#   back to the map, so that when the scene is exited, it goes straight back to
#   the scene that called it.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#
#    Paste this script into its own slot in the Script Editor, above Main but
#   below Materials.
#
#    To have an item or skill call a scene, just place the following code into
#   its notebox:
#
#      \scene[Scene_Name]
#
#    Where Scene_Name is the name of the scene you want to call. For example,
#   if you wanted to call the Debug scene, you would put there:
#
#     \scene[Scene_Debug]
#
#    Note that this script does not work in battle. If you want to call a scene
#   from battle, do it with a common event.
#
#    Note that if you set an item to call a scene like this, then any common
#   event assigned to the item will be prevented from running (if in the menu).
#   If in battle, on the other hand, this script is inoperative and so the
#   common event will be run.
#==============================================================================

$imported ||= {}
$imported[:MA_CallSceneFromItemsAndSkills] = true

#==============================================================================
# ** RPG::UsableItem
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new method - csis_call_scene
#==============================================================================

class RPG::UsableItem
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Call Scene
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def csis_call_scene
    if !@csis_call_scene
      @csis_call_scene = false
      if self.note[/\\SCENE\[\s*(\w+)\s*\]/i]
        sym = $1.to_sym
        @csis_call_scene = sym if Kernel.const_defined?(sym)
      end
    end
    @csis_call_scene
  end
end

#==============================================================================
# ** Game_Actor
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased method - item_has_any_valid_effects?
#==============================================================================

class Game_Actor
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Item Has Any Valid Effects?
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias macsis_itmvalideffects_3kc5 item_has_any_valid_effects?
  def item_has_any_valid_effects?(user, item, *args, &block)
    result = macsis_itmvalideffects_3kc5(user, item, *args, &block)
    (result || (SceneManager.scene.is_a?(Scene_ItemBase) && item.csis_call_scene))
  end
end

#==============================================================================
# ** Scene_ItemBase
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased method - use_item_to_actors; return_scene
#    new method - csis_call_scene
#==============================================================================

class Scene_ItemBase
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Use Item to Actors
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias macsis_useitmactors_3ej5 use_item_to_actors
  def use_item_to_actors(*args, &block)
    macsis_useitmactors_3ej5(*args, &block) # Call Original Method
    csis_call_scene if item.csis_call_scene
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Return Scene
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias macsis_retrnscene_2wj6 return_scene
  def return_scene(*args, &block)
    # Restore Menu Actor
    $game_party.menu_actor = @csis_real_menu_actor if @csis_real_menu_actor
    macsis_retrnscene_2wj6(*args, &block)
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * CSM Call Scene
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def csis_call_scene
    # If item is targetted, change the menu actor in case matters for scene
    @csis_real_menu_actor = $game_party.menu_actor if !@csis_real_menu_actor
    $game_party.menu_actor = item_target_actors[0] if !item_target_actors.empty?
    $game_temp.clear_common_event # Don't call a common event.
    # Call the identified scene
    Input.update
    SceneManager.call(Kernel.const_get(item.csis_call_scene))
  end
end


Credit




Support



Please post in this topic at RMRK.net if you need any assistance at all with this script.

Known Compatibility Issues

No compatibility issues have yet been brought to my attention.
Title: Re: Call Scene from Items & Skills
Post by: D&P3 on February 05, 2012, 07:21:58 PM
Thanks Modern, I had a world map in my inventory and so with this it won't exit the item menu.

Delivering as always, Modern  ;D
Title: Re: Call Scene from Items & Skills
Post by: Seiryuki on February 05, 2012, 11:25:47 PM
Aha, so you made it. Great. As soon as I get some time, I'll give it a try.
Title: Re: [VXA] Call Scene from Items & Skills
Post by: pinkapinkie on February 09, 2013, 07:16:36 AM
Is it possible to call the crafting scene with bubble's script, when it specifies the category of the item you want to craft? For example, I have a recipebook that has category "armors", now, with bubble's script, you can specify the scene to show up only the recipes with the armors category.
When I try to specify this in the skill's notebox i get an error.
http://mrbubblewand.wordpress.com/rgss3/tactics-ogre-psp-crafting-system/ (http://mrbubblewand.wordpress.com/rgss3/tactics-ogre-psp-crafting-system/) This is bubble's script.
Thanks
Title: Re: [VXA] Call Scene from Items & Skills
Post by: modern algebra on February 09, 2013, 11:31:51 AM
No, it's not possible to pass an argument like that in this script.
Title: Re: [VXA] Call Scene from Items & Skills
Post by: estriole on February 14, 2013, 08:17:28 AM
you could add notetags <scene_prepare: x, y, z>
grab them. and do the scenemanager.scene.prepare(x,y,z) ONLY if the note exist.
i do that technique in one of the script i'm making.