Results 1 to 1 of 1

Thread: Go2 adjustment to deal with the commas.

  1. #1

    Default Go2 adjustment to deal with the commas.

    Old code:

    Code:
    check_silvers = proc {
    	hook_proc = proc { |server_string|
    		if server_string =~ /^\s*Name\:|^\s*Gender\:|^\s*Normal \(Bonus\)|^\s*Strength \(STR\)\:|^\s*Constitution \(CON\)\:|^\s*Dexterity \(DEX\)\:|^\s*Agility \(AGI\)\:|^\s*Discipline \(DIS\)\:|^\s*Aura \(AUR\)\:|^\s*Logic \(LOG\)\:|^\s*Intuition \(INT\)\:|^\s*Wisdom \(WIS\)\:|^\s*Influence \(INF\)\:/
    			nil
    		elsif server_string =~ /^\s*Mana\:\s+\-?[0-9]+\s+Silver\:\s+([0-9]+)/
    			DownstreamHook.remove('go2_check_silvers')
    			nil
    		else
    			server_string
    		end
    	}
    	clear
    	DownstreamHook.add('go2_check_silvers', hook_proc)
    	silence_me unless undo_silence = silence_me
    	put 'info'
    	silence_me if undo_silence
    	while (line = get)
    		if line =~ /^\s*Mana\:\s+\-?[0-9]+\s+Silver\:\s+([0-9]+)/
    			silvers = $1.to_i
    			break
    		end
    	end
    	silvers
    }

    Updated code:

    Code:
    check_silvers = proc {
    	hook_proc = proc { |server_string|
    		if server_string =~ /^\s*Name\:|^\s*Gender\:|^\s*Normal \(Bonus\)|^\s*Strength \(STR\)\:|^\s*Constitution \(CON\)\:|^\s*Dexterity \(DEX\)\:|^\s*Agility \(AGI\)\:|^\s*Discipline \(DIS\)\:|^\s*Aura \(AUR\)\:|^\s*Logic \(LOG\)\:|^\s*Intuition \(INT\)\:|^\s*Wisdom \(WIS\)\:|^\s*Influence \(INF\)\:/
    			nil
    		elsif server_string =~ /^\s*Mana\:\s+\-?[0-9]+\s+Silver\:\s+(.*)/
    			DownstreamHook.remove('go2_check_silvers')
    			nil
    		else
    			server_string
    		end
    	}
    	clear
    	DownstreamHook.add('go2_check_silvers', hook_proc)
    	silence_me unless undo_silence = silence_me
    	put 'info'
    	silence_me if undo_silence
    	while (line = get)
    		if line =~ /^\s*Mana\:\s+\-?[0-9]+\s+Silver\:\s+(.*)/
    			silvers = $1.gsub(",","").to_i
    			break
    		end
    	end
    	silvers
    }
    Updated the regex to take everything after silvers instead of just the numbers before the first comma, then gsub out the commas.

    Changes in 3 places.
    - 2 where it changes from s+([0-9]+) to s+(.*)
    - 1 where the change is from silvers = $1.to_i to silvers = $1.gsub(",","").to_i
    Last edited by Sadrael; 10-11-2020 at 05:59 PM.

Similar Threads

  1. Official: Guild Training Points Adjustment
    By Orthin in forum Gemstone News
    Replies: 1
    Last Post: 09-29-2020, 07:48 AM
  2. Pending Bone Shatter Adjustment
    By Nilandia in forum Empath
    Replies: 179
    Last Post: 01-03-2014, 04:45 PM
  3. Official: crumbly enhancive item value adjustment
    By Belnia in forum Gemstone News
    Replies: 4
    Last Post: 04-08-2009, 12:47 AM
  4. Strathspey on Chalk Adjustment
    By Fallen in forum Sorcerer
    Replies: 13
    Last Post: 04-07-2009, 11:59 AM
  5. Gemstone IV Schedule Adjustment
    By CrystalTears in forum Gemstone News
    Replies: 4
    Last Post: 08-26-2003, 02:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •