Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

> 


———
Before you ask! Read! ;)

You must have 30+ Posts to create a topic here!

Thanks for reading!
———

 
Reply to this topicStart new topic
> Events that are clones of other events, Can one event inherit all properties and pages of another?
LockeZ
post Feb 26 2012, 04:27 PM
Post #1


Level 9
Group Icon

Group: Revolutionary
Posts: 141
Type: Developer
RM Skill: Masterful




So here's this crate. It's destroyable with the bombs, the laser cannon, and the flamethrower. It's a five page event. There are about a billion such identical crates throughout my game.

I'm going to add more tools later that will also interact with crates. I would really like to not have to go back and edit all billion crates when I do that. Not to mention all the other types of objects besides crates that are repeated throughout the game.

So what I want is to be able to make one event inherit all properties and pages of another event. From another map, ideally, so that I can just have one junk map full of all the source events, but if the source event has to be on the same map that's still a huge improvement.

Thanks in advance.


__________________________
Go to the top of the page
 
+Quote Post
   
Night_Runner
post Feb 27 2012, 02:01 AM
Post #2


Level 50
Group Icon

Group: +Gold Member
Posts: 1,525
Type: Scripter
RM Skill: Undisclosed




This seems to do the trick happy.gif

CODE
#==============================================================================
# ** XP: Night_Runner's Cloning Event's Script.
#------------------------------------------------------------------------------
# History:
#  Date Created: 27/Feb/2012
#  Created for: LockeZ
#   @> http://www.rpgrevolution.com/forums/index.php?showtopic=55553
#
# Description:
#  This script allows a developer to copy an event's pages to another event.
#
# How to Install:
#  Copy this entire script. In your game editor select Tools >> Script
#  Editor. Along the left hand side scroll to the bottom, right click on
#  'Main' and select 'Insert'. Past on the right.
#
# How to Use:
#  Create the parent event which you want to get the data from.
#  Create a child event whilch gets the data. For the child event, have the
#   only command be a comment which reads:
#        CopyEvent(1, 12)
#   where 1 is the map ID of the parent event, and 12 is the event ID of
#   the parent event.
#==============================================================================



#==============================================================================
# ** Game_Event
#------------------------------------------------------------------------------
#  Edited to allow leading of another events' pages.
#==============================================================================

class Game_Event
  #--------------------------------------------------------------------------
  # * Alias Methods
  #--------------------------------------------------------------------------
  alias nr_inheriting_events_initialize  initialize  unless $@
  #--------------------------------------------------------------------------
  # * Classwide Variables
  #--------------------------------------------------------------------------
  @@source_event_maps = []
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(*args)
    # Run the original initialize
    nr_inheriting_events_initialize(*args)
    # If this event has a valid page opened
    if (not @erased) and (not @page.nil?)
      # If there is only 1 command, and it's a comment
      if (@page.list.size == 2) and (@page.list[0].code == 108)
        command = @page.list[0]
        # Check if it's of the correct formatting
        if command.parameters[0].gsub(' ', '') =~ /CopyEvent\((\d+)\,(\d+)\)/i
          # Get the map and event ID
          map_id = $1.to_i
          event_id =  $2.to_i
          # Check if the map has already been loaded
          if @@source_event_maps[map_id] != nil
            map = @@source_event_maps[map_id]
          else
            map = load_data(sprintf("Data/Map%03d.rxdata", map_id))
            @@source_event_maps[map_id] = map
          end
          event = map.events[event_id]
          # Load the event's pages
          @event.pages = event.pages
          # Refresh
          refresh
        end
      end
    end
  end
end



#==============================================================================
# ** End of Script.
#==============================================================================


Let me know if you find any problems!


__________________________
K.I.S.S.
Want help with your scripting problems? Upload a demo! Or at the very least; provide links to the scripts in question.

Most important guide ever: Newbie's Guide to Switches
Go to the top of the page
 
+Quote Post
   
LockeZ
post Feb 28 2012, 03:39 AM
Post #3


Level 9
Group Icon

Group: Revolutionary
Posts: 141
Type: Developer
RM Skill: Masterful




You are the BOSS. Thanks!


__________________________
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 24th May 2013 - 08:52 AM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker