forked from elanthia-online/dr-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8b1f92e
commit f385e1b
Showing
2 changed files
with
142 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
Contacts = YAML.load_file('./scripts/data/base-contacts.yaml') | ||
Contacts = Contacts['contacts'] | ||
|
||
#DEBUG INFO | ||
#puts "---Base Contacts---" | ||
#puts Contacts.inspect | ||
#puts Contacts.class | ||
|
||
#Check for <CharName>-contacts.yaml file and merges it if exists | ||
if File.exist?('./scripts/profiles/'+checkname+'-contacts.yaml') | ||
puts "Personal Contact file found! Now importing!" | ||
|
||
Personal_Contacts = YAML.load_file('./scripts/profiles/'+checkname+'-contacts.yaml') | ||
Personal_Contacts = Personal_Contacts['contacts'] | ||
|
||
#DEBUG INFO | ||
#puts "---Personal Contacts---" | ||
#puts Personal_Contacts.inspect | ||
#puts Personal_Contacts.class | ||
|
||
Contacts.merge!(Personal_Contacts) | ||
Names = Contacts.map {|row| row[0]} | ||
puts "***Successfully loaded " + Names.length.to_s + " contacts." | ||
|
||
#DEBUG INFO | ||
#puts "---Names Array---" | ||
#puts Names.inspect | ||
#puts Names.class | ||
end | ||
|
||
#DEBUG INFO | ||
#puts "---Merged Contacts---" | ||
#puts Contacts.inspect | ||
#puts Contacts.class | ||
#puts "-----" | ||
|
||
|
||
# quiet | ||
=begin | ||
Documentation: https://elanthipedia.play.net/Lich_script_repository#stalker | ||
=end | ||
|
||
no_pause_all | ||
no_kill_all | ||
|
||
class Stalker | ||
@@subs = {} | ||
|
||
def self.subs | ||
@@subs | ||
end | ||
|
||
def self.clear | ||
@@subs = {} | ||
end | ||
|
||
def self.add(target, result) | ||
@@subs[/#{target}/] = result | ||
end | ||
end | ||
|
||
action = proc do |client_string| | ||
matches = Stalker.subs.select { |key, _| key =~ client_string } | ||
matches.each { |target, result| client_string.gsub!(target, result) } | ||
client_string | ||
end | ||
|
||
DownstreamHook.remove('stalker') | ||
DownstreamHook.add('stalker', action) | ||
|
||
before_dying do | ||
DownstreamHook.remove('stalker') | ||
end | ||
|
||
# defaults | ||
for index in 0 ... Names.size | ||
if (Contacts[Names[index]]['guild'] == 'Thief') | ||
Contacts[Names[index]]['guild'] = 'X' | ||
end | ||
if (Contacts[Names[index]]['guild'] == 'Bard') | ||
Contacts[Names[index]]['guild'] = 'D' | ||
end | ||
Stalker.add((Names[index].capitalize),Contacts[Names[index]]['guild'].chr+':'+Names[index].capitalize) | ||
end | ||
|
||
clear until script.gets.nil? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#Load base contacts YAML | ||
Contacts = YAML.load_file('./scripts/data/base-contacts.yaml') | ||
Contacts = Contacts['contacts'] | ||
|
||
#DEBUG INFO | ||
#puts "---Base Contacts---" | ||
#puts Contacts.inspect | ||
#puts Contacts.class | ||
|
||
#Check for <CharName>-contacts.yaml file and merges it if exists | ||
if File.exist?('./scripts/profiles/'+checkname+'-contacts.yaml') | ||
puts "Personal Contact file found! Now importing!" | ||
|
||
Personal_Contacts = YAML.load_file('./scripts/profiles/'+checkname+'-contacts.yaml') | ||
Personal_Contacts = Personal_Contacts['contacts'] | ||
|
||
#DEBUG INFO | ||
#puts "---Personal Contacts---" | ||
#puts Personal_Contacts.inspect | ||
#puts Personal_Contacts.class | ||
|
||
Contacts.merge!(Personal_Contacts) | ||
end | ||
|
||
#DEBUG INFO | ||
#puts "---Merged Contacts---" | ||
#puts Contacts.inspect | ||
#puts Contacts.class | ||
#puts "-----" | ||
|
||
|
||
arg_definitions = [ | ||
[ | ||
{ name: 'search', regex: /[a-zA-Z]/, optional: false, description: 'Name of player to look up in contacts.' } | ||
] | ||
] | ||
args = parse_args(arg_definitions) | ||
|
||
#DEBUG INFO | ||
#puts args.search | ||
#puts args.class | ||
|
||
Record = Contacts[args.search] | ||
if Record.nil? | ||
puts "User not found in contacts" | ||
else | ||
#puts Record.inspect | ||
puts "Information for " + args.search | ||
puts " " | ||
puts "Guild: " + Record['guild'].inspect.gsub(/nil/,'') | ||
puts "Race: " + Record['race'].inspect.gsub(/nil/,'') | ||
puts "Circle: " + Record['circle'].inspect.to_s.gsub(/nil/,'') | ||
puts "Relationship: " + Record['relationship'].inspect.gsub(/nil/,'') | ||
puts "Notes: " + Record['notes'].inspect.gsub(/nil/,'') | ||
puts "Alts: " + Record['alts'].inspect.gsub(/nil/,'') | ||
end |