Results 1 to 2 of 2

Thread: get_player_name(int) to get player names

  1. #1
    Senior Member
    Join Date
    Oct 2014
    Posts
    169

    Default get_player_name(int) to get player names

    I am hoping I am just not blind and didn't see a function that already did this but I was hoping for a function that takes an ID and returns a player name. I've been using one for a bit now and pushed it in a script update without realizing that it wasn't part of vanilla mafia so I'm posting my diff file here:

    Code:
    Index: src/net/sourceforge/kolmafia/textui/RuntimeLibrary.java
    ===================================================================
    --- src/net/sourceforge/kolmafia/textui/RuntimeLibrary.java (revision 18478)
    +++ src/net/sourceforge/kolmafia/textui/RuntimeLibrary.java (working copy)
    @@ -1520,6 +1536,8 @@
    
            params = new Type[] { DataTypes.STRING_TYPE };
            functions.add( new LibraryFunction( "get_player_id", DataTypes.STRING_TYPE, params ) );
    +       params = new Type[] { DataTypes.INT_TYPE };
    +       functions.add( new LibraryFunction( "get_player_name", DataTypes.STRING_TYPE, params ) );
    
            // Quest handling functions.
    
    @@ -6759,7 +6805,13 @@
    
            return new Value( ContactManager.getPlayerId( playerName, true ) );
        }
    +   public static Value get_player_name( Interpreter interpreter, final Value playerIdValue )
    +   {
    +       String playerId = playerIdValue.toString();
    
    +       return new Value( ContactManager.getPlayerName(playerId) );
    +   }
    +
        // Quest completion functions.
    
        public static Value tavern( Interpreter interpreter )

  2. #2
    Developer
    Join Date
    Apr 2006
    Posts
    922

    Default

    r18480

Posting Permissions

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