Help - Search - Members - Calendar
Full Version: Create Map event manually
RPG RPG Revolution Forums > Scripting > Script Development and Support > Script Requests
cometstar
I want a script to call it to create an even t manually ,which is copied from another mapevent with its command events and give it new graphic or change its ghraphic manually, too
Is this possible ?
Jens of Zanicuud
QUOTE (cometstar @ Dec 15 2011, 12:06 AM) *
I want a script to call it to create an even t manually ,which is copied from another mapevent with its command events and give it new graphic or change its ghraphic manually, too
Is this possible ?


Hello Cometstar,
I think it's possible, try this script...

CODE
class Game_Event
  attr_accessor :character_name
  attr_accessor :character_hue
end

class Spriteset_Map
  def add_event(id)
    sprite = Sprite_Character.new(@viewport1, $game_map.events[id])
    @character_sprites.push(sprite)
  end
end

class Scene_Map
  attr_reader :spriteset
end

class Game_Map
  def copy_event(id,x,y,char_name=nil,char_hue=nil)
    if $game_map.events[id] == nil
      return -1
    end
    event = $game_map.events[id].clone
    event.moveto(x,y)
    if char_name != nil
    event.character_name = char_name
    end
    if char_hue != nil
    event.character_hue  = char_hue
    end
    index = $game_map.events.keys.size
    $game_map.events[index+1] = event
    if $scene.is_a?(Scene_Map)
      $scene.spriteset.add_event(index+1)
    end
    return true
  end
end


Call it from script writing
CODE
$game_map.copy_event(id,x,y,char_name,char_hue)

where:
-id is the id of the event you want to copy;
-x and y are the new coordinates;
-char_name and char_hue are what their name say and can be left blank.

For example,

$game_map.copy_event(1,5,7)

creates a copy of Event #1 and places it into coordinates (5,7).

I've not made a complete debug yet, please report any bugs...

N.B. It works ONLY in Scene_Map and in this state doesn't save the new event. If you exit the game and resume it again, the new event will disappear...

####
EDIT: actually, you can use this script anywhere, but once you leave the map, events will be reset...
It seems working quite well, although...
Please, let me know if it works...
###

Jens
cometstar
Thank you for this replay
it is very good, and it's exactly what I want, but I need also to change graphic of the event and specify a new graphic
I'll try it later....
Thank you
Jens of Zanicuud
QUOTE (cometstar @ Dec 18 2011, 10:40 PM) *
Thank you for this replay
it is very good, and it's exactly what I want, but I need also to change graphic of the event and specify a new graphic
I'll try it later....
Thank you


Actually the script allows you to change graphics...
Just set the new character name and character hue in the arguments...
Maybe I wrote it in wrong words...
I meant this...

CODE
$game_map.copy_event(id,x,y,new_char_name,new_char_hue)


Jens
cometstar
Thank you much.....
Your job is perfect, and it's exactly what I need for my project.
thanks for this briliant site in RPG Maker's world
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.