Trick-Or-Treating script

guyy

Member
I have Win8 and Java 1.8.0_25-b18, which also has no problem with ampersands. Firefox and IE both work.

There's probably not much I can do about this, since it seems to be a Java bug and I can't reproduce it. The outfit list isn't that useful of a feature anyway. If you want to know what to farm, the answer is dubious peppermints. (Everything else is worthless, rarely gets purchased, or both. Maybe plexi-pips if you have the outfit and a lot of patience.)
 

Bale

Minion
I tested it and I'm also getting only part of the URL.

Windows XP, Java 1.7.0_55-b13 :confused:

I have no idea why it works for some and not others.
 

Theraze

Active member
Well, the people who have reported problems seem to all be on Java 1.7, while guyy is on 1.8, so...

But then that breaks down when yours doesn't work and lost's does. Since you're both on the same Java 1.7.55 version. So blah.
 

guyy

Member
Very weird. Surely there are other scripts trying to print_html a URL with ampersands?

...Er... maybe not. I can't find one, anyway. Maybe that's why this wasn't noticed before.

If I replace them with & it still works. Does that change anything for the people it's not working for? The browser might be correcting an error or something.

Code:
prices[pricey] = "<a href=\"http://kol.coldfront.net/newmarket/itemgraph.php?itemid="+ahtem.to_int()+"&timespan=1&noanim=0\">" + ahtem.to_string() + "</a> (" + group(data,2) + ((group(data,2)=="Cold Comforts")?" + Russian Ice":"") + ")";
 
... replace them with & it still works. Does that change anything for the people it's not working for? ...

Nope, that was one of the first things I tried, playing around with HTML entity encoding. © embedded in the URL will output as expected (resolved into the character it refers to first), but & apparently is resolved to &, and then the weird stuff happens. Chaining entities (&amp; ) doesn't help either.

What's behind print_html() ?
 

Veracity

Developer
Staff member
Considered using

string url_encode( string )

whose purpose is to encode a string "correctly" for use as a URL. Which is not the same as entity_encoding it - which is the function you'd use if you wanted & in place of &.
 

guyy

Member
url_encoding it gives

Code:
http://127.0.0.1:60080/http%3A%2F%2Fkol.coldfront.net%2Fnewmarket%2Fitemgraph.php%3Fitemid%3D6405%26timespan%3D1%26noanim%3D0

which my browser doesn't understand. Taking out the "http://127.0.0.1:60080/" gives "Server Not Found." If I just use %26 for the ampersands I get coldfront's "Oops! Invalid parameters" message.

Those seem to be for when you want an ampersand or something but don't want it treated as a URL or PHP character, like "place.com?name=blah%26blah". If something's trying to decode it twice, maybe this would help? But for me it just breaks it. The weird thing is that the ampersands aren't just jumbled, it's apparently erasing everything after the first ampersand (but only for some people).

Code:
prices[pricey] = "<a href=\"http://kol.coldfront.net/newmarket/itemgraph.php?itemid="+ahtem.to_int()+url_encode("&")+"timespan=1"+url_encode("&")+"noanim=0"+"\">" + ahtem.to_string() + "</a> (" + group(data,2) + ((group(data,2)=="Cold Comforts")?" + Russian Ice":"") + ")"
 

Veracity

Developer
Staff member
I think you misunderstood what I meant.

You do not url-encode the entire data string, which has multiple fields separated by ampersands. You NEED those ampersands.
You url-encode individual fields that might contain ampersands. So, if you wanted a field named "message" with the value "this & that", you would have to url-encode "this & that", so that you end up with "message=this+%26+that"

Actually, your "blah%26blah" example shows that you did get what I meant. Although, you didn't seem to realize that I meant what I meant. ;)
 
FYI, updated java to Java 1.8.0_31, url portion after ampersand is still removed. (r15454)

Also, Preferences -> General -> Extra Debugging -> Verbosely log communications between Kolmafia and browser no longer logs http comms.

Strange stuff.
 

coandco

Member
I've got a quick fix here -- the outfit-gathering regex broke, so I fixed it. This line:
Code:
matcher data = create_matcher("Item Drops:</b> <a href=[^>]*>([^<]*?)</a>.*?</li><li><i>Note:</i> Only occurs [^>]*>([^<]*?)</a>", stuff);

Needs to change to this:
Code:
matcher data = create_matcher("Item Drops:</b> <a href=[^>]*>([^<]*?)</a>.*?</li>[^<]*<li><i>Note:</i> Only occurs [^>]*>([^<]*?)</a>", stuff);

With the new regex, "tricktreat outfits" once again works as intended.
 

Lord_Kobel

Member
"tricktreat outfits" is giving me a warning that stuff doesn't sell, but that's it. No prices or links to graphs or anything...
 

Crowther

Active member
"tricktreat outfits" is giving me a warning that stuff doesn't sell, but that's it. No prices or links to graphs or anything...
Items that are in the mall at the mall minimum are ignored. If I run this script in run (just four outfits), I get nothing like you. Out of run, it lists things.
 
I setup libramBurn.ash as my betweenbattlescript to use the mp from my newblock outfit, but it's not working as I hoped, and I hoped my fix might be helpful for others:

To be exact, what it does it switch to newblock, scout out a newblock (generating a load of mp), and it then switches to trick (or treat) before trying to use the betweenbattle script. This wouldn't be much of a problem, except I specifically gave my newblock outfit a load of max mp as well as mp regen, so after switching back I lose a load of MP because my max goes down.
I fixed it by manually adjusting the script, to call the post_combat_junk() right after opening a new block. (effectively adding two brackets and that commands into the if-clause on line 214).
 

Malibu Stacey

Active member
"tricktreat outfits" is giving me a warning that stuff doesn't sell, but that's it. No prices or links to graphs or anything...

Works fine for me:

Code:
118 meat -- nasty gum (Toxic Togs)
147 meat -- Take Eleven Bar (Xiblaxian Stealth Suit)
187 meat -- Northern pemmican (Frigid Northlands Garb)
195 meat -- pile of candy (Pinata Provisions)
201 meat -- fry-oil-flavored Hob-O (Tawdry Tramp Togs)
201 meat -- Angry Farmer's Wife Candy (Tapered Threads)
201 meat -- crude crudités (Oil Rig)
201 meat -- Shrubble Bubble (Topiaria)
201 meat -- Spechunky bar (Spelunker's Gear)
201 meat -- strawberry-flavored Hob-O (Dire Drifter Duds)
202 meat -- Elvish delight (Pork Elf Prizes)
206 meat -- candied kobold (Yendorian Finery)
245 meat -- sterno-flavored Hob-O (Pyretic Panhandler Paraphernalia)
300 meat -- double-ice gum (Cold Comforts + Russian Ice)
400 meat -- toothbrush (Terrycloth Tackle)
420 meat -- herb brownies (Filthy Hippy Disguise)
499 meat -- warbear whosit (Warbear Dress Armor)
500 meat -- chocolate filthy lucre (Bounty-Hunting Rig)
674 meat -- black pepper (Black Armaments)
686 meat -- Good 'n' Slimy (Slimesuit)
695 meat -- pawn cookie (Knight's Armor)
969 meat -- Mer-kin saltmint (Mer-kin Gladiatorial Gear)
1000 meat -- roll of Hob-Os (Hodgman's Regal Frippery)
1500 meat -- Boss Drops (Raiments of the Final Boss)
1850 meat -- Mer-kin saltsquid (Mer-kin Scholar's Vestments)
4111 meat -- dubious peppermint (Wumpus-Hair Wardrobe)
6250 meat -- worst candy (Hateful Habiliment)
6500 meat -- chocolate disco ball (Legendary Regalia of the Groovelord)
WARNING: Many candies are rarely actually bought, regardless of mall price. Check Coldfront's sales graphs (linked above) to avoid farming up something that won't sell.

I can't actually wear the Hateful Habiliment as I can't equip Chefstaves as DB but it still checked it.
 

Crowther

Active member
As you can see above, chocolates from your legendary regalia are often a good choice. They actually sell in the mall.
 
Now that the trick-or-treating tot doubles candy drops from the 'light' houses, a change that automatically uses the tot when using the treat outfit could be a great addition. (I made change to my personal script, but I have no idea how to make it a general update)
 

lostcalpolydude

Developer
Staff member
I think the simplest way to change it would be to have trick_outfitname and treat_outfitname, with default values of "trick" and "treat" to preserve backward compatibility while allowing people to change it if desired. Then people can have f=tot as part of their outfit name.
 
Hmm, that could work, though for myself I just added in 4 lines, one to save whichever familiar I have with me, one to switch to the tot and one to switch to the previous familiar. (with linenumbers)

Code:
62	familiar fam = my_familiar();
83			use_familiar(fam);
233			use_familiar(fam);

244			if have_familiar($familiar[Trick-or-Treating Tot]) use_familiar($familiar[Trick-or-Treating Tot]);

Edit:
Figured I might as well put my new version as an attachment, in case other people want to use it today (tested for exactly one block, because I haven't actually got to playing my turns).
 

Attachments

  • tricktreat.ash
    8.1 KB · Views: 69
Last edited:
Top