Bitems for Bees Hate You

ckb

Minion
Staff member
I threw together an inventory Relay script to highlight all the items in your inventory with Bs in them. This is a work in progress and breaks some stuff, but it gets things started. I thought I would post this now because there are probabaly a lot of people doings these runs now. I'll work on improvements as I have time.

This is a simple script... probably too simple. It just does a replace for item strings with Bs in them. This breaks some of the HTML for simple named items (box, ball) so I have an expection for those. It also breaks some images that have the same imagename as the itemname. These are known bugs at the moment.

ckb
 

Attachments

  • inventory.ash
    409 bytes · Views: 70
Last edited:

Bale

Minion
To do this properly isn't as simple as exchanging every b on the page. You need to specifically find b in the names of items. The correct (and easiest for certain definitions of the word easy) is to use a regular expression. There's a primer on using regular expressions in mafia HERE. there's a list of mafia's regex functions HERE.

It's a very useful thing to learn although it can seem daunting at first glance.
 

Theraze

Active member
If you're dealing with the inventory, the easiest thing to do is to go to your general inventory in the mafia GUI and just type 'b' in the box, no apostrophes, just the letter. You'll get all the items with 'b' in the name. Now dump them all in your closet (as long as you have automatically satisfy with closet disabled) if they aren't a no-sell quest item. Done! Well, until the next time you get some more 'b' items...
 

slyz

Developer
That takes up way too many server hits. And you might still decide to use an item, even if it has a 'b' in its name.
 

ckb

Minion
Staff member
What slyz said... and you can still equip B items - sometimes the benefit is worth the extra pain.

Also, I fixed the bugs... without Bale's fancy programmer stuff. Mostly with my mechanical minded force-foo.
I also added a check for the Bees Hate You path, so it won't highlight your B items unless it matters.
New update attached to first post.

ckb
 
Last edited:

Bale

Minion
Huh. Force-fu indeed. I guess I'm too fond of regexps. :)

Here's a small improvement using an interesting feature of ash that you don't seem to have discovered yet:

Code:
	[COLOR="#0000ff"][B]foreach it in $items[][/B][/COLOR]
	{
		if (contains_text(it,"b") || contains_text(it,"B") )
		{
			results.replace_string("ircm\">"+it, "ircm\"><span style=\"color:darkred\"><i>"+it+"</i></span>");
		}
	}
$items[] is an array of ALL ITEMS in the game. Amazing, eh?

Also you can check for Beecore without needing a server hit like this:

Code:
void main()
{
	//Add a path check for Bees hate you here
	if(my_path() == "Bees Hate You")
	{
		Bitems();
	}

}

That's important because you don't want to hit the server an extra time EVERY time you check inventory.
 
Last edited:

ckb

Minion
Staff member
Yea, this is what you get when a mechanical engineer writes code. Thanks for the cleanup and the my_path(). I felt like there should be a command like that but could not find the right syntax.

ckb

edit: update attachment on post 1
 

Theraze

Active member
Wouldn't it be easier to do contains_text(it.to_lower_case(), "b") instead of checking for both b and B?
 

ckb

Minion
Staff member
Minor updates for better-than-me programming (thanks Theraze) and more general highlighting. Now works with items that are equipped. New attachment in first post.

ckb
 

nema

New member
I don't have any idea how to make this work.

If I add it to /relay, there is no apparent effect.

If I prefix it as so: relay_inventory.ash
then the option to run it appears, which after doing so, mafia spams the Graphical CLI with:"Unexpected error, debug log printed." while writing to the debug log endlessly. It's up to 36 megabytes now.

I have made sure to enable user-scripted relay browser overrides.

If instead I just invoke the script by placing it /scripts and running it from the Scripts menu, I get just one "Unexpected error, debug log printed."

I would post the debug log, but the header clearly says not to post that to these threads. But here is the outermost stuff which I suppose is the most relevant.
Code:
Unexpected error, debug log printed.
class java.lang.NullPointerException: null
java.lang.NullPointerException
 

Theraze

Active member
It's supposed to go into relay... no rename or anything, just check the inventory with it in there and user-scripted relay overrides on.
 

Veracity

Developer
Staff member
Here is what MY header says:

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
KoLmafia v14.7 r9608, Mac OS X, Java 1.6.0_26
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Please note: do not post this log in the KoLmafia thread. If you
would like the 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 the log as an attachment.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Timestamp: Sat Jul 09 16:14:36 CDT 2011
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
I suppose it is a subtle distinction, but it says "Do not post this log in the KoLmafia thread" - THE Kolmafia thread being the one in G-D over on the KoL forums.

A few lines farther along, it says "please write a bug report at kolmafia.us. Include specific information about what you were doing when you made this and include the log as an attachment."

In other words, when reporting bugs on kolmafia.us, you are ENCOURAGED to attach debug logs.

That said, 36 MB is too big to attach. If you want to give us "the most relevant" part, you made a good start - you found the exception - but we need to see the rest of the stack trace. In other words, all the stuff with function names and file names and line numbers that follows what you included...
 

nema

New member
When I do that, I get no apparent effect. My character is in the proper path, but the items names are all just black text, b or no b.

I have to actually do something to invoke the script to get that error. No such error is generated by just placing it into the /relay folder. But here is what happens if I invoke it from the Scripts menu:
Code:
Unexpected error, debug log printed.
class java.lang.NullPointerException: null
java.lang.NullPointerException
	at net.sourceforge.kolmafia.request.RelayRequest.run(RelayRequest.java:1453)
	at net.sourceforge.kolmafia.RequestThread.postRequest(RequestThread.java:73)
	at net.sourceforge.kolmafia.textui.RuntimeLibrary.visit_url(RuntimeLibrary.java:1635)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at net.sourceforge.kolmafia.textui.parsetree.LibraryFunction.execute(LibraryFunction.java:126)
	at net.sourceforge.kolmafia.textui.parsetree.FunctionCall.execute(FunctionCall.java:166)
	at net.sourceforge.kolmafia.textui.parsetree.FunctionCall.execute(FunctionCall.java:104)
	at net.sourceforge.kolmafia.textui.parsetree.BasicScope.execute(BasicScope.java:451)
	at net.sourceforge.kolmafia.textui.parsetree.UserDefinedFunction.execute(UserDefinedFunction.java:129)
	at net.sourceforge.kolmafia.textui.parsetree.FunctionCall.execute(FunctionCall.java:166)
	at net.sourceforge.kolmafia.textui.parsetree.BasicScope.execute(BasicScope.java:451)
	at net.sourceforge.kolmafia.textui.parsetree.Conditional.execute(Conditional.java:94)
	at net.sourceforge.kolmafia.textui.parsetree.If.execute(If.java:67)
	at net.sourceforge.kolmafia.textui.parsetree.BasicScope.execute(BasicScope.java:451)
	at net.sourceforge.kolmafia.textui.parsetree.UserDefinedFunction.execute(UserDefinedFunction.java:129)
	at net.sourceforge.kolmafia.textui.Interpreter.executeScope(Interpreter.java:313)
	at net.sourceforge.kolmafia.textui.Interpreter.execute(Interpreter.java:245)
	at net.sourceforge.kolmafia.textui.Interpreter.execute(Interpreter.java:238)
	at net.sourceforge.kolmafia.textui.command.CallScriptCommand.call(CallScriptCommand.java:194)
	at net.sourceforge.kolmafia.textui.command.CallScriptCommand.run(CallScriptCommand.java:63)
	at net.sourceforge.kolmafia.KoLmafiaCLI.executeCommand(KoLmafiaCLI.java:544)
	at net.sourceforge.kolmafia.KoLmafiaCLI.executeLine(KoLmafiaCLI.java:418)
	at net.sourceforge.kolmafia.swingui.CommandDisplayFrame$CommandQueueHandler.handleQueue(CommandDisplayFrame.java:202)
	at net.sourceforge.kolmafia.swingui.CommandDisplayFrame$CommandQueueHandler.run(CommandDisplayFrame.java:183)
 
Last edited:

Veracity

Developer
Staff member
Enable relay overrides in Preferences/Browser - "Enable user-scripted relay browser overrides".
 

nema

New member
I solved the problem. It seemed it should work, so I created a fresh data store and indeed it worked fine.

Not wanting to lose important settings like bee window, cookie counters, etc, I did a grep on the new settings directory versus the old one.

The culprit was a residual -masterRelayOverride setting from stuff I tested last week. Once removed, the old settings files worked fine as well.
 
Top