Feature - Implemented Allow user input more advanced than "yes or no" in ash scripts

philmasterplus

Active member
I'm seeing two bugs.

1. When I hit Cancel in a popup launched with the aggregate-based form of user_prompt(), KoLmafia aborts the script.
Code:
 > ash user_prompt( "some message", $strings[ foo, bar, baz ] );
()
Script execution aborted (java.lang.NullPointerException): ()
Returned: void
Code:
 > js userPrompt("some message", {'did timmy': 0, 'fall down': 0, 'a well?': 0});
Unexpected error, debug log printed.

The debug log looks like this:
Code:
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
         KoLmafia v20.7 r20798, Windows 10, Java 11.0.11
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Please note: do not post this log in the KoLmafia thread of KoL's
 Gameplay-Discussion forum. If you would like the KoLmafia dev team
 to look at it, please write a bug report at kolmafia.us. Include
 specific information about what you were doing when you made this
 and include this log as an attachment.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Timestamp: Wed Jul 14 00:12:54 KST 2021
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 User: 
 Current run: 0
 MRU Script: Unknown
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


()
class java.lang.NullPointerException: null
java.lang.NullPointerException
	at net.sourceforge.kolmafia.textui.RuntimeLibrary.user_prompt(RuntimeLibrary.java:2671)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at net.sourceforge.kolmafia.textui.parsetree.LibraryFunction.execute(LibraryFunction.java:110)
	at net.sourceforge.kolmafia.textui.parsetree.FunctionCall.execute(FunctionCall.java:161)
	at net.sourceforge.kolmafia.textui.parsetree.BasicScope.execute(BasicScope.java:566)
	at net.sourceforge.kolmafia.textui.AshRuntime.executeScope(AshRuntime.java:292)
	at net.sourceforge.kolmafia.textui.AshRuntime.execute(AshRuntime.java:234)
	at net.sourceforge.kolmafia.textui.AshRuntime.execute(AshRuntime.java:226)
	at net.sourceforge.kolmafia.textui.command.AshSingleLineCommand.run(AshSingleLineCommand.java:74)
	at net.sourceforge.kolmafia.KoLmafiaCLI.doExecuteCommand(KoLmafiaCLI.java:593)
	at net.sourceforge.kolmafia.KoLmafiaCLI.executeCommand(KoLmafiaCLI.java:546)
	at net.sourceforge.kolmafia.KoLmafiaCLI.executeLine(KoLmafiaCLI.java:448)
	at net.sourceforge.kolmafia.KoLmafiaCLI.executeLine(KoLmafiaCLI.java:316)
	at net.sourceforge.kolmafia.KoLmafiaCLI$CommandProcessorThread.run(KoLmafiaCLI.java:238)
Code:
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
         KoLmafia v20.7 r20798, Windows 10, Java 11.0.11
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Please note: do not post this log in the KoLmafia thread of KoL's
 Gameplay-Discussion forum. If you would like the KoLmafia dev team
 to look at it, please write a bug report at kolmafia.us. Include
 specific information about what you were doing when you made this
 and include this log as an attachment.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Timestamp: Wed Jul 14 00:13:49 KST 2021
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 User: 
 Current run: 0
 MRU Script: Unknown
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


Unexpected error, debug log printed.
class java.lang.RuntimeException: java.lang.NullPointerException
java.lang.RuntimeException: java.lang.NullPointerException
	at net.sourceforge.kolmafia.textui.parsetree.LibraryFunction.executeWithoutInterpreter(LibraryFunction.java:165)
	at net.sourceforge.kolmafia.textui.javascript.LibraryFunctionStub.execute(LibraryFunctionStub.java:87)
	at net.sourceforge.kolmafia.textui.javascript.AshStub.call(AshStub.java:153)
	at net.sourceforge.kolmafia.textui.javascript.LibraryFunctionStub.call(LibraryFunctionStub.java:137)
	at org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:76)
	at org.mozilla.javascript.gen.command_line_3._c_script_0(command line:1)
	at org.mozilla.javascript.gen.command_line_3.call(command line)
	at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:412)
	at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3578)
	at org.mozilla.javascript.gen.command_line_3.call(command line)
	at org.mozilla.javascript.gen.command_line_3.exec(command line)
	at org.mozilla.javascript.Context.evaluateString(Context.java:1234)
	at net.sourceforge.kolmafia.textui.javascript.JavascriptRuntime.lambda$executeRun$1(JavascriptRuntime.java:325)
	at net.sourceforge.kolmafia.textui.javascript.JavascriptRuntime.executeFunction(JavascriptRuntime.java:256)
	at net.sourceforge.kolmafia.textui.javascript.JavascriptRuntime.executeRun(JavascriptRuntime.java:312)
	at net.sourceforge.kolmafia.textui.javascript.JavascriptRuntime.execute(JavascriptRuntime.java:236)
	at net.sourceforge.kolmafia.textui.AbstractRuntime.execute(AbstractRuntime.java:61)
	at net.sourceforge.kolmafia.textui.command.JavaScriptCommand.run(JavaScriptCommand.java:56)
	at net.sourceforge.kolmafia.KoLmafiaCLI.doExecuteCommand(KoLmafiaCLI.java:593)
	at net.sourceforge.kolmafia.KoLmafiaCLI.executeCommand(KoLmafiaCLI.java:546)
	at net.sourceforge.kolmafia.KoLmafiaCLI.executeLine(KoLmafiaCLI.java:448)
	at net.sourceforge.kolmafia.KoLmafiaCLI.executeLine(KoLmafiaCLI.java:316)
	at net.sourceforge.kolmafia.KoLmafiaCLI$CommandProcessorThread.run(KoLmafiaCLI.java:238)
Caused by: java.lang.NullPointerException
	at net.sourceforge.kolmafia.textui.RuntimeLibrary.user_prompt(RuntimeLibrary.java:2671)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at net.sourceforge.kolmafia.textui.parsetree.LibraryFunction.executeWithoutInterpreter(LibraryFunction.java:152)
	... 22 more

class java.lang.NullPointerException: null
java.lang.NullPointerException
	at net.sourceforge.kolmafia.textui.RuntimeLibrary.user_prompt(RuntimeLibrary.java:2671)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at net.sourceforge.kolmafia.textui.parsetree.LibraryFunction.executeWithoutInterpreter(LibraryFunction.java:152)
	at net.sourceforge.kolmafia.textui.javascript.LibraryFunctionStub.execute(LibraryFunctionStub.java:87)
	at net.sourceforge.kolmafia.textui.javascript.AshStub.call(AshStub.java:153)
	at net.sourceforge.kolmafia.textui.javascript.LibraryFunctionStub.call(LibraryFunctionStub.java:137)
	at org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:76)
	at org.mozilla.javascript.gen.command_line_3._c_script_0(command line:1)
	at org.mozilla.javascript.gen.command_line_3.call(command line)
	at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:412)
	at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3578)
	at org.mozilla.javascript.gen.command_line_3.call(command line)
	at org.mozilla.javascript.gen.command_line_3.exec(command line)
	at org.mozilla.javascript.Context.evaluateString(Context.java:1234)
	at net.sourceforge.kolmafia.textui.javascript.JavascriptRuntime.lambda$executeRun$1(JavascriptRuntime.java:325)
	at net.sourceforge.kolmafia.textui.javascript.JavascriptRuntime.executeFunction(JavascriptRuntime.java:256)
	at net.sourceforge.kolmafia.textui.javascript.JavascriptRuntime.executeRun(JavascriptRuntime.java:312)
	at net.sourceforge.kolmafia.textui.javascript.JavascriptRuntime.execute(JavascriptRuntime.java:236)
	at net.sourceforge.kolmafia.textui.AbstractRuntime.execute(AbstractRuntime.java:61)
	at net.sourceforge.kolmafia.textui.command.JavaScriptCommand.run(JavaScriptCommand.java:56)
	at net.sourceforge.kolmafia.KoLmafiaCLI.doExecuteCommand(KoLmafiaCLI.java:593)
	at net.sourceforge.kolmafia.KoLmafiaCLI.executeCommand(KoLmafiaCLI.java:546)
	at net.sourceforge.kolmafia.KoLmafiaCLI.executeLine(KoLmafiaCLI.java:448)
	at net.sourceforge.kolmafia.KoLmafiaCLI.executeLine(KoLmafiaCLI.java:316)
	at net.sourceforge.kolmafia.KoLmafiaCLI$CommandProcessorThread.run(KoLmafiaCLI.java:238)

2. When I hit Cancel in a popup launched with the timeout-form of user_prompt(), KoLmafia appears to become "locked":
user-prompt-bug1.png

When the GUI is launched from a terminal-based session (using the --CLI option), it is the CLI that becomes unresponsive; I can type in arbitrary text, but KoLmafia does not respond. Quizzically, the graphical CLI works just fine:
user-prompt-bug2.png
 

gausie

D̰͕̝͚̤̥̙̐̇̑͗̒e͍͔͎͈͔ͥ̉̔̅́̈l̠̪̜͓̲ͧ̍̈́͛v̻̾ͤe͗̃ͥ̐̊ͬp̔͒ͪ
Staff member
Top