Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
- # Custom Event Triggers
- # Author: ForeverZer0
- # Version: 1.1
- # Date: 10.13.2010
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
- # VERSION HISTORY
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
- # v.1.0 7.14.2010
- # - Original release
- # v.1.1 10.13.2010
- # - Shortened and made more efficient. Added comments.
- # - Eliminated bug and removed an unnecessary Regular Expression.
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
- #
- # Explanation:
- #
- # Allows you to easily create custom triggers for events. Uses simple comment
- # code in their event page to create a new trigger. If trigger evaluates as
- # 'true', their code will execute. Work differently than conditions, since the
- # page conditions must still be met and they are what actually what begin
- # execution of the event commands for that page.
- #
- # Instructions:
- #
- # - Very simple. Make a comment at the TOP of the page you want the custom
- # trigger to execute that simply reads "Custom Trigger". Now in the same
- # comment on the next line, or in another comment directly below the first,
- # simply write the a scripted true/false statement. If this line ever results
- # in a true statement, and the page conditions are met, the page will execute
- # its commands.
- # - You can use as many comment boxes you need to script the trigger, but they
- # must be consecutive and immediately after the "Custom Trigger" comment. Do
- # not use an arbitrary comment right after these comments, else the game will
- # attempt to include them in the trigger.
- # - This will also disable all other triggers for this page.
- #
- # Here's an example:
- #
- # Comment: Custom Trigger
- # : Input.press?(Input::L) && Input.press?(Input::R) &&
- # : Input.trigger?(Input::C)
- #
- # This will execute the event if the C button is pressed while the L and R
- # buttons are being held down (if page conditions are met).
- #
- # Another example:
- #
- # Comment: Custom Trigger
- # : $game_party.steps == 23423
- #
- # This executes if the party step count is equal to 23423.
- #
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
- #===============================================================================
- # ** Game_Event
- #===============================================================================
- class Game_Event
- attr_accessor :trigger
- alias zer0_custom_trigger_refresh refresh
- def refresh
- # Normal refresh method.
- zer0_custom_trigger_refresh
- # Search top of current page for the string "Custom Trigger".
- if @page != nil && @page.list[0].code == 108 &&
- @page.list[0].parameters[0] == 'Custom Trigger'
- trigger, list_index = '', 1
- # If found, loop until the next command is not a comment, adding each line
- # of the comments into a single string.
- while [108, 408].include?(@page.list[list_index].code)
- trigger += @page.list[list_index].parameters[0] + ' '
- list_index += 1
- end
- # Set event trigger to -1, which no method exists for by default.
- @custom_trigger, @trigger = trigger, -1
- end
- end
- alias zer0_custom_trigger_upd update
- def update
- zer0_custom_trigger_upd
- # If trigger is -1, and the created string evaluates as true, start event.
- if @trigger == -1 && !@erased && eval(@custom_trigger)
- start
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement