New Event Triggers (SDK2)

New Event Triggers
Version: 1.00

Introduction
This script allows you trigger an event with scripted expressions.

Script
script Spoiler
#==============================================================================
# ** Event Trigger
#------------------------------------------------------------------------------
# Tibuda
# Version 1.00
# 04.18.2007
#------------------------------------------------------------------------------
# Instructions: Add a comment to your event starting with "Trigger" with
#   the conditional expression
#==============================================================================

#------------------------------------------------------------------------------
# * SDK Log Script and Check requirements
#------------------------------------------------------------------------------
SDK.log('Event Trigger', 'tibuda', 1.00, '04.18.2007')
SDK.check_requirements(2, [1,2])
#--------------------------------------------------------------------------
# Begin SDK Enabled Check
#--------------------------------------------------------------------------
if SDK.enabled?('Event Trigger')

#==============================================================================
class RPG::Event::Page
  #--------------------------------------------------------------------------
  def conditions_met?(map_id, event_id)
    return false unless @condition.conditions_met?(map_id, event_id)
    for item in @list
      next unless item.code == 108 || item.code == 408
      array = item.parameters[0].split(' ')
      if array.size > 1 && array[0].upcase == 'TRIGGER'
        array.delete_at(0)
        return false unless eval(array.join(' '))
      end
    end
    return true
  end
  #--------------------------------------------------------------------------
end
#==============================================================================
class Game_Event
  #--------------------------------------------------------------------------
  SDK.log_overwrite(:Game_Event, :refresh_trigger_conditions)
  def refresh_trigger_conditions
    # Check in order of large event pages
    for page in @event.pages.reverse
      # Skips If Page Conditions Not Met
      next unless page.conditions_met?(@map_id, @id)
      if SDK.enabled?('Time System')
        next unless time_conditions_met?(page)
      end
      # Set local variable: new_page
      new_page = page
      # Remove loop
      break
    end
    # Return new page
    return new_page
  end
  #--------------------------------------------------------------------------
end
#==============================================================================

end
#--------------------------------------------------------------------------
# End SDK Enabled Test
#--------------------------------------------------------------------------
Expand to see the code.


Instructions
To add a trigger create a comment with the following syntax:
Trigger <expression>
Expand to see the code.


FAQ
Quote:
How does this triggers work? i want a light to be on once $ats.hours is >= 22 and $ats.hours i <= 21, with the comment light effects. how would i turn the light on?

Add the following comment to the page with the light effects comment:
Trigger $ats.hours >= 22 and $ats.hours <= 21
Expand to see the code.

Quote:
Thx for helping me out and btw how do u end trigger?

You don't have to "end" it.

Compatibility
Requires SDK2.2 parts I & II

Credits and Thanks
Credit for Near Fantastica for the original idea and busbuzz for requesting a SDK2 version.
I'm pretty annoying when it comes to event comments (I launched the trend, so I know the subject :) ), and I think we really shoud use the same standard, so they can all be compatible.

I saw that lot of scripts are using |, so why don't you use something like Trigger|$ats.hours >= 22 and $ats.hours <= 21 ? That way, you can evaluate directly the part on the right of the |, and stay compatible with other scripts !

Trust me, things like that should be done in the beginning, because when the cat is out of the box... I'm still regretting some design decisions !
Yay!! awesome script

for the ones are used to near's trigger and actually use near's advance time make sure u put the trigger above all comments ^^
This will be great addition to Netplay Plus! Great Script!
Erm, sorry about necroposting but this is something I absolutely need help with. How do I make it so that if I press the L button (Or any other buttons besides C), the event will trigger?
[QUOTE=Hero;268119]Erm, sorry about necroposting but this is something I absolutely need help with. How do I make it so that if I press the L button (Or any other buttons besides C), the event will trigger?[/QUOTE]

It's not a good idea, but you can set the event to Autorun and add the following comment to your event:
Trigger Input.press?(Input::L)
Expand to see the code.


I think it would be better to script something to call a common event when the button is pressed.
Well actually, I was trying to implement a pickpocket system without having to go into too much scripting (It would be very difficult, considering the event numbers and such) so I was trying to make the pickpocket thing trigger if you press L. Oh and before I forget, the event disappears when I try to make that comment :( .
What should i do if i want to turn on the script when a certain switch is on?
Hi, I'm using Mr. Mo's SBABS and Near's ATS but I don't know if these scripts are compatible with the New event triggers 'cause when I start my game it gives a Syntax Error@_@, what can I do? And where I have to put the event triggers script?
Thanks

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=19517