[XP] Custom Event Triggers

Started by ForeverZer0, July 14, 2010, 05:35:24 pm

Previous topic - Next topic

ForeverZer0

July 14, 2010, 05:35:24 pm Last Edit: October 13, 2010, 04:40:22 pm by ForeverZer0
Custom Event Triggers
Authors: ForeverZer0
Version: 1.1
Type: Event Trigger System
Key Term: Game Utility



Introduction

Allows you to easily create custom triggers for events. Uses simple commentcode 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.


Features


  • Very easy to use (requires very simple script statements)
  • Can use ABSOLUTELY anything to trigger an event.
  • No longer confined to the few basic triggers.



Screenshots

None.


Demo

None.


Script

Here it is...
Spoiler: ShowHide


#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
# 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



Instructions

See script. Even if you have no scripting experience, you can will likely still be able to create the triggers, so do not let that turn you off to the script.


Compatibility

Should be very compatible with other scripts.


Credits and Thanks


  • ForeverZer0, for the script.
  • game_guy, for making the suggestion to post this.



Author's Notes

Enjoy! Please report any bugs/issues you may encounter. I will offer as much support as possible with support on creating triggers.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

winkio

I like the idea of the script, but I'm just curious: what does this do that parallel proccess events contained within a conditional block don't?

ForeverZer0

Quote from: winkio on July 14, 2010, 08:24:46 pm
I like the idea of the script, but I'm just curious: what does this do that parallel proccess events contained within a conditional block don't?


Not a whole lot. You can make more complicated triggers easier. You can say the same for all the default triggers as well. Why have an "Action Button" trigger when you can make a conditional branch on a parallel trigger checking for the same thing. Just makes some things easier.  :P
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

G_G

The input is my favorite part. Just glancing at it, I'm sure it supports ToA's Custom controls. :3

ForeverZer0

Quote from: game_guy on July 14, 2010, 08:52:52 pm
The input is my favorite part. Just glancing at it, I'm sure it supports ToA's Custom controls. :3


It should support ANY script call that, even from exotic scripts.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Blizzard

Quote from: ForeverZero on July 14, 2010, 05:35:24 pm

  • Can use ABSOLUTELY anything to trigger an event.



Unless it can trigger when I cough, I suggest you remove "ABSOLUTELY" from that sentence. xD
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

ForeverZer0

Quote from: Blizzard on July 15, 2010, 02:21:52 am
Quote from: ForeverZero on July 14, 2010, 05:35:24 pm

  • Can use ABSOLUTELY anything to trigger an event.



Unless it can trigger when I cough, I suggest you remove "ABSOLUTELY" from that sentence. xD


Just use
@blizzard.cough?


I'm leaving it. If anybody takes it out of context and thinks arbitrary things in the real world will trigger events, they are the idiot, not me for writing that.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

G_G


ForeverZer0

 :P
Didn't mean to be a smart-ass, but its the truth.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Sin86

I keep getting this error every time I hit new game on the beginning. It says this right before the game loads the starting map.



Script 'Custom Event Triggers' line 59: NoMethodError occurred

undefined method `list for nil:NilClass

The Niche

Bump. I get that if I try to load a savegame, except it happens when I try to enter another map.
Level me down, I'm trying to become the anti-blizz!
Quote from: winkio on June 15, 2011, 07:30:23 pm
Ah, excellent.  You liked my amusing sideshow, yes?  I'm just a simple fool, my wit entertains the wise, and my wisdom fools the fools.



I'm like the bible, widely hated and beautifully quotable.

Dropbox is this way, not any other way!

ForeverZer0

October 12, 2010, 12:03:39 pm #11 Last Edit: October 13, 2010, 04:41:07 pm by ForeverZer0
Quote from: Sin86 on July 25, 2010, 02:44:49 pm
I keep getting this error every time I hit new game on the beginning. It says this right before the game loads the starting map.



Script 'Custom Event Triggers' line 59: NoMethodError occurred

undefined method `list for nil:NilClass


I'll look into it and fix it tonight. Thanks. ;)

EDIT:
* Updates to 1.1 *

Fixed the bug. Also changed the script a bit, shortening it and improving the code. Added comments.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Karltheking4

OMG, most wondeful script in the world *hugs and levels up*
It is ALOT easier than conditional paralell process events if you have nearly the whole floor covered in them :D

Mimi Chan

I think I am stupid for thinking some stuffs that can be use as a trigger too @.@

I mean I was thinking of stuffs outside RMXP that can trigger it as well. I was thinking of...an npc checks if you have a floopy drive inserted on your drive A and if you do, gives you a very rare item @.@ (a much rarer item if the floppy has a certain file inside it)

Or an event that will activate if your sounds are mute o.oa
Or if your CD drive bay is open...
Or if you are connected to internet...

Wait I think I am thinking too much ^^;
What's a sig?

WhiteRose

Quote from: Mimi Chan on October 15, 2010, 01:52:10 pm
floopy drive


Quote from: Mimi Chan on October 15, 2010, 01:52:10 pm
floopy drive


Quote from: Mimi Chan on October 15, 2010, 01:52:10 pm
floopy drive


:rofl: That's way funnier than it should be; I guess I'm just on one today.

At any rate, Blizz did, if I remember correctly, create a script that accessed external files. It's part of his Multi-Game Launcher, but if you got his permission you might be able to modify it to check for external files during a game.

The Niche

Level me down, I'm trying to become the anti-blizz!
Quote from: winkio on June 15, 2011, 07:30:23 pm
Ah, excellent.  You liked my amusing sideshow, yes?  I'm just a simple fool, my wit entertains the wise, and my wisdom fools the fools.



I'm like the bible, widely hated and beautifully quotable.

Dropbox is this way, not any other way!

Karltheking4

Uh oh....
My drive is no longer floppy... :whistle:

Blizzard

You can drive my floopy. If you've been a good girl, that is.

Ok, enough with the sexual innuendo with my wife. (Read: Enough spam, lol!)
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Mimi Chan

Whats with people and floppy drives o.oa

For one, my computer still has floppy drive B (the one with 5 1/2 inch floppy)

Would be cool if RMXP can read stuffs outside it, I could make funny in and interesting NPC with it *.*
Like a psychic that will say I heard you like 'insert game here' when it detects you have it installed in your system.

Or that script that can automatically open your CD drive. I remember I always taught those are magic O.O
Or maybe force a full screen pic of a fake Blue Screen of Death and tell the CPU to make that long beep.
What's a sig?

The Niche

*reluctantly puts away his floopy drive* What the hell kinda game are you making?!
Level me down, I'm trying to become the anti-blizz!
Quote from: winkio on June 15, 2011, 07:30:23 pm
Ah, excellent.  You liked my amusing sideshow, yes?  I'm just a simple fool, my wit entertains the wise, and my wisdom fools the fools.



I'm like the bible, widely hated and beautifully quotable.

Dropbox is this way, not any other way!