Create a new event with the script editor

● ARCHIVED · READ-ONLY
Started by bker9680 19 posts View original ↗
  1. Hello, I'm wondering if it's possible to create an event from scratch using the script editor?
  2. Possible, yes, but very hard. I'd use the editor instead. But if you really want to do it...

    I've moved this thread to Learning Ruby and RGSSx. Thank you.

  3. Possible. You've gotta read the reference in help file. Starting from RPG::Event.
    It contains basic data need to fill like name, id, coordinate xy, and pages

    For pages, the reference is class
    Code:
    RPG::Event::page
    Within this class, you define the graphic, walk anim, step anim, etc manually.
    Your question is too broad. I'd suggest you to read help file instead or try to mess up with editor created events.
  4. As much as its doable, its hard to do especially if you want a fully working event.

    So first let me ask why do you want to do it? What's the end goal?

    Depending on what you want to achieve, there might be simpler ways of doing it than trying to create events from scratch.
  5. As said before, people usually create the events in the editor and at maximum use a script to copy those events if dynamic events are really needed.
    Tsukihime wrote a wrapper script to make dynamic creation of events a bit simpler, but absolutely no one used it because it is much simpler to clone or copy events (there are several scripts for that available for Ace).
  6. Creating events from scratch is not that hard. The issue is rather that it is extremely tedious to do so. Each event contains quite a lot of information and many objects, which is true even for “simple” blank events.
    If you are creating a script where you want to generate events I recommend you focus on copying editor created events, or use editor created events as a seed. One reason is given by Ander. It is simply easier and faster to copy the data of an editor created event and then edit that data than it is to create the data form scratch. Another reason is that for many event settings using the editor is easier and nicer for configuration purposes. Having a hybrid solution with some config done in the editor event itself and some in the script editor can be nice to.
    Having to configure everything in the script editor is super tedious. You can actually see the graphics you select in the editor, you cannot do that in the script editor.

    Good luck with whatever you are trying to accomplish.

    *hugs*
    - Zeriab
  7. Thanks for the replies everyone. I'm doing this to display blood on the ground for a simple custom battle system. Each enemy will take 3 hits to kill and there will be a drop of blood on the ground every time they are hit. So for each enemy, I need to have 3 blank events just sitting on the map waiting to be moved to the correct location and change the graphic. I thought it would be more practical to just create the events as I need them instead of just having a bunch of events sitting on the map that may or may not be used depending on how many enemies I kill.

    I made a class that creates an instance of the RPG::Event module but nothing shows up on the map when I call it.

    Code:
    class New_Event
      def initialize
    # ========================== RPG::Event ========================================
        @event = RPG::Event.new(9,6)
        @event.name = "Blood"
        @event.id = 99
    # ====================== RPG::Event::Page ======================================
        @rpg_event_page = RPG::Event::Page.new
        @rpg_event_page.through = true
        @rpg_event_page.graphic = @rpg_event_page_graphic
        @event.pages = @rpg_event_page
    # ================== RPG::Event::Page::Graphic =================================
        @rpg_event_page_graphic = RPG::Event::Page::Graphic.new
        @rpg_event_page_graphic.tile_id = 393 # blood graphic on tileset
        @rpg_event_page.graphic = @rpg_event_page_graphic
        def event
          return @event
        end
      end
    end
  8. I recommend creating a special event template map and creating your blood events there.
    Search for some of the scripts that allows copying of events out there. They'll show both how to copy and the glue that's necessary to actually make the events show up on the map.
  9. Zeriab said:
    I recommend creating a special event template map and creating your blood events there.
    Search for some of the scripts that allows copying of events out there. They'll show both how to copy and the glue that's necessary to actually make the events show up on the map.

    Thanks, I will do that.

    UPDATE

    I found a script that does more or less exactly what I want it to do called event spawn for xp that allows me copy events. Thank you again to everyone who responded, your help was very much appreciated.
  10. Okay so that script that copies events is fine for drawing blood to the screen but now I need to be able to create a hit box for damaging enemies. I found a script that creates events from scratch but it's for VX and I'm using XP. I managed to change it to work in XP but there's one small little problem.

    Code:
    class Create_Event
      def initialize
    #==============================================================
    #                                            Create new instance of RPG::Event
    #==============================================================
        @rpg_event = RPG::Event.new(5,8)
        @rpg_event.x = 0                                                     
        @rpg_event.y = 0                                                     
        @rpg_event.id = 20                                                   
        @rpg_event.name = "blank event"
        @rpg_event.pages[0].graphic.character_name = "001-Fighter01"
    #==============================================================
    #                                          Create new instance of Game_Event
    #==============================================================
        @game_event = Game_Event.new($game_map.map_id,@rpg_event)
        $game_map.events[@rpg_event.id] = @game_event
        @game_event.refresh
        @viewport1 = Spriteset_Map.new.viewport1
        @sprite =
    Spriteset_Map.new.character_sprites.push(Sprite_Character.new(@viewport1,@game_event))
        return @game_event
      end
    end
    class Scene_Map
        attr_accessor :spriteset
    end
    class Spriteset_Map
      attr_accessor :character_sprites
      attr_reader :viewport1
    end

    This makes the event show up on screen, but then the screen freezes and the event disappears. I think the problem is that I can't push the instance of Spriteset_Map from this script to the instance of Spriteset_Map in Scene_Map despite providing read and write access to the @spriteset variable from Scene_Map. How do I get access to this variable from outside the class?
  11. Just give the access, like this in Scene_Map
    Code:
    attr_reader :spriteset
    And accessing it by
    Code:
    $scene.spriteset
    Might not the best solution, but hey if it works then who cares.

    EDIT: Also please don't use "Spriteset_Map.new" You're creating an unnecessary spriteset
  12. TheoAllen said:
    Just give the access, like this in Scene_Map
    Code:
    attr_reader :spriteset
    And accessing it by
    Code:
    $scene.spriteset
    Might not the best solution, but hey if it works then who cares.

    EDIT: Also please don't use "Spriteset_Map.new" You're creating an unnecessary spriteset

    Thanks for the quick reply.

    I've already provided read and write access to the spriteset variable on line 24 but I get a no method error any time I try to access it from outside the class.

    Edit

    Nevermind, you were right. I was putting $scene_map.spriteset instead of $scene.spriteset. Thanks for the help.
  13. bker9680 said:
    I've already provided read and write access to the spriteset variable on line 24 but I get a no method error any time I try to access it from outside the class.
    How do you try to access the spriteset?
    Are you using different code?
  14. I was trying to print out the contents by putting
    p $scene_map.spriteset
    instead of
    p $scene.spriteset
  15. You dont use $scene_map, but $scene
    Try again.
  16. I did and it worked like a charm.
    Thanks again for the help.

    Okay so I've got one more problem with this script that needs fixing. I can create an event that actually stays on the screen but the screen freezes for 4 seconds when I call the script.

    Code:
    class Create_Event
      def initialize
    #==============================================================
    #                     Create new instance of RPG::Event
    #==============================================================
        @rpg_event = RPG::Event.new(5,8)
        @rpg_event.x = 0                                                     
        @rpg_event.y = 0                                                     
        @rpg_event.id = 20                                                   
        @rpg_event.name = "blank event"
        @rpg_event.pages[0].graphic.character_name = "001-Fighter01"
    #==============================================================
    #                      Create new instance of Game_Event
    #==============================================================
        @game_event = Game_Event.new($game_map.map_id,@rpg_event)
        $game_map.events[@rpg_event.id] = @game_event
        @game_event.refresh
        @viewport1 = Spriteset_Map.new.viewport1
        @sprite = Sprite_Character.new(@viewport1,@game_event)
        $scene.spriteset.character_sprites.push(@sprite)
        return @game_event
      end
    end
    class Scene_Map
        attr_accessor :spriteset
    end
    class Spriteset_Map
      attr_accessor :character_sprites
      attr_reader :viewport1
    end

    So how do I stop the screen from freezing when I run this script?
  17. You don't do "class Create_Event"
    Throw the method on Game_Map where the @events are located

    And again, don't create unnecessary Spriteset_Map.new.
    If you want to get viewport1, use $scene.spriteset
  18. TheoAllen said:
    You don't do "class Create_Event"
    Throw the method on Game_Map where the @events are located

    And again, don't create unnecessary Spriteset_Map.new.
    If you want to get viewport1, use $scene.spriteset

    Thanks a million TheoAllen. You've been a great help to me getting this script working the way I want it to. Everything's working the way it should now. Mods, you can close this thread now.
  19. Hey, it's been 6 years already, so time to dig up the topic
    :ptea:
    I had some success with creating these events from script, maybe someone will still use or upgrade it.
    Here, have a look.

    To spawn a new event, just call the function `ekipa` from the map
    ekipa.png


    class Scene_Map attr_accessor :spriteset end class Interpreter def ekipa #============================================================== # Create new instance of RPG::Event #============================================================== if $new_id == nil; $new_id = 500; end @rpg_event = RPG::Event.new(5,8) @rpg_event.x = 3 @rpg_event.y = 3 @rpg_event.id = $new_id @rpg_event.name = "Critter_#{$new_id.to_s}" @rpg_event.pages[0].move_type = 2 @rpg_event.pages[0].always_on_top = false @rpg_event.pages[0].through = false @rpg_event.pages[0].graphic.tile_id = 0 @rpg_event.pages[0].graphic.character_name = "018-Thief03" @rpg_event.pages[0].graphic.character_hue = 0 @rpg_event.pages[0].graphic.direction = 2 @rpg_event.pages[0].graphic.pattern = 0 @rpg_event.pages[0].graphic.opacity = 255 @rpg_event.pages[0].graphic.blend_type = 0 #============================================================== # Adding positions to "Lift of Event Commands #============================================================== @rpg_event.pages[0].list.unshift(RPG::EventCommand.new(108, 0, ["Comment"])) @rpg_event.pages[0].list.unshift(RPG::EventCommand.new(101, 0, ["Working Message"])) @rpg_event.pages[0].list.unshift(RPG::EventCommand.new(0, 0, [])) # #¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ $new_id += 1 #============================================================== # Create new instance of Game_Event #============================================================== @game_event = Game_Event.new($game_map.map_id,@rpg_event) $game_map.events[@rpg_event.id] = @game_event @game_event.refresh #@viewport1 = Spriteset_Map.new.viewport1 @sprite = Sprite_Character.new(@viewport1,@game_event) $scene.spriteset.character_sprites.push(@sprite) return @game_event end def ekipa_reset $new_id = 500 end end class Spriteset_Map attr_accessor :character_sprites attr_reader :viewport1 end

    Obviously there is a lot of space for improvement, so if I'll ever decide to upgrade it I'll post a new version again.