RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
[VXA] Call Scene from Items & Skills

0 Members and 1 Guest are viewing this topic.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
Call Scene from Items & Skills
Version: 1.0
Author: modern algebra
Date: February 5, 2012

Version History


  • <Version 1.0> 2012.02.05 - Original Release

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

  • Allows you to directly call scenes from using an item or skill in the Item or Skill menu
  • When you exit the scene, it will take you back to the item or skill scene from which it was called

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
  • \scene[Scene_Debug]
        When used, the item would call the Debug Scene.
  • \scene[Scene_MonsterCatalogue]
        If you are using my Monster Catalogue, it would open that scene.
  • \scene[Scene_StateView]
        If you are using my State Viewer script, it would open that scene.

Script


Code: [Select]
#==============================================================================
#    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


  • modern algebra

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.
« Last Edit: January 31, 2013, 09:49:12 PM by modern algebra »

*
*crack*
Rep:
Level 64
2012 Best Newbie2012 Most Unsung MemberFor frequently finding and reporting spam and spam bots
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
All of my scripts are totally free to use for commercial use. You don't need to ask me for permission. I'm too lazy to update every single script post I ever made with this addendum. So ignore whatever "rule" I posted there. :)

All scripts can be found at: https://pastebin.com/u/diamondandplatinum3

**
Rep:
Level 72
RMRK Junior
Aha, so you made it. Great. As soon as I get some time, I'll give it a try.

**
Rep: +0/-0Level 74
RMRK Junior
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/ This is bubble's script.
Thanks

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
No, it's not possible to pass an argument like that in this script.

**
Rep: +0/-0Level 74
RMRK Junior
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.