cheesecookie
Member
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 )