Skip to content

Commit

Permalink
Updates in response to Pull Request comments
Browse files Browse the repository at this point in the history
-Started each script with documentation block
-Used string interpolation for YAML files
-Incorporated debug arguments into both scripts to print debug info
-Changed 'puts' to either 'echo' or 'respond'
-Fixed name of script in documentation block
-Changed for loop to 'Names.each do'
  • Loading branch information
lloyd-delacroix authored Feb 21, 2017
1 parent d237280 commit ef9ac30
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 73 deletions.
75 changes: 40 additions & 35 deletions display-guild.lic
Original file line number Diff line number Diff line change
@@ -1,47 +1,53 @@
Contacts = YAML.load_file('./scripts/data/base-contacts.yaml')
=begin
Documentation: https://elanthipedia.play.net/Lich_script_repository#display-guild
=end

no_pause_all
no_kill_all

arg_definitions = [
[
{ name: 'debug', regex: /debug/i, optional: true, description: 'Very verbose, may cause lich to hang for several seconds if using large contact files' }
]
]
args = parse_args(arg_definitions)
$debug_mode_cc = args.debug

Contacts = YAML.load_file("./scripts/data/base-contacts.yaml")
Contacts = Contacts['contacts']

#DEBUG INFO
#puts "---Base Contacts---"
#puts Contacts.inspect
#puts Contacts.class
echo "---Base Contacts---" if $debug_mode_cc
echo Contacts.inspect if $debug_mode_cc
echo Contacts.class if $debug_mode_cc

#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!"
if File.exist?("./scripts/profiles/#{checkname}-contacts.yaml")
echo "Personal contact file found - now importing." if $debug_mode_cc

Personal_Contacts = YAML.load_file('./scripts/profiles/'+checkname+'-contacts.yaml')
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
echo "---Personal Contacts---" if $debug_mode_cc
echo Personal_Contacts.inspect if $debug_mode_cc
echo Personal_Contacts.class if $debug_mode_cc

Contacts.merge!(Personal_Contacts)
Names = Contacts.map {|row| row[0]}
puts "***Successfully loaded " + Names.length.to_s + " contacts."
echo "***Successfully loaded " + Names.length.to_s + " contacts."

#DEBUG INFO
#puts "---Names Array---"
#puts Names.inspect
#puts Names.class
echo "---Names Array---" if $debug_mode_cc
echo Names.inspect if $debug_mode_cc
echo Names.class if $debug_mode_cc
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
echo "---Merged Contacts---" if $debug_mode_cc
echo Contacts.inspect if $debug_mode_cc
echo Contacts.class if $debug_mode_cc
echo "-----" if $debug_mode_cc

class Stalker
@@subs = {}
Expand Down Expand Up @@ -72,15 +78,14 @@ 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'
Names.each do |name|
if (Contacts[name]['guild'] == 'Thief')
Contacts[name]['guild'] = 'X'
end
if (Contacts[Names[index]]['guild'] == 'Bard')
Contacts[Names[index]]['guild'] = 'D'
if (Contacts[name]['guild'] == 'Bard')
Contacts[name]['guild'] = 'D'
end
Stalker.add((Names[index].capitalize),Contacts[Names[index]]['guild'].chr+':'+Names[index].capitalize)
Stalker.add((name.capitalize),Contacts[name]['guild'].chr+':'+name.capitalize)
end

clear until script.gets.nil?
clear until script.gets.nil?
90 changes: 52 additions & 38 deletions yellowpages.lic
Original file line number Diff line number Diff line change
@@ -1,56 +1,70 @@
=begin
Documentation: https://elanthipedia.play.net/Lich_script_repository#yellowpages
=end

arg_definitions = [
[
{ name: 'debug', regex: /debug/i, optional: true, description: 'Very verbose, may cause lich to hang for several seconds if using large contact files' },
{ name: 'search', regex: /[a-zA-Z]/, optional: true, description: 'Name of player to look up in contacts.' }
]
]
args = parse_args(arg_definitions)
$debug_mode_cc = args.debug

#DEBUG INFO
echo args.debug if $debug_mode_cc
echo args.search if $debug_mode_cc

#Load base contacts YAML
Contacts = YAML.load_file('./scripts/data/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
echo "---Base Contacts---" if $debug_mode_cc
echo Contacts.inspect if $debug_mode_cc
echo Contacts.class if $debug_mode_cc

#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!"
if File.exist?("./scripts/profiles/#{checkname}-contacts.yaml")
##DEBUG
echo "Personal Contact file found! Now importing!" if $debug_mode_cc

Personal_Contacts = YAML.load_file('./scripts/profiles/'+checkname+'-contacts.yaml')
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
echo "---Personal Contacts---" if $debug_mode_cc
echo Personal_Contacts.inspect if $debug_mode_cc
echo Personal_Contacts.class if $debug_mode_cc

Contacts.merge!(Personal_Contacts)
end

#DEBUG INFO
#puts "---Merged Contacts---"
#puts Contacts.inspect
#puts Contacts.class
#puts "-----"

echo "---Merged Contacts---" if $debug_mode_cc
echo Contacts.inspect if $debug_mode_cc
echo Contacts.class if $debug_mode_cc
echo "-----" if $debug_mode_cc

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"
if args.search.nil?
echo "What user do you wish to search for?"
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/,'')

Record = Contacts[args.search]
if Record.nil?
echo "User not found in contacts"
else
#DEBUG
echo Record.inspect if $debug_mode_cc

#Print contact information
respond "Information for " + args.search
respond " "
respond "Guild: " + Record['guild'].inspect.gsub(/nil/,'')
respond "Race: " + Record['race'].inspect.gsub(/nil/,'')
respond "Circle: " + Record['circle'].inspect.to_s.gsub(/nil/,'')
respond "Relationship: " + Record['relationship'].inspect.gsub(/nil/,'')
respond "Notes: " + Record['notes'].inspect.gsub(/nil/,'')
respond "Alts: " + Record['alts'].inspect.gsub(/nil/,'')
end
end

0 comments on commit ef9ac30

Please sign in to comment.