Custom Event Triggers
Authors: ForeverZer0
Version: 1.1
Type: Event Trigger System
Key Term: Game Utility
IntroductionAllows 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.
ScreenshotsNone.
DemoNone.
ScriptHere it is...
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
# 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
InstructionsSee 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.
CompatibilityShould be very compatible with other scripts.
Credits and Thanks
- ForeverZer0, for the script.
- game_guy, for making the suggestion to post this.
Author's NotesEnjoy! Please report any bugs/issues you may encounter. I will offer as much support as possible with support on creating triggers.
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?
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
The input is my favorite part. Just glancing at it, I'm sure it supports ToA's Custom controls. :3
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.
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
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
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.
LOL! Nice comeback! xD
:P
Didn't mean to be a smart-ass, but its the truth.
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
Bump. I get that if I try to load a savegame, except it happens when I try to enter another map.
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.
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
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 ^^;
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.
Rose! My drive is floopy!
Uh oh....
My drive is no longer floppy... :whistle:
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!)
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.
*reluctantly puts away his floopy drive* What the hell kinda game are you making?!
Zero, who I love so very much, do you know how to make an event trigger when a babs enemy or one of the heroes touches it?
The script is the best, but when I tried it, I saw the event fires immediately
Can you do that when the condition is made, is activated by pressing accept in the event, or when is touching with the hero?
These are more to be used to trigger events, not as conditions. In your example it would be easier and simpler just to use the Player Touch trigger, and add a scripted conditional branch on what the event does if you still need to.
I admit there is a bit of ambiguity on the difference between the triggers and events. The trigger is basically the condition that is required for the event to start even looking at its code, while a condition is only checked once the event is already triggered.
Ah, I see, anyway the script is awesome, but i dont know any code to use, i have only the two codes incluided in the script
Quote from: ForeverZer0 on December 17, 2010, 12:07:50 pm
...between the triggers and events...
I meant "triggers'" and "conditions". I messed that up. :P
Is there a way to get an event with multiple custom triggered pages to work? Right now only the rightmost page seems to be processed, any other page with a lower number is ignored.
I'm not entirely sure. What you have stated is default in RMXP. My best suggestion is to rewrite the Game_Event#refresh method in the default scripts. But I don't think that would be a very good idea to begin with. Is there something you had in mind?
I think I mixed something up there; the actual problem is that events triggered by this script can't be run as parallel process, which means that the player isn't able to move during execution of background events when they contain waits for example.
Where to start editing in order to enable parallel processing?
I don't think this script was meant to be used with parallel processes in mind. There is a bit of a work around I guess:
Page 1 contains your trigger. Somewhere in there, turn on a self/switch.
Page 2 is a parallel process (no trigger needed). Page condition is the switch turned on. Here's where your parallel process stuff happens.