Group: +Gold Member
Posts: 1,199
Type: Scripter
RM Skill: Undisclosed
Menu Common Event by: Night5h4d3 v5.0
Introduction:
This was a request of JoRu, and I figured I ought to add it to the the scripts (his topic here) This script basically allows you to run a common event from the menu (using the command window) it supports these features:
Features:
run a common event from the menu
display messages, choices, etc
Modify player stats such as gold, HP, etc
Modify variables, switches
Call shop processing
You can now process player transfers
Deleting commands from the array is now easier (see FAQ)
NEW!!! Infinite commands in menu! now you can use way more than just 4!
NEW!!! Adding commands is now automated!! (see FAQ)
NEW!!! You can now call a name change!
NEW!!! The 'gameover' command is now added, so you can have your player 'suicide,' great for death-note fan-games XP
Script:
V5.0 here!
CODE
#============================================================================== # ** Menu Call Common Event (NS_CE) # by Night5h4d3 # v 5.0 #============================================================================== module NS_CE # An array of the text that will appear in the menu selection EVENT_NAME = ["Some Text"] # An array of the common events to run EVENT_NUM = [1] # These appear at game start, so if you dont want event options available at # the start of the game, then just remove the items.
#----------------------------------------------------------+ # DO NOT TOUCH BELOW UNLESS YOU REALLY KNOW WHAT YOUR DOING| #----------------------------------------------------------+ def self.delete_byname(name) EVENT_NAME.compact! EVENT_NUM.compact! for i in 0...EVENT_NAME.size if EVENT_NAME[i].downcase == name.downcase EVENT_NAME[i] = nil EVENT_NUM[i] = nil $scene.recreate_windows if $game_temp.from_menu == true and $game_temp.scene_now == "ME" break end end end def self.add_event(name, number, pos = -1) @name = name @number = number @pos = pos EVENT_NAME.compact! EVENT_NUM.compact! if @name or @number != nil if @pos > 0 EVENT_NAME[@pos - 1, 0] = @name EVENT_NUM[@pos - 1, 0] = @number else EVENT_NAME.push(name.to_s) EVENT_NUM.push(number) end $scene.recreate_windows if $game_temp.from_menu == true and $game_temp.scene_now == "ME" end end end #============================================================================== # ** Game_Temp #------------------------------------------------------------------------------ # This class handles temporary data that is not included with save data. # The instance of this class is referenced by $game_temp. #============================================================================== class Game_Temp attr_accessor :from_menu attr_accessor :scene_now alias :initialize_new2 :initialize def initialize initialize_new2 @from_menu = false @scene_now = nil end end #============================================================================== # ** Game_Interpreter #------------------------------------------------------------------------------ # An interpreter for executing event commands. This class is used within the # Game_Map, Game_Troop, and Game_Event classes. #============================================================================== class Game_Interpreter attr_accessor :list alias :initialize_new :initialize def initialize(depth = 0, main = false) @list = nil initialize_new end #-------------------------------------------------------------------------- # * Transfer Player #-------------------------------------------------------------------------- def command_201 return true if $game_temp.in_battle if $game_player.transfer? or # Transferring Player $game_message.visible # Displaying a message return false end if @params[0] == 0 # Direct designation map_id = @params[1] x = @params[2] y = @params[3] direction = @params[4] else # Designation with variables map_id = $game_variables[@params[1]] x = $game_variables[@params[2]] y = $game_variables[@params[3]] direction = @params[4] end $game_player.reserve_transfer(map_id, x, y, direction) @index += 1 return false if $game_temp.from_menu == true $game_player.set_direction(direction) if $game_map.map_id != map_id $game_map.setup(map_id) end $game_player.moveto(x, y) end end #-------------------------------------------------------------------------- # * Shop Processing #-------------------------------------------------------------------------- alias :command_302_new :command_302 def command_302 command_302_new if $game_temp.from_menu == true $scene = Scene_Shop.new end end #-------------------------------------------------------------------------- # * Shop Processing #-------------------------------------------------------------------------- alias :command_303_new :command_303 def command_303 command_303_new if $game_temp.from_menu == true $scene = Scene_Name.new end end #-------------------------------------------------------------------------- # * Game Over #-------------------------------------------------------------------------- alias :command_353_new :command_353 def command_353 command_353_new if $game_temp.from_menu == true $game_temp.next_scene = nil $scene = Scene_Gameover.new end end end #============================================================================== # ** Scene_Map #------------------------------------------------------------------------------ # This class performs the map screen processing. #============================================================================== class Scene_Map < Scene_Base def initialize $game_temp.from_menu = false $game_temp.scene_now = "MA" end end #============================================================================== # ** Scene_Menu #------------------------------------------------------------------------------ # This class performs the menu screen processing. #============================================================================== class Scene_Menu < Scene_Base #-------------------------------------------------------------------------- # * Object Initialization # menu_index : command cursor's initial position #-------------------------------------------------------------------------- def initialize(menu_index = 0) @menu_index = menu_index NS_CE::EVENT_NAME.compact! NS_CE::EVENT_NUM.compact! $game_temp.from_menu = true $game_temp.scene_now = "ME" $pause_interpreter = !$game_temp.from_menu end #-------------------------------------------------------------------------- # * Start processing #-------------------------------------------------------------------------- def start super create_menu_background create_command_window @command_window.active = false @message_window = Window_Message.new @gold_window = Window_Gold.new(0, 360) @status_window = Window_MenuStatus.new(160, 0) end #-------------------------------------------------------------------------- # * Termination Processing #-------------------------------------------------------------------------- def terminate super @message_window.dispose dispose_menu_background @command_window.dispose @gold_window.dispose @status_window.dispose end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update super update_menu_background @message_window.update @command_window.update @gold_window.update @status_window.update if @command_window.active update_command_selection elsif @status_window.active update_actor_selection elsif !@command_window.active and $game_map.interpreter.list == nil recreate_windows elsif $game_map.interpreter.running? @command_window.active = false end $pause_interpreter = !$game_temp.from_menu unless $pause_interpreter $game_map.interpreter.update end end #-------------------------------------------------------------------------- # * Create Command Window #-------------------------------------------------------------------------- def create_command_window s1 = Vocab::item s2 = Vocab::skill s3 = Vocab::equip s4 = Vocab::status s5 = Vocab::save s6 = Vocab::game_end @command_array = [s1, s2, s3, s4, s5, s6] if NS_CE::EVENT_NAME.size > 0 @command_window = Window_Command.new(160, @command_array + NS_CE::EVENT_NAME) else @command_window = Window_Command.new(160, @command_array) end @command_window.index = @menu_index if $game_party.members.size == 0 # If number of party members is 0 @command_window.draw_item(0, false) # Disable item @command_window.draw_item(1, false) # Disable skill @command_window.draw_item(2, false) # Disable equipment @command_window.draw_item(3, false) # Disable status end if $game_system.save_disabled # If save is forbidden @command_window.draw_item(4, false) # Disable save end end #-------------------------------------------------------------------------- # * Recreate Windows #-------------------------------------------------------------------------- def recreate_windows @old_size = NS_CE::EVENT_NAME.size NS_CE::EVENT_NAME.compact! if NS_CE::EVENT_NAME.include?(nil) NS_CE::EVENT_NUM.compact! if NS_CE::EVENT_NUM.include?(nil) @gold_window.refresh @status_window.refresh @old_index = @command_window.index @command_window.dispose create_command_window unless @old_size == NS_CE::EVENT_NAME.size @command_window.index = @old_index - 1 else @command_window.index = @old_index end end #-------------------------------------------------------------------------- # * Update Command Selection #-------------------------------------------------------------------------- def update_command_selection if Input.trigger?(Input::B) Sound.play_cancel $scene = Scene_Map.new elsif Input.trigger?(Input::C) if $game_party.members.size == 0 and @command_window.index < 4 Sound.play_buzzer return elsif $game_system.save_disabled and @command_window.index == 4 Sound.play_buzzer return end Sound.play_decision case @command_window.index when 0 # Item $scene = Scene_Item.new when 1,2,3 # Skill, equipment, status start_actor_selection when 4 # Save $scene = Scene_File.new(true, false, false) when 5 # End Game $scene = Scene_End.new else if @command_window.index >= 6 @command_window.active = false $game_map.interpreter.setup($data_common_events[NS_CE::EVENT_NUM[@command_window.index - 6]].list, 0) end end end end #-------------------------------------------------------------------------- # * Start Actor Selection #-------------------------------------------------------------------------- def start_actor_selection @command_window.active = false @status_window.active = true if $game_party.last_actor_index < @status_window.item_max @status_window.index = $game_party.last_actor_index else @status_window.index = 0 end end #-------------------------------------------------------------------------- # * End Actor Selection #-------------------------------------------------------------------------- def end_actor_selection @command_window.active = true @status_window.active = false @status_window.index = -1 end #-------------------------------------------------------------------------- # * Update Actor Selection #-------------------------------------------------------------------------- def update_actor_selection if Input.trigger?(Input::B) Sound.play_cancel end_actor_selection elsif Input.trigger?(Input::C) $game_party.last_actor_index = @status_window.index Sound.play_decision case @command_window.index when 1 # skill $scene = Scene_Skill.new(@status_window.index) when 2 # equipment $scene = Scene_Equip.new(@status_window.index) when 3 # status $scene = Scene_Status.new(@status_window.index) end end end end #============================================================================== # ** Scene_Shop #------------------------------------------------------------------------------ # This class performs shop screen processing. #============================================================================== class Scene_Shop < Scene_Base def initialize $game_temp.next_scene = nil $game_temp.scene_now = "SH" end #-------------------------------------------------------------------------- # * Update Command Selection #-------------------------------------------------------------------------- def update_command_selection if Input.trigger?(Input::B) Sound.play_cancel if $game_temp.from_menu == true $scene = Scene_Menu.new else $scene = Scene_Map.new end elsif Input.trigger?(Input::C) case @command_window.index when 0 # buy Sound.play_decision @command_window.active = false @dummy_window.visible = false @buy_window.active = true @buy_window.visible = true @buy_window.refresh @status_window.visible = true when 1 # sell if $game_temp.shop_purchase_only Sound.play_buzzer else Sound.play_decision @command_window.active = false @dummy_window.visible = false @sell_window.active = true @sell_window.visible = true @sell_window.refresh end when 2 # Quit Sound.play_decision if $game_temp.from_menu == true $scene = Scene_Menu.new else $scene = Scene_Map.new end end end end end #============================================================================== # ** Scene_Name #------------------------------------------------------------------------------ # This class performs name input screen processing. #============================================================================== class Scene_Name < Scene_Base def initialize $game_temp.next_scene = nil $game_temp.scene_now = "NM" end #-------------------------------------------------------------------------- # * Return to Original Screen #-------------------------------------------------------------------------- def return_scene if $game_temp.from_menu == true $scene = Scene_Menu.new else $scene = Scene_Map.new end end def update super update_menu_background @edit_window.update @input_window.update if Input.repeat?(Input::B) if @edit_window.index > 0 # Not at the left edge Sound.play_cancel @edit_window.back end elsif Input.trigger?(Input::C) if @input_window.is_decision # If cursor is positioned on [OK] if @edit_window.name == "" # If name is empty @edit_window.restore_default # Return to default name if @edit_window.name == "" Sound.play_buzzer else Sound.play_decision end else @actor.name = @edit_window.name Sound.play_decision @actor.name = @edit_window.name unless @actor.name == @edit_window.name return_scene end elsif @input_window.character != "" # If text characters are not empty if @edit_window.index == @edit_window.max_char # at the right edge Sound.play_buzzer else Sound.play_decision @edit_window.add(@input_window.character) # Add text character end end end end end
Compatible with anything that isn't a CMS, or revisions to the original Scene_Menu. RGSS2 ONLY
Instructions:
Just put this where you put your other scripts, above main, under the materials section.
FAQ/Configuration:
QUOTE
Q: How do i change the text in the command window?
A: find EVENT_NAME[<number>] and change the text to what you desire
QUOTE
Q: How do i add more menu commands for more than one common event call?
A: change the values of EVENT_NAME[<number>] and EVENT_NUM[<number>] from nil to what you want them to be. To remove event calls from the menu, set them to nil
QUOTE
Q: I know what event command I want to remove, but I dont know where in the array it is, how do i remove it?
A: Well, thanks to v4.0, you can now delete event commands if you just know the name of it IE: "Teleporta" you simply add the script call "NS_CE.delete_byname("name of event")" and it will do the work for you!
QUOTE
Q: I want to add an event command, but I hate using the manual way, how do I use the automated add event?
A: it's simple, in a 'call script' type this:
CODE
NS_CE.add_event("<name to show in menu>", <common event number>)
and if you want to add it to a specific position:
CODE
NS_CE.add_event("<name to show in menu>", <common event number>, <position 1~N>)
NOTE: putting 1 as position is right after the 'end game' command, 0 or less adds to the end.
Terms and Conditions:
you cannot:
> claim as your own > not give credit > post on other sites without my permission first
you can:
> use this script > modify this script > suggest modifications to this script > distribute this script personally
Notes: Enjoy! If you'd like to use this script in a commercial game, please ask me first. Don't forget to give credit This may not work on select calls, such as call battle, call menu(uh, who'd need this one?). If you find any bugs, lemme know ASAP.
__________________________
Got 30 minutes? Then you've enough time to play this awesome game: - potentially promising project page - thanks holder
Group: Global Mod
Posts: 4,604
Type: Writer
RM Skill: Intermediate
Rev Points: 5
This is something you've just gotta love, a beautiful script made in moments nice work indeed, I've only recently got into advanced eventing but I'm sure this script will come in handy sooner or later (hopefully sooner )
__________________________
Warning!this post may contain sarcasm, please re-read it in a funny voice The old spoiler was out of control, it had to be stopped.
If you want to suggest a translation for something, PM me, and I'll take a look. I AM TRYING TO GIVE AWAY LOCKERZ.com INVITES, SO PLEASE LET ME KNOW IF YOU WANT ONE. Currently Working on 2 RPG Maker VX Projects. They are very unique, and have a different kind of style then the usual RPGs. So don't think of them as just another RPG. Did that sound rude? :D Not sure if I want them to go public yet, but we'll see how it goes. Need a script translated? Come talk to me, and I'll see what I can do.
Nice! Didn't work all that well in the beginning (you had to close down the menu yourself to actually make the game transfer you ) but that was an easy fix (call "$scene = Scene_Map.new" before transfer and it should work).
Thanks a lot once again!
__________________________
Stay tuned for more information about Fairytale. To stay updated on all my project videos, visit my YouTube page!
Group: Global Mod
Posts: 4,604
Type: Writer
RM Skill: Intermediate
Rev Points: 5
QUOTE (Sparrowsmith @ Sep 17 2009, 08:24 PM)
This is something you've just gotta love, a beautiful script made in moments nice work indeed, I've only recently got into advanced eventing but I'm sure this script will come in handy sooner or later (hopefully sooner )
The aforementioned time has come, but I am afraid I am the bringer of bad news. For my deathnote project (which you may of heard of) I need the player to be able to design killing methods. I created the common event for this (I'm actually unsure if it is the common event that is crashing actually) and attached it to my menu with your script. I did the setup right, but it just crashes.
Have I missed something? I'll send you the event if necessary
__________________________
Warning!this post may contain sarcasm, please re-read it in a funny voice The old spoiler was out of control, it had to be stopped.
Group: +Gold Member
Posts: 1,199
Type: Scripter
RM Skill: Undisclosed
yes, please send me the event, this script isnt compatible with battle-events, and doesnt work for scene changing events very well.
QUOTE
So I don't get it. This cannot be used to directly call a common event, can it.
It's best put this way, if you were to put 'X' common event into the list of common events to show. the menu (when opened) will show this:
CODE
<Original commands here> "X"
If you were to select 'X' it would run all of the event code in common event 'X.' What you do, is code event X and then add it to the commands list. I hope that helped.
__________________________
Got 30 minutes? Then you've enough time to play this awesome game: - potentially promising project page - thanks holder
Group: Member
Posts: 6
Type: Event Designer
RM Skill: Intermediate
There seems to be an issue when interacting with events. When "talking" to other events, they will face you, but after that they will not turn toward you and stay in that direction, and if they have an "autonomous movement" option turned on, they will not move. I'm sure it's this script, since I tested it in a new project without any scripts and the same problem occurred. Any help?
EDIT: Also, for an unexplained reason, Shop Processing commands always seem to skip the action that occurs right afterward. Not quite sure why this happens either on a common event script.
This post has been edited by ArcticYoshi45: Nov 7 2010, 06:12 PM
__________________________
Since I can't type cursive, I don't know what's supposed to go in my signature.