http://forums.rpgmakerweb.com/index.php?/topic/3148-event-wrapper/
Spoiler

Demo: http://db.tt/ZBuWIe8f
Instructions: Talk to fairy
Overview
This script is called an "Event Wrapper", which is appropriate because it provides methods that allow you to dynamically create events using script calls.
Currently it supports roughly only 25% of what the event editor can actually do. Things I haven't implemented include branching, move routes, and actor/enemy related commands.
Branching includes loops, choice selection, conditional branching, and basically anything where the indent is not 0.
When this script is completed, not only would you be able to create events easily using a standard set of method calls, but you can also have support for
-unlimited, arbitrary page conditions (including custom page conditions)
-unlimited choice options (not just 4), because you have full control over the branching logic
-unlimited pages
-unlimited self-switches without having to use odd script calls
This script is not a replacement for the event editor.
If you can do something with the event editor, use it.
However, there are many cases where the event editor simply cannot help you, especially when it comes to dynamic content that may be generated during the game. Examples include custom actors that are created in-game, or items that are dropped onto the map that may be picked up later.
A sample script that allows you to create a battle event:
Here, all I needed to do was say tell it to add a command that calls a battle with troop ID 1, which is a slime. I also set the character name and index to the slime character, and then just added it to the game map.
I've put together a demo to show various functions in action:
I will have to re-design certain parts of the script. In particular
1. conditions should be accessed through Event.condition, to make it more flexible and clear
2. Maybe a better way to handle branching should be considered. This is what I have planned so far:
Basically, if you want to branch, you must make it clear that you're starting a branch, and the script will do all of the indenting and set-up for you.
Similarly, to close a branch, you must say "end_branch" because you must decrease the indent by 1, and also insert an empty command to tell the interprer that the branch is finished.

Demo: http://db.tt/ZBuWIe8f
Instructions: Talk to fairy
Overview
This script is called an "Event Wrapper", which is appropriate because it provides methods that allow you to dynamically create events using script calls.
Currently it supports roughly only 25% of what the event editor can actually do. Things I haven't implemented include branching, move routes, and actor/enemy related commands.
Branching includes loops, choice selection, conditional branching, and basically anything where the indent is not 0.
When this script is completed, not only would you be able to create events easily using a standard set of method calls, but you can also have support for
-unlimited, arbitrary page conditions (including custom page conditions)
-unlimited choice options (not just 4), because you have full control over the branching logic
-unlimited pages
-unlimited self-switches without having to use odd script calls
This script is not a replacement for the event editor.
If you can do something with the event editor, use it.
However, there are many cases where the event editor simply cannot help you, especially when it comes to dynamic content that may be generated during the game. Examples include custom actors that are created in-game, or items that are dropped onto the map that may be picked up later.
A sample script that allows you to create a battle event:
def make_battle_event(x, y) event = Event.new(x, y) event.character_name = "monster2" event.character_index = 2 event.call_battle(1) $game_map.add_event(event) end
Here, all I needed to do was say tell it to add a command that calls a battle with troop ID 1, which is a slime. I also set the character name and index to the slime character, and then just added it to the game map.
I've put together a demo to show various functions in action:
I will have to re-design certain parts of the script. In particular
1. conditions should be accessed through Event.condition, to make it more flexible and clear
2. Maybe a better way to handle branching should be considered. This is what I have planned so far:
event = Event.new(...)
event.show_choices("choice1, "choice2")
event.option_branch("choice1")
#perform branch commands
event.end_branch
event.option_branch("choice2")
#perform more stuff
event.end_branch
Basically, if you want to branch, you must make it clear that you're starting a branch, and the script will do all of the indenting and set-up for you.
Similarly, to close a branch, you must say "end_branch" because you must decrease the indent by 1, and also insert an empty command to tell the interprer that the branch is finished.
Edited by Tsukihime, 11 July 2012 - 11:27 AM.













