06-21-2006, 01:00 PM
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.
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~