Choice-Move Handlers

Help spread the word!Share on FacebookShare on TumblrTweet about this on TwitterShare on Google+Share on LinkedInShare on RedditFlattr the author

This script provides a custom event (as in, event-driven programming) or choice windows called an “on cursor move” event. This event is triggered whenever the choice
window cursor changes to a different option.

You can attach handlers to this event that will be fired whenever the event
is triggered. Each handler holds a method and a set of arguments, and when
the handler is called, it will pass the arguents to the method and call the
method.

choiceMoveHandlers1

This script does not support changing scenes such as opening the party
menu or save menu.

Download

ScriptDemo

The demo shows a very simple use of on-cursor-move event handlers. It simply displays what your current selection is.

Installation

Place this script below Materials and above Main.

Usage

To assign an event handler, use the script call

choice_move_handler(choice_num, method_name, arg1, arg2, ... )

Where
choice_num is the number of the choice you want to assign this handler
to. 1 is the first choice.

method_name is the name of the method that will be called when this
handler is called.

arg1, arg2, ... are the arguments that will be passed to your method
when the handler is called.

You should have methods defined in Game_Interpreter for user convenience.

Example

Suppose we have the following method:

def show_gab(text)
  gab("Your selected choice is: %s" %text, 0)
end

It takes some text and displays it in a gab window.
We have a list of choices:

One
Two
Three

Let’s have each option display the option you have selected in a gab window

choice_move_handler(1, :show_gab, "One")
choice_move_handler(2, :show_gab, "Two")
choice_move_handler(3, :show_gab, "Three")

When you run the event and scroll through the choices, you will see the numbers
printed to console as expected.

Help spread the word!Share on FacebookShare on TumblrTweet about this on TwitterShare on Google+Share on LinkedInShare on RedditFlattr the author

You may also like...

Leave a Reply

Your email address will not be published.

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax