trade response script Version 2, fixed and working.

Being a collector of sewer items, I need a trade auto response script because it gets quite tedious calculating the response amount, and responding all the time. I also buy other items sometimes, and i want to be able to add these items to my list when I am buying them, and remove them when I am not.

The format for adding items is:

price[item] = ### where ### can be any number -1 and above.
Code:
price[$item[meat paste]] = -1;
price[$item[meat stack]] = -1;
price[$item[dense meat stack]] = -1;
and they should be added inside void main() before the parse_trades(); command.

setting the price for an item to -1 tells the script to cancel the offer containing the item.
not setting a price for an item, or setting it to 0 tells the script to ignore offers containing this item, and you will handle it manually.

The script only buys items, it does not trade item for item, or sell items.

I have not tested this script yet, and would like for someone to double check it for errors before I do.

Presently it should cancel any offers containing only dense meat stacks, meat stacks, or meat pastes. Items to buy have not been added yet so it should leave any other offers alone.
 

Attachments

  • Traderesponse.ash
    3.9 KB · Views: 89
  • Traderesponse_ver2.ash
    4.5 KB · Views: 123

Nightmist

Member
Re: trade response script

Hey cool. I'm working on my own trade response script at the moment and looking at this, I really need to learn how to use "record" xD. (Currently mine just contains a mass of maps and is messy++)

Edit: Some of the mess is from my ItemDesc finding (Before I actually though of that "len" function I had to use a itemdesc to item map >>).

Edit2: Actually its a "item for item" based trade response script rather then the "item for meat" type you have here so that might also be a factor.
 

Veracity

Developer
Staff member
Re: trade response script

A quick comment: when I saw your "int Length( string theString )" function, I was inspired to add a new function to ASH. It's in 9.4, so is available to all:

int length( string s );

Look familiar? :)
 

Nightmist

Member
Re: trade response script

[quote author=Veracity link=topic=498.msg2471#msg2471 date=1160358474]
A quick comment: when I saw your "int Length( string theString )" function, I was inspired to add a new function to ASH. It's in 9.4, so is available to all:
[/quote]
Yay my function got added! (Yes my function... well very similar to it anyway... of course you probably came up with it earlier then I did... *sigh*)
Linky: http://kolmafia.us/index.php/topic,451.msg2376.html#msg2376

Oh and my trade script is almost ready for public release, just need to do some more testing and adding the "request item in trade note" type of trade and possibly "auto-delete offers"+"buy VarQty of items for meat" (Ideas stolen from you efilnikufecin >>).
Coming to a forums near you, soon, maybe, assuming no unexpected bugs//hitches.
Heh shameless advertising in someone elses thread >>.
 
Re: trade response script

[quote author=Veracity link=topic=498.msg2471#msg2471 date=1160358474]
A quick comment: when I saw your "int Length( string theString )" function, I was inspired to add a new function to ASH. It's in 9.4, so is available to all:

int length( string s );

Look familiar? :)
[/quote]

Nightmist gets all the credit for writing the "int Length( string theString )" with a slightly different name. I copied the function straight out of Nightmists link above, and the only change I made was the function name. His chosen name was "int Len( string theString )"

anyway, sadly this script does not work as expected. It's one of those error that you go "DOH!"

Code:
while(count != 11)
 {
 if(price[items_offered[count].offered] == 0)
  {
  print(items_offered[count].offered + " not in list of items to buy!");
  return false;
  }
 if(price[items_offered[count].offered] == -1)
  {
  visit_url("makeoffer.php?action=decline&whichoffer=" + substring(offerurl, length("counteroffer.php?whichoffer=")));
  return false;  
  }
 //payment_amount
 //calc_temp
 //finally we can start calculating the meat to pay.
 calc_temp = price[items_offered[count].offered] * items_offered[count].quant;
 payment_amount = payment_amount + calc_temp;
 count = count + 1;
 }

Great if you always get 11 items in a trade, but I don't so I get the error: "none not in list of items to buy!" I'm going to fix the script, but I'm going to use the new functions for parsing trades first. Life will be so much easier with them.

Thanks for the addition of a Length function veracity!
 

Nightmist

Member
Re: trade response script

[quote author=efilnikufecin link=topic=498.msg2474#msg2474 date=1160365898]
anyway, sadly this script does not work as expected. It's one of those error that you go "DOH!"
[/quote]
A quick fix of your script is after the first edits to count, this section:
Code:
 count = count + 1;
 }
//the next while loop uses count to know how many items to handle, but
Change it to,
Code:
 count = count + 1;
 }
 int TotItems = count-1;
//the next while loop uses count to know how many items to handle, but

Then at the
Code:
while( count != 11)
replace the 11 with TotItems, so:
Code:
while( count != TotItems)
Or something like that eh, all your plus and minus of count is semi-confusing to visualise >> (So maybe TotItems doesnt need the -1 or maybe it does... >> You get what im saying though hopefully, "Find the number of times to loop it and then only loop for that many times.")

Edit: Assuming thats the same script there, because the one I downloaded doesn't seem to have that added error message bit, just a return false.
 
Re: trade response script

it's the same script, I added the error message and a bunch of others trying to figure out why it would not reply to any trade offers.

as for count being hard to visualize:
the first count = count + 1; is inside a loop, which executes the addition 1 too many times. it's just counting at that point.
the first count = count - 1; fixes the 1 too many problem.
in the next while loop I just count backwards from where I left off in the first while loop(after fixing the 1 too many).
so it goes 0,1,2,3,4,5,6,7,8,9,10,11,10,9,8,7,6,5,4,3,1,0,-1
-1 is only used to stop second the while loop.
then I reset count to 0, and recycle the count variable and use it again.
then it goes 0,1,2,3,4,5,6,7,8,9,10,11 at 11 it is not used except to stop the loop, and that is where the error is. expecting 11 items every time.

[quote author=holatuwol link=topic=503.msg2446#msg2446 date=1160278830]
Code:
string response_text = visit_url( "messages.php?box=Inbox&begin=1" );

int mailed_meat = extract_meat( response_text );
int [item] mailed_items = extract_items( response_text );

foreach received_item in mailed_items
  print( received_item + ": " + mailed_items[received_item] + " received in total" );

print( "You gained " + mailed_meat + " meat." );
[/quote]

Holatuwol's usage of foreach in the above sample actually made me realize I was going about the whole thing the wrong way. I'm going to do a major re-write...that wont take near as long, or as many characters in the file.

Edit Version 2 is up, and working. Doesn't use foreach because it doesn't seem to want to work as needed.
 

radcliffe

New member
Could someone PLEASE explain me why doesen't the script refresh by itself???
I can't understand... I must alsways re-activate the script if I want to respond to a offer...




Please someone explain me... I would really need this script
 
The original intentions of this script were for it to be manually run while in chat when you see a trade offer notification. Making it loop is simple.

Start a new script.
Code:
While(true)
  {
  cli_execute("call traderesponse_ver2.ash");
  cli_execute("wait 120");
  }

Call it looped_response.ash or whatever.ash and save it in your scripts directory.

"wait 120" means wait for 120 seconds, or 2 minutes between executions. Adjust for your needs.
 

radcliffe

New member
Is there any way to make the prices uptade themselves? I mean like if I put for clovers 3.000 meat as the price is 3100 meat and then the price goes up to 4000 meat is there any way for it to uptade automaticly to 3900 meat? If anyone can tell me I'll pay 1 mil meat ^_^ or if you think your work worthes more we'll talk a good price...
 
Determining mall prices of items is impossible within a kolmafia script. This script is also not very suited to your needs as it wasn't meant to be used to buy items, then re-sell them, but to simply buy them.

My whole reason for writing this script was because I got tired of miscalculating the amount to respond with when people were selling me their sewer items. I did not have the problem of changing mall prices because I didn't car if a Disco ball was worth 1mil each in the mall, I was only going to pay 75 for one, and it would go into my DC and rot.
 
Top