Closed kyri0 closed 8 years ago
Sadly there is no way, at least not one i could find, to easily determine the type of an item, and for the buyout the only solution i can come up with is
function setupWtbMessage(item) {
// Look at class SearchResultItem in file SearchPageScraper.java
// for more variable to use
// vanilla js doesn't have format function :(
if(item.buyout == ""){
var wtbTemplate = '@%s Heyo! I\'d like to buy your %s, quality %s, level %s listed in %s'
var wtb = java.lang.String.format(
wtbTemplate,
item.ign,
item.name,
item.quality,
item.level,
item.league
)
}else{
var wtbTemplate = '@%s Heyo! I\'d like to buy your %s, quality %s, level %s listed for %s in %s'
var buyout = item.buyout
if (item.guildItem()) {
buyout = java.lang.String.format(
"%s (less %s guildmate discount)",
item.buyout,
item.guildDiscount())
}
var wtb = java.lang.String.format(
wtbTemplate,
item.ign,
item.name,
item.quality,
item.level,
buyout,
item.league
)
}
item.wtb(wtb)
}
unless there is away to use conditions inside a function parameters this the only way to do the optional buyout part
Thanks, man!
not a problem and if you can come up with a creative way of identifying gems , please share
i think i found a way
The only way I can think of is by item type, or simply making it in a way that it would always show the quality and lvl of any item.
the way i found uses a unique property of gems and maps alike, they have a level listed on poe.trade, where as every other item does not
Okay, as soon as you figure this out, i'll merge it to the master branch.
is there any map that does not include the name map in it?
so after first believing i was going mad, because the function behaved in no way like it should, and i figured out that i somehow managed to duplicate the function, confirming that every map includes the Term "Map" in its name and that only maps and gems have a lvl listed on poe.trade.
I can now proudly present the function you asked for with no exceptions:
Yes, every map has 'map' in its name.
So, I tried it out here, but when I look for a gem, it gives me this error: EDIT:Actually it only occurs if I try to search for glvl and quality along with the name of gem. Ex.: bladevortex q20 glvl20
An error has occurred in thread #32: SwingWorker-pool-3-thread-7; please find details below:
java.util.MissingFormatArgumentException: Format specifier '%s'
at java.util.Formatter.format(Unknown Source)
at java.util.Formatter.format(Unknown Source)
at java.lang.String.format(Unknown Source)
at jdk.nashorn.internal.scripts.Script$Recompilation$51$592A$\^eval\_.setupWtbMessage(<eval>:43)
at jdk.nashorn.internal.scripts.Script$Recompilation$50$276AA$\^eval\_.process(<eval>:24)
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:644)
at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:228)
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393)
at jdk.nashorn.api.scripting.ScriptObjectMirror.callMember(ScriptObjectMirror.java:199)
at jdk.nashorn.api.scripting.NashornScriptEngine.invokeImpl(NashornScriptEngine.java:383)
at jdk.nashorn.api.scripting.NashornScriptEngine.invokeFunction(NashornScriptEngine.java:190)
at qic.util.FmJS.process(FmJS.java:58)
at qic.Main.processLine(Main.java:172)
at qic.ui.ManualPanel.runQuery(ManualPanel.java:228)
at qic.ui.ManualPanel.lambda$null$53(ManualPanel.java:149)
at qic.ui.extra.Worker.doInBackground(Worker.java:21)
at javax.swing.SwingWorker$1.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at javax.swing.SwingWorker.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
okay, just tried your example and i do not get any errors with the version i posted here, mind posting your function maybe there is a problem with your version
I used the one you posted on this thread
found the problem, and also why you could find it and i could not first, the problem i forgot to update the WTB template for items with no buyout. Second because I always exclude items without buyout it did not happen for me updated the version the the pull request
Oh, ok, so, what's the correct one?
var wtbTemplate = '@%s Heyo! I\'d like to buy your %s listed in %s'
is the correct version
Perfect, works now.
I'll just change the default message back to the one used by poe.trade, thanks a lot!
I don't know yet how to do this on my own, so i'm asking your guys help.
I'd like to the WTB message to have more 'ifs'. For example, it would only show the 'listed for x' if it had an actual buyout. Another thing I wanted it to show as an 'if' would be the quality and the lvl, in case it was a gem.
My current WTB message is the following: