Jump to content
  • 0

How to [delitem] a set number of items multiple times?


derpderpderp

Question


  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  9
  • Reputation:   0
  • Joined:  12/06/14
  • Last Seen:  

My script is currently a 1-click item exchanger breaking elemental stones back into ores, but I want to expand it to swapping multiple dead branches to bloody banches.

Atm, it's a case of doing '100 DBs -> 1 BB' one at a time, but I would like to have it exchange as many as possible in one go, eg. '320 DBs -> 3 BBs'. How can I make it do that, but only remove DBs in multiples of 100 and leave the remainder? So in that example, 320 DBs yields 3 BBs w/ 20 DBs still in inventory.

prontera,162,193,4	script	Vending Machine#vender01	564,{

setarray .@i[0],countitem(994),countitem(995),countitem(996),countitem(997),countitem(604);
	
	if (.@i[0] > 0 || .@i[1] > 0 || .@i[2] > 0 || .@i[3] > 0 || .@i[4] > 99)
	
		EL1:
			delitem 994,.@i[0];
			getitem 990,.@i[0]*5;
		
		EL2:
			delitem 995,.@i[1];
			getitem 991,.@i[1]*5;
		
		EL3:
			delitem 996,.@i[2];
			getitem 992,.@i[2]*5;
		
		EL4:
			delitem 997,.@i[3];
			getitem 993,.@i[3]*5;
		
		DB:
			delitem 604,100;
			getitem 12103,1;
		
}
Link to comment
Share on other sites

2 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  177
  • Reputation:   21
  • Joined:  01/31/12
  • Last Seen:  

.@total = countitem(994); // total number of Item ID 994

.@exchg = .@total / 100; //Floored division of total by 100 (e.g. 256 / 100 = 2)

.@remain = .@total % 100; //Remainder (e.g. 256 / 100 has remainder of 56)

delitem 944,(.@total - .@remain); //Remove all but the remainder

getitem 990,.@exchg; //Get total number of item id 990 = to floored division of total 994 (e.g. 256 --> 2)

something like that
  • Upvote 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...