Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

SephirothSpawn's Event_Spawner Quick Tutorial

The Event_Spawner... very useful tool, can be tricky especially for a non-scripter to get into (I'm hoping you've read the instructions Seph left for you in the script's comments). I've actually started getting good use out of it, I have created a vehicle system with it which works nicely, I'd like to see more people use it.

Step 1 : Installing the Event_Spawner

First thing you want to do, if you haven't got this far, is install the Event_Spawner. There is at least one script from the MACL that I believe this system depends on, and that is RGSS.Map. It has methods such as .add_character/event, .delete_character/event, etc. Place RGSS.Map in your script editor, THEN place Modules.Event_Spawner somewhere below it (try to be organized)

As example, here is a visual reference of how the order should look...

Scene_Debug
-----------------------
SDK (if using)
-----------------------
RGSS.Map
Modules.Event_Spawner
-----------------------
(other scripts here...)
-----------------------
main

There might be other MACL requirements, but I believe that is all you need is those two scripts and you're good to go.

Step 2 : Creating a brand new event

Okay, creating events via call script is a pain in the ass (due to the size restraints of the Call Script box), so you're going to turn into a scripter for a second... Insert a new blank script somewhere appropriate below the Event_Spawner, this page will be deticated to whatever kind of Events you want to create.

Now, in this new BLANK page in our script editor, we're going to open the Event_Spawner module again and begin *scripting* our new event that we want to be able to create on the fly.

Code:
module Event_Spawner

  #...we'll be adding the method in a second

end

Cool, now we're ready... what kind of event shall we start off with?

Part 3 : Creating an Event (Example)

Okay, you've finished the last step in Part 2 and reopened the Event_Spawner module in a new page in our Script Editor, what next? Lets make our first EVENT! In this example, I'm going to create a very generic event. If you know nothing about scripting, this could actually be a good practice for you on learning basic Object Oriented principals (or at least how to use methods/arguments).

Remember how Seph showed you to create your basic, do-nothing (yet) event? Well, we're going to write a method into the actual Event_Spawner module to create an event...

Code:
module Event_Spawner

  def self.my_event(x, y)

    create_event(x, y, "My Event")

    end_event

  end

end

Note how def self.my_event(x, y), again you're using X, Y as the arguments? This is still used to determine the X/Y coords the event will spawn. We can mix this up a little bit and randomize the spot the event will appear each time, but I'll show you that later if I have time. BUT lets give this event a graphic first, and make it talk... we're gonna further modify the method just written.

Code:
module Event_Spawner

  def self.my_event(x, y)

    create_event(x, y, "My Event")

    set_page_graphic({'c_name' => "001-Fighter01")

    add_event_command(101, ["Hello, my name is Aluxes, nice to", "meet you..."])

    end_event

  end

end

Notice how on this line...

add_event_command(101, ["Hello, my name is Aluxes, nice to", "meet you..."])

...The text is written INSIDE an array (inside a []) using a string then we use a comma (,) to seperate the message into two strings? This means that the second string will be used in the second line of the text box. The very first argument is 101, which the Interpreter recognizes as the Show Text event command, the second argument is an Array (container) with 2 Strings (text). You can look at Interpreter 2 to see how the commands are all organized by numeric code, but you're just as well off just reading the instructions of the Event_Spawner to see what these numeric codes are for each event command, and how to call them through script.

Bug when deleting events (and solution)

Obviously, with a system like this, you'll be needing to delete events if you spawn alot on certain maps... this is easy enough, just use $game_map.delete_event(event_id). Lastly, you'll want to put this snippet into you RGSS.Map section where it would be most appropriate...

Code:
#===============================================================================

# ** Interpreter

#===============================================================================

 

class Interpreter

  #-----------------------------------------------------------------------------

  # * Alias Listings

  #-----------------------------------------------------------------------------

  alias_method :macl_interpreter_commandend,     :command_end

  #-----------------------------------------------------------------------------

  # * End Event

  #-----------------------------------------------------------------------------

  def command_end

    if $game_map.is_a?(Game_Map) && $game_map.events.is_a?(Array)

      if $game_map.events.include?(@event_id)

        macl_interpreter_commandend

        return

      end

    end

    @list = nil

  end

end

Conclusion

The Event_Spawner module could be a very useful tool, I'd like to see more people use it! Not that you have to, but I have alot of praise and respect for Seph actually taking the time to put it together, and its useful for events that you can place on any map. If anybody wants, I'll make a sample script using the Event_Spawner and you can actually see how I use it.

For best results, try creating an actual event that works like you want it to (one that you want to spawn on any map without worrying about making 'pre-mades'), then slowly start 'coding' out the event line for line in the Event_Spawner module.

If there is any further questions about SephirothSpawn's Event_Spawner module, I'll be glad to help you out. Really, all you should need now are the basic instructions written within the script header since I've already shown you a hands-on approach of how a scripter would use it. I hope I've helped you rather than confuse you...

Happy Scripting ! :thumb:
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top