PDA

View Full Version : Script request: Sort by value



droit
05-26-2016, 01:26 PM
Would someone mind slapping together a script that will sort a particular item by value? I'd like to be able to specify a noun in container 1 and specify an appraisal value (at gemshop/furrier), and have the script appraise each item and put items that are below the specified value in container 2 and items above the specified value in container 3.

Say I have 10 goblin skins in my cloak. I could ';sortvalue skin 50' and it would appraise each skin and put ones worth <50 in my sack and ones worth >50 in my backpack. I'd like for it to work at both the furrier and the gemshop.

Thanks in advance!

Ososis
05-26-2016, 03:47 PM
I know this isn't exactly what you are asking for, but its what I have on hand. It sorts skins based on quality, saving fair and better for bounties, puting poor and crude in my harness to be sold off. Since it's not based on siver values it will NOT work while standing inside the furrier
Things to edit:
b back=original container
longc=good quality container
harn=bad quality container


put open my b back
loop:
put get %1 from b back
appraise:
matchre badskin /(crude|poor) quality/
matchre goodskin /(fine|fair|superb|exceptional|outstanding|magnific ent) quality/
match appraise is in decent shape.
match appraise ...wait
put appraise my %1
matchwait

badskin:
wait 1
put put my %1 in my harn
goto loop

goodskin:
wait 1
put put my %1 in my longc
goto loop


Gnomad
05-26-2016, 04:05 PM
Jara just wrote a script like this, hardcoded for gems and 3500 silvers. Should be easy enough to modify. I think it's called jsort.

zennsunni
05-26-2016, 04:19 PM
I modified this script that I found in the repository to do this, works great. You just have to change your variables before you run it. You can glance at the script to check, but I think currently it puts gems OVER the number in the argument back in your gemsack, and ones under the argument in your lootsack. Cheers, and don't thank me, thank Cathrais, I barely changed anything in this script, which I believe is called gemsorter.lic in the repo.


=begin

Script: gemsorter
Author: Caithris
Creation Date: 2/20/2013
Description: Down dirty gem sorting.

=end

if script.vars[0].nil?
respond "Please enter cutoff level to put in your LOOTSACK."
respond "example:"
respond "gemseller 2000 (sell all gems below 2000 appraisal value)"
respond ""
exit
elsif script.vars[0] =~ /help/
respond "gemseller. Sells your cheap gems."
respond ""
respond "Usage: ;gemseller <cutoff value>"
respond ""
exit
end
if UserVars.gemsack.nil? or UserVars.gemsack.empty?
echo 'error: gemsack is not set. (;set change gemsack <container name>)'
exit
end
start_script("go2", ["gemshop"])
wait_while { running? "go2" }
empty_hand
GameObj.inv.find {|sack| if sack.name=~/#{UserVars.gemsack}/ then sack.contents.each{|gem| if gem.type=="gem" then fput "get ##{gem.id}"; fput "appraise ##{gem.id}"; value=matchfind "you ? for it if you want to sell"; if value.to_i <= script.vars[0].to_i then fput "put ##{gem.id} in my #{UserVars.lootsack}"; else fput "put ##{gem.id} in ##{sack.id}"; end; end; } end;}
fill_hand

droit
05-26-2016, 11:34 PM
That's close. How would I modify that to be able to specify one particular noun rather than check all gems in the container?

zennsunni
05-27-2016, 02:32 AM
Uhhh, you'd have to iterate through the contents of the gemsack differently, based on a match by that noun rather than the item type. Not really sure how to do it, but it should be pretty easy.