Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> Event wrapper
Tsukihime
post Jul 10 2012, 09:07 PM
Post #1


Level 25
Group Icon

Group: Revolutionary
Posts: 560
Type: None
RM Skill: Undisclosed
Rev Points: 25




Thought I'd drop this here as well in case anyone's interested. I won't be updating this thread though. Progress updates will be reflected in the script since it's in my dropbox, but most of the discussion will take place over at rpgmakerwebs.

Event Wrapper
-Tsukihime

This is an early release because I haven't completed a few key features (control variables, conditional branches), but I'm looking for testers to comment on the general usage of the script. About 70% of the event editor commands have been implemented (the rest are changing actor and enemy parameters which isn't too important)

Overview

This script provides a wrapper for the RPG::Event object. It adds additional methods to allow you to create event commands directly without having to go through the event editor, and provides intuitive names that are based on the command names available on the event editor.

This is mainly a scripting tool, and is not intended to replace the event editor.
If something can be achieved using the event editor, use it.

Features
  • Easily create events using scripts
  • An Event Builder that helps you create your list of command events
  • Use the Event Builder to mix scripting with event commands to create all sorts of event processing


Downloads

Script: http://db.tt/QiaEiAN2
Demo: http://db.tt/TavscwIB

If you are not sure where to start, I've provided some examples in the demo.

Usage

Currently, your scripted events are just scripts, so they are not very accessible. You must have an event on the map to be able to use a script call to create more events, though after that your custom events can create their own events provided that you've written the logic into their command list.

You can choose to write methods in Game_Interpreter or just a custom module. As long as you can call the methods that will create the event.

CODE
class Game_Interpreter

   def make_my_event
      # your event building code
   end
end




Creating an event is simple.

1. Instantiate an Event object, passing in x,y coordinates

CODE
event = Event.new(2, 4)


2. Set some page properties. For a list of properties, refer to the help manual, or look through the Event class. You can either access the properties directly, or use some convenience methods defined in the Event class. So for example, assuming we are on page 0,

CODE
event.page[0].character_name = "actor1"
event.character_name = "actor1"


Both do the same thing. Note that the convenience methods always operate on the "current" page. When you first initialize a new event, the "current" page is 0. You can change the page by calling

CODE
event.set_page(n)


For some integer n

3. Set some page conditions. Refer to the Event_Condition class for details.

CODE
event.condition.switch1_id = 2   # this means switch 2 must be ON
event.condition.actor_id = 4     # actor 4 must be in party


4. Add the event to the map

CODE
$game_map.add_event(event)


That should create an event on the map at the designated x,y coords when we make a script call to create this event, but it's not very useful. We want to add some event commands.

I've provided an "Event Builder" that allows you to use a custom syntax to create your events in addition to regular ruby syntax.

I have written a set of methods that essentially alias Game_Interpreter methods, except instead of using command codes, I use the common editor names to identify what the command is. All of the methods are available in the EventCommands class. So for example, let's write an event that will display a simple message

CODE
event = Event.new(3, 3)
event.character_name = "actor1"
event.character_index = 2
event.build {
  show_text("actor1", 2)
  add_message("Hello World")
}
$game_map.add_event(event)


When you create this event, you can talk to it and it will say "Hello World"



The event builder supports branching, which is used in various commands such as showing a list of choices, conditional branching, and other things.

CODE
event.build {
   show_text("actor1", 1)
   add_message("What do you like?")
   show_choices(["Health", "Mana"], 0)
   choice_branch(0) {
      show_text("actor1", 1)
      add_message("So you prefer health")
   }
   choice_branch(1) {
      show_text("actor1", 1)
      add_message("Mana is ok too")
   }
}


This example demonstrates how to using branching to create a list of choices that the player can select from, and how to define the commands that should be executed depending on the choice.

Naturally, you can provide an unlimited number of branches, though the choice window is not designed for that.



It is also possible to use typical ruby syntax when building your commands.
You know, take advantage of loops and variables.

CODE
event = Event.new(x, y)
event.character_name = "actor2"
event.character_index = 5

event.build {
  show_text("actor2", 5)
  add_message("Which party member do you wish to view?")
  actors = $game_party.members.collect {|actor| actor.name }
  show_choices(actors, 0)

  $game_party.members.each_with_index { |actor, i|
    choice_branch(i) {
      show_text(actor.face_name, actor.face_index)
      add_message("%s is a level %d %s" %[actor.name, actor.level, actor.class.name])
    }
  }
}
$game_map.add_event(event)


This example demonstrates how you would write an event that will go through all of the actors in your party, display their names in a choice list, and then when you select an actor, it will display information about the actor in a text box.





However, note that because this code is run only when the event is created, the event commands have already been hardcoded into the event. It is no different from manually creating an event and writing your own choice branches and such.

One of the goals of this script is to eventually allow you to create completely dynamic events whose commands may change at any time.

I am currently working on a way for you to specify that an event should be "rebuilt" everytime you enter the map, or your refresh the event. By rebuilding the event, you are basically clearing out the command list and re-running the script, which will correctly reflect the current state of the game.

This post has been edited by Tsukihime: Jul 10 2012, 09:15 PM


__________________________
My Scripts
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: 20th May 2013 - 10:40 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker