Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

> 


———
Before you ask! Read! ;)

You must have 30+ Posts to create a topic here!

Thanks for reading!
———

> Event trigger labels
Tsukihime
post Jun 13 2012, 01:36 PM
Post #1


Level 25
Group Icon

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




Looking for someone to write this script. It is not complicated actually.

This script will allow you to setup events in such a way that the player can press a certain key to trigger the event, and then the event will jump to a specific label depending on which key was pressed.

For example, by default, the "confirm" key is used to trigger "action trigger" events through :C (or the Z key)
But what if instead of executing all of the commands, we only execute some of them?

An example setup would be like

CODE
#==================#
#Label: Z
"talk?"
#==================#
#Label: A
"steal?"
#==================#
#Label: S
"battle?"


Where different parts of the event are executed depending on which key you pressed.

Ideally, you would make use of labels because now you just say "go to label C if C is pressed" or "go to label A if A is pressed".

In fact, the implementation of this script may become really easy with the use of labels.
All you have to do is jump to the specific label based on the key you pressed and then execute it normally. You might not even need to mess around with even triggers!

You then just have to make sure that you break out of the event when you reach another label.

This post has been edited by Tsukihime: Jun 13 2012, 02:00 PM


__________________________
My Scripts
Go to the top of the page
 
+Quote Post
   
 
Start new topic
Replies (1 - 3)
Night_Runner
post Jun 14 2012, 05:17 AM
Post #2


Level 50
Group Icon

Group: +Gold Member
Posts: 1,523
Type: Scripter
RM Skill: Undisclosed




CODE
#==============================================================================
# ** VXAce: NR's Event Trigger Labels
#------------------------------------------------------------------------------
# History:
#  Date Created: 13/June/2012
#  Created for: Tsukihime
#   @> http://www.rpgrevolution.com/forums/index.php?showtopic=56937
#
# Description:
#  This script allows developers to start their events by using more than
#  just the default 'C' button, and will jump to the correct place in the
#  event when the appropriate button is pressed.
#
# How to Install:
#  Copy this entire script. In your game's editor select Tools >>
#  Script Editor. Along the left hand side scroll to the bottom, right
#  click on after 'Materials' and select 'Insert'. Paste the code in the
#  blank window on the right.
#
# How to Use:
#  To choose where to start processing if the 'A' input is triggered, have
#  a 'Label' command at that position, with the 'Label Name' as
#           Input.trigger?(:A)
#  And repeat for the other input buttons.
#  By default, if an event uses this script, you need to manually specify
#  where it starts its processing for the C button as well.
#==============================================================================



#==============================================================================
# ** Game_Player
#------------------------------------------------------------------------------
#  Edited to have further checks (for the exra inputs) before running an
#  event
#==============================================================================

class Game_Player
  #--------------------------------------------------------------------------
  # * Processing When Not Moving
  #     last_moving : Was it moving previously?
  #--------------------------------------------------------------------------
  def update_nonmoving(last_moving)
    return if $game_map.interpreter.running?
    if last_moving
      $game_party.on_player_walk
      return if check_touch_event
    end
    if movable?
      if Input.trigger?(:C)
        return if get_on_off_vehicle
      end
      for x, y in positions_to_check_for_event
        for event in $game_map.events_xy(x, y)
          button_triggers = event.button_triggers
          if not button_triggers.empty?
            for button in button_triggers
              if Input.trigger?(button.to_sym)
                # Reset the commands (if this has run before)
                event.list = event.page.list.clone
                # If the event can run, insert a jump to label command at
                # the beginning
                if check_action_event
                  text = ["Input.trigger?(:#{button})"]
                  command = RPG::EventCommand.new(119, 0, text)
                  event.list.insert(0, command)
                  return
                end
              end
            end
          else
            if Input.trigger?(:C)
              return if check_action_event
            end
          end
        end
      end
    end
    update_encounter if last_moving
  end
  #--------------------------------------------------------------------------
  # * Positions to check for events
  #--------------------------------------------------------------------------
  def positions_to_check_for_event
    positions = [[@x, @y]]
    x2 = $game_map.round_x_with_direction(@x, @direction)
    y2 = $game_map.round_y_with_direction(@y, @direction)
    positions << [x2, y2]
    return positions unless $game_map.counter?(x2, y2)
    x3 = $game_map.round_x_with_direction(x2, @direction)
    y3 = $game_map.round_y_with_direction(y2, @direction)
    positions << [x3, y3]
    return positions
  end
end



#==============================================================================
# ** Game_Event
#------------------------------------------------------------------------------
#  Edited to detect if extra input buttons are specified.
#==============================================================================

class Game_Event
  #--------------------------------------------------------------------------
  # * Public Instance variables
  #--------------------------------------------------------------------------
  attr_reader   :button_triggers
  attr_reader   :page
  attr_accessor :list
  #--------------------------------------------------------------------------
  # * Alias Methods
  #--------------------------------------------------------------------------
  alias nr_eventLabels_setup_page_settings  setup_page_settings  unless $@
  #--------------------------------------------------------------------------
  # * Set Up Event Page Settings
  #--------------------------------------------------------------------------
  def setup_page_settings(*args)
    # Run the original setup_page_settings
    nr_eventLabels_setup_page_settings(*args)
    # Initialize the array of extra possiblt buttons to press
    @button_triggers = []
    # If the event starts by the player pressing a button
    if @trigger == 0
      # Check for extra buttons
      for command in @list
        if command.code == 118
          label = command.parameters[0]
          @button_triggers = label.scan(/Input\.trigger\?\(\:(.)\)/).flatten
        end
      end
    end
  end
end



#==============================================================================
# ** End of Script.
#==============================================================================


Instead of the:
CODE
Label: Z

I've gone with:
CODE
Label: Input.trigger?(:Z)


If you can I can change it to your original design, I just implemented it my way to make sure that developers don't accidentally invoke this script when they actually wanted to have a jump command.
It also lets developers use this script with any-key-input scripts.


__________________________
K.I.S.S.
Want help with your scripting problems? Upload a demo! Or at the very least; provide links to the scripts in question.

Most important guide ever: Newbie's Guide to Switches
Go to the top of the page
 
+Quote Post
   
Tsukihime
post Jun 15 2012, 02:06 PM
Post #3


Level 25
Group Icon

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




As long as it doesn't conflict with existing usage lol
I'm not really sure how common the labels are being used.

Now I just need to find something to test this with.


__________________________
My Scripts
Go to the top of the page
 
+Quote Post
   
Tsukihime
post Aug 18 2012, 07:36 PM
Post #4


Level 25
Group Icon

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




I have updated the script to automatically separate each "input branch" from one another. I don't think there is any reason why someone would want to allow the rest of the commands to run if they're going to use specialized branches anyways. But maybe if someone brings up a point...

This only occurs when you are using the specialized input branches.

I simply went through the page while it's setting itself up and inserted Exit Event Processing commands before each input branch label.
eg:

CODE
Label: Input.trigger?(:C)
Show Text: Do this
Exit Event Processing #automatically added
Label: Input.trigger?(:B)
Show Text: Do that


This ensures that when you press C, you are getting only the stuff that should be shown under the C branch.

I also fixed the extra buttons since it was just assigning, and not combining the different keys.

I also changed it so that if they don't like to type `Input.trigger?` they can change it to whatever they want.
However they still need to type the buttons in parenthesis.

http://db.tt/MUvL8AfU

This post has been edited by Tsukihime: Aug 18 2012, 08:40 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: 22nd May 2013 - 09:01 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker