Event Name and ID Search Script
#1
This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.


What it does:
This is a script partially based on Near Fantastica's EventName script.
I have extended it and made it so that you can also search for the ID of an event you have a name of.
For example, you need to find a event with the name "John Doe". This script will return the ID of that event so that you can use it in another script/system/whatever.


The script:
Paste this script above Main:
Code:
#================================================#
#-----------------------------Event name and ID search engine---------------------------#
#------------------------------------------------------------------------------------------------#
#Name Search by Near Fantastica
#ID Search by Hadriel
#------------------------------------------------------------------------------------------------#
#================================================#


#==============================================================================
# Search for names of events with the given index/ID
#------------------------------------------------------------------------------
#   Near Fantastica
#   22/12/04
#   Add defenision of the names to Game Map Class
#--------------------------------------------------------------------------
#   How to use:
#   put this in the Call Script command:
#      $game_map.event_name(event_id)
#   to assing the name to a game variable use this in Call Script:
#      $game_variables[#] = $game_map.event_name(event_id)
#==============================================================================

class Game_Map
#--------------------------------------------------------------------------
#      Refer setup to Game Map
#--------------------------------------------------------------------------
alias game_map_setup setup
#--------------------------------------------------------------------------
#      Loads Event names
#--------------------------------------------------------------------------
def setup(map_id)
  game_map_setup(map_id)
  @name = {}
  for i in @map.events.keys
    @name[i] = @map.events[i].name
  end
end
#--------------------------------------------------------------------------
#      Displays Event names
#--------------------------------------------------------------------------
def event_name(event)
  @event_id = event
  @name[@event_id]
end
end

#==============================================================================
# Event ID search
#------------------------------------------------------------------------------
#   Hadriel
#   21/06/06
#--------------------------------------------------------------------------
#   How to use:
#   put this in the Call Script command:
#      Event_Id_Search.new("name",#)
#   where name is the name of the event and # is the
#   variable number you wish to assing the value to
#   Example:
#      Event_Id_Search.new("John Doe", 1)
#==============================================================================
#--------------------------------------------------------------------------
#     Searches for the id of an event with the given name
#--------------------------------------------------------------------------
class Event_Id_Search
  
  def initialize(find_name,search_result=1)
    @find_name = find_name
    @temp_name = ""
    @search_result = search_result
    for i in 1...$game_map.events.size
      @temp_name = $game_map.event_name(i)
      if  @temp_name == @find_name
        @event_id = i
      end
    
    end
    $game_variables[@search_result]=@event_id
  
  end
  
end


How to use it:

Put this in the Call script command:

Code:
Event_Id_Search.new("name",#)


name is the name of the event
# is the name of the variable in which the ID should be stored

Event Command version:
This is for those who want to use the classic event commands with Near Fantastica's EventNames script.
Use these event commands as follows:
Code:
<>Variable: [0001: i] = 1
<>Script: @find_name = "name" #the name you're searching for
<>Loop
     <>Script: $game_variables[2] = $game_map.event_name($game_variables[1])
     <>Conditional Branch: Script: $game_variables[2] == @find_name
         <>Variable: [0003: search_result] = Variable [0001: i]
         <>End Loop
         <>
     : End
     <>Variable: [0001: i] += 1
     <>
: Repeat


This uses 3 variables: 0001 named i, 0002, and 0003 named search_result. At the end of the process the event id is stored in 0003: search_result.

Ending credits:

I would like to thank Near Fantastica for his EventName script and I hope he doesn't mind me extending it like this.


I just thought this would be useful to some people.
Well, anyways...

Enjoy

~Hadriel~
}


Possibly Related Threads…
Thread Author Replies Views Last Post
  Change character script jaigai 0 3,187 11-19-2006, 01:00 PM
Last Post: jaigai
  Just a modification of Abyssos' facs script lumina... 0 2,958 11-01-2006, 01:00 PM
Last Post: lumina...
  Credit Script 1.1 acoole 0 2,838 10-24-2006, 01:00 PM
Last Post: acoole
  Script Dev Kit Nick 0 3,227 10-15-2006, 01:00 PM
Last Post: Nick
  Event dependent Movement Caldaron 0 2,597 10-09-2006, 01:00 PM
Last Post: Caldaron
  Opening Image script sasuke89 0 2,360 07-24-2006, 01:00 PM
Last Post: sasuke89
  Change Color of The diferent Status Script MASTERLOKI 0 2,630 07-18-2006, 01:00 PM
Last Post: MASTERLOKI
  Currency Script Split 0 2,658 05-18-2006, 01:00 PM
Last Post: Split
  Book Script and Utility Bruth 0 2,606 05-07-2006, 01:00 PM
Last Post: Bruth
  Common Event on Terrain Tag mudgolem 0 2,557 03-26-2006, 01:00 PM
Last Post: mudgolem



Users browsing this thread: 1 Guest(s)