Guild Donation

Additional botting resources. Addons may be either for the game itself or for the RoM bot.
Forum rules
Only post additional bot resources here. Please do not ask unrelated questions.
Message
Author
Rickster
Posts: 291
Joined: Sun Oct 24, 2010 4:23 pm

Re: Guild Donation

#21 Post by Rickster » Fri Mar 09, 2012 10:13 am

rock5 wrote:My pet peave. You're like Lisa. You don't indent properly. Grrrr.
hm strange. I use notepad++ as editor and all is well indent :(
Last edited by Rickster on Tue Mar 13, 2012 12:22 am, edited 1 time in total.

Rickster
Posts: 291
Joined: Sun Oct 24, 2010 4:23 pm

userfunction_GuildDonate - new version 1.43

#22 Post by Rickster » Fri Mar 09, 2012 10:22 am

As the itemtypes table seems to work for non german clients too, i release the next version as stable.

Lisa you are welcome to update first post with it.

Changelog v1.43
  • variable "item" is local now
  • extra MM status messages are not shown any more and moved to debug mode
userfunction_GuildDonate.lua
Version 1.43
(3.8 KiB) Downloaded 194 times

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Guild Donation

#23 Post by rock5 » Sat Mar 10, 2012 3:14 am

With those 2 changes I'm happy.
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Guild Donation

#24 Post by lisa » Mon Mar 12, 2012 10:35 pm

Should look at making it so if arg1 is nil then it defaults to all
•arg1 is the type of resource "ore", "wood", "herb" or "all"
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

Rickster
Posts: 291
Joined: Sun Oct 24, 2010 4:23 pm

Re: Guild Donation

#25 Post by Rickster » Tue Mar 13, 2012 12:21 am

hm, sure we can make it so that nil defaults to "all" for downward compatibility.

but i am not sure if it is really ok, because nil is something undefined, and for whatever reason someone uses nil and all his ressources are gone (to guild :D)

i just found your suggestions in the AT thread and hijacked it to here ;)
rock5 wrote:
lisa wrote:With the new version of guild donate also had to change nil to "all"
So ("all",8)
I might mention it in the userfunction topic, if it's nil then it should be assumed to be all.
So nil doesn't work anymore? It doesn't default to "all"? Hm... shouldn't it?

Maybe, this

Code: Select all

	if ( _type == nil and _quality == nil and _lesser == nil ) then 
		_lesser = "true"
		_type = "all"
		_quality = 15
	end
should be

Code: Select all

	if _type == nil then _type = "all" end
	if _quality == nil then _quality = 15 end
	if _lesser == nil then _lesser = "true" end

Anyway, with the new version of GuildDonate we could just use

Code: Select all

GuildDonate()
My idea for using GuildDonate() is, to donate everything possible to guild.
If the user wants something specific, he cleary has to tell the function what he wants ... nil is not very specific ;)
But in the end it is up to you. We can easyly get this behaviour back.

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Guild Donation

#26 Post by lisa » Tue Mar 13, 2012 1:28 am

that is fine if all arg's are nil but in the AT example we want to do all of quality 8

("all",8)
but you could do
(nil,8)

much of a muchness really.
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Guild Donation

#27 Post by rock5 » Tue Mar 13, 2012 1:33 am

I'm for nil meaning "all". (Actually I changed my mind by the end of the post, sort of. Read on.)

You have to think about the way people will use it. If someone is harvesting resources and processing them to green, they wont forget the add "green". So they would use

Code: Select all

GuildDonate("all","green",false)
or

Code: Select all

GuildDonate("herb","green",false) 
or whatever resource they are doing or

Code: Select all

GuildDonate(nil,"green",false)
In this case I can't imagine a user accidentally donating resources they didn't mean to (unless they forget the "false").

While other users might be opening packages with resources in them and just want to donate them all. You don't want to have to make them enter values. They should just be able to type.

Code: Select all

GuildDonate()
The only situation I can see users accidentally donating items is if they do something like this

Code: Select all

GuildDonate(ore,"green",false)
ore would be nil so it would donate all types.

Actually, on second thought, besides the case of just "GuildDonate()", I don't see any need to default nil to "all". After all, if you are going to type nil, you can just type "all" instead. And it is a bit safer. So basically, if there is a value for _quality or _lesser, then require a value for _type.

Other comments:
  • Probably _lesser should have a default value. At the moment if all 3 are nil it defaults to true but if _type and _quality are specified then _lesser effectively defaults to false, which is not what I think is intended.
  • I don't think this part would work.

    Code: Select all

    	if ( _type == "white" or _type == "green" or _type == "blue" or _type == "purple" ) then _quality = _type end
    I understand what is intended but it copies _type to _quality but leaves _type as it is. Probably it should be.

    Code: Select all

    	if ( _type == "white" or _type == "green" or _type == "blue" or _type == "purple" ) then _quality = _type _type = "all" end
  • Maybe we should look into donating other items as well? Such as "Guild Stones", "Guils Runes" and "Guild Rubies". Is there anything else? Shouldn't be hard to do. Just add

    Code: Select all

    if _type == "stone" then
    etc. Probably the only other argument needed for these are the number you want to send. So _quality would have to be able to stand in as a variable for how many you want to send.
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Guild Donation

#28 Post by rock5 » Tue Mar 13, 2012 1:45 am

Scratch my comments about _lesser. Didn't understand it properly. It's fine as it is.
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

dx876234
Posts: 188
Joined: Sat Jul 24, 2010 6:13 am

Re: Guild Donation

#29 Post by dx876234 » Mon Oct 01, 2012 11:35 am

I added option to donate any item in backpack by name or id, ex:

Code: Select all

GuildDonateItems({"Guild Stone", "Guild Rune", "Handcrafted Ruby"})
-dx
Attachments
userfunction_GuildDonate.lua
(3.92 KiB) Downloaded 171 times

Cindy
Posts: 237
Joined: Fri Sep 28, 2012 4:23 pm

Re: Guild Donation

#30 Post by Cindy » Fri Nov 09, 2012 8:48 am

Code: Select all

GuildDonateItems({"Guild Stone", "Guild Rune", "Handcrafted Ruby"})
resulted in

Code: Select all

Did not find any crashed game clients.
7:46am - scripts\rom/bot.lua:824: Failed to compile and run Lua code for waypoint #2

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Guild Donation

#31 Post by rock5 » Fri Nov 09, 2012 9:05 am

A compile error means some sort of syntax error. I can't see anything wrong with that line so maybe you changed something else.
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

Cindy
Posts: 237
Joined: Fri Sep 28, 2012 4:23 pm

Re: Guild Donation

#32 Post by Cindy » Fri Nov 09, 2012 9:10 am

rock5 wrote:A compile error means some sort of syntax error. I can't see anything wrong with that line so maybe you changed something else.
Yes, I believe so, was just debugging, can't figure out how to delete my post :)

Cindy
Posts: 237
Joined: Fri Sep 28, 2012 4:23 pm

Re: Guild Donation

#33 Post by Cindy » Fri Nov 09, 2012 9:22 am

Yes it was a bug in my code. Now that its fixed, this function runs well, listing the items I have:

Code: Select all

GuildDonateItems({"Guild Stone", "Guild Rune", "Handcrafted Ruby", "Magic Fortune Grass", "Moonlight Pearl", "Sunset Ear of Grain"})

Code: Select all

Name Moonlight Pearl at 132
Name Sunset Ear of Grain at 111
Name Magic Fortune Grass at 149
However, it didn't actually donate, the items are still in the bag. I've also tried with the donation window already open, same result.

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Guild Donation

#34 Post by rock5 » Fri Nov 09, 2012 10:00 am

They are all mini game rewards, right? Do you have problems donating anything else?
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

Cindy
Posts: 237
Joined: Fri Sep 28, 2012 4:23 pm

Re: Guild Donation

#35 Post by Cindy » Fri Nov 09, 2012 10:31 am

Yes, they come from mini game AT. I specifically want the donate function for those (and guild runes/stones but i don't have any of those to test with). The materials, I produce what I need and use what I need, so there is no systematic donation needed for me for those.

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Guild Donation

#36 Post by rock5 » Fri Nov 09, 2012 11:05 am

Cindy wrote: The materials, I produce what I need and use what I need, so there is no systematic donation needed for me for those.
Yes but you could test with those. Just harvest something and donate it using the commandline. Example I collected 1 Dragon Mallow and this worked for me.

Code: Select all

        RomBot command line
Type in 'q' (without quotes) to quit.
Command> GuildDonateItems({"Dragon Mallow"})
Name Dragon Mallow at 73
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

Cindy
Posts: 237
Joined: Fri Sep 28, 2012 4:23 pm

Re: Guild Donation

#37 Post by Cindy » Sat Nov 24, 2012 5:40 pm

Its these items

for example:
Nigthmare Essence (Andor drop)
Magic Fortune Grass (AT drop)

I ran some command line tests, and the position it gives for item.BagId does not seem to match where I have the item. I even added an inventory:update() (the developer of GuildDonateItems() didn't, this may be an issue).

I put items in the firt row of my third bag, here are the item numbers i got for them :

Command> inventory:update()
Command> GuildDonateItems({"Nightmare Essence"})
Name Nightmare Essence at 143
Command> GuildDonateItems({"Magic Fortune Grass"})
Name Magic Fortune Grass at 144
Command> GuildDonateItems({"Guild Rune"})
Name Guild Rune at 139
Command> GuildDonateItems({"Magic Fortune Grass"})

Seems off that third bag first slot is ID 143, third bag 2nd slot is ID 144 (at least sequential to first slot item), and third bag fifth slot is 139, which is neither sequential (would have been147) nor sensical.

At any rate, none of them actually got donated, including the Guild Runes

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Guild Donation

#38 Post by lisa » Sat Nov 24, 2012 7:45 pm

Cindy wrote:I even added an inventory:update() (the developer of GuildDonateItems() didn't, this may be an issue).
line 10 has

Code: Select all

inventory:update()
Cindy wrote:Seems off that third bag first slot is ID 143, third bag 2nd slot is ID 144 (at least sequential to first slot item), and third bag fifth slot is 139, which is neither sequential (would have been147) nor sensical.
have a look at the pics down the bottom of this link, it might explain why the numbers are weird.
http://www.theromwiki.com/API:UseBagItem
Cindy wrote:At any rate, none of them actually got donated, including the Guild Runes
So it is finding the items but isn't donating them?
Cindy wrote:Name Guild Rune at 139
I can't find that print in the code anywhere, what version are you using???
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

Cindy
Posts: 237
Joined: Fri Sep 28, 2012 4:23 pm

Re: Guild Donation

#39 Post by Cindy » Sat Nov 24, 2012 10:51 pm

I was using the command line testing the donation function.

Cindy
Posts: 237
Joined: Fri Sep 28, 2012 4:23 pm

Re: Guild Donation

#40 Post by Cindy » Sat Nov 24, 2012 10:56 pm

And yes, the items are found, but then its not donated.

This is the code im using (downloaded from one of the threads here) :

Code: Select all

-- =============================================
-- Joint effort by the solarstrike/rom dev team
-- and Rickster
-- Version 1.43 (03.09.2012 / mm.dd.yyy)
-- last edited by: Rickster
-- =============================================

local function GuildDonateBagID(bagid)
	RoMScript("PickupBagItem("..bagid..")")
	RoMScript("GCB_GetContributionItem(n)")
	if RoMScript("CursorHasItem()") then
		RoMScript("PickupBagItem("..bagid..")")            -- Put it back in the bag
	else
		RoMScript("GCB_OnOK()")
	end
end

function GuildDonateItems(itemlist)
	for slot = 61, 240 do
		item = inventory.BagSlot[slot]
		for k, nameid in pairs(itemlist) do
			if item.Name == nameid or item.Id == nameid then
				cprintf(cli.yellow, "Name %s at %d\n", tostring(nameid), item.BagId)
				GuildDonateBagID(item.BagId)
			end
		end
	end
end

function GuildDonate(_type, _quality, _lesser)
	inventory:update()	
	local oreTypeName	= itemtypes[3][0].Name
	local woodTypeName	= itemtypes[3][1].Name
	local herbTypeName	= itemtypes[3][2].Name
	local donated = false;
	local local_debug_mode = false;
		
	if ( _type == nil and _quality == nil and _lesser == nil ) then 
		_lesser = "true"
		_type = "all"
		_quality = 15
	end



	-- argument fool proofing
	if ( _type == "white" or _type == "green" or _type == "blue" or _type == "purple" ) then _quality = _type end

	-- _lesser if "true" then lesser qualities will be donated, otherwise only specified quality will be donated.

	-- for _quality use names "white", "green", "blue", "purple", "orange", "gold".

	if _quality == "white" then _quality = 0
	elseif _quality == "green" then _quality = 1
	elseif _quality == "blue" then _quality = 2  
	elseif _quality == "purple" then _quality = 3 
	elseif _quality == "orange" then _quality = 4 
	elseif _quality == "gold" then _quality = 5  
	elseif (type(_quality) == "number" and (_quality >= 0 and 15 >= _quality)) then 
		-- _quality is given as a number between 0 and 15
	else 
		error("Error in function call GuildDonate(_type, _quality, _lesser), check \"_quality\"!",0);
	end
	if local_debug_mode then
		cprintf_ex("|purple| DEBUG: Donate quality is set to: %s.\n", _quality)
		player:sleep();
	end;

	if (_type == "wood" or _type == "woods") then _type = woodTypeName
	elseif (_type == "ore" or _type == "ores") then _type = oreTypeName
	elseif (_type == "herb" or _type == "herbs") then _type = herbTypeName
	elseif (_type == "all" or _type == "All") then _type = "all" 
	else 
		error("Error in function call GuildDonate(_type, _quality, _lesser), check \"_type\"!",0);
	end
	if local_debug_mode then
		cprintf_ex("|purple| DEBUG: Donate type is set to: %s.\n", _type)
		player:sleep();
	end;
	
	if local_debug_mode then
		cprintf_ex("|purple| Donating %s to guild ...\n", _type);
	end;

	local item;
	for slot = 61, 240 do
		item = inventory.BagSlot[slot];
		if ( _type == "all" and (item:isType(woodTypeName) or item:isType(oreTypeName) or item:isType(herbTypeName)) ) or ( _type ~= "all" and item:isType(_type) ) then
			if  _lesser == "true"  then -- Donates quality stated and lesser
				if _quality >= item.Quality then
					local itemtype, itemsubtype, itemsubsubtype = item:getTypes()
					cprintf_ex("|lightgreen| Donating  %s %s (%s) ...\n", item.ItemCount, item.Name, itemsubtype)
					if local_debug_mode then player:sleep(); end;

					GuildDonateBagID(item.BagId)
					donated = true;
				end
			elseif _quality == item.Quality then
				local itemtype, itemsubtype, itemsubsubtype = item:getTypes()
				cprintf_ex("|lightgreen| Donating  %s %s (%s) ...\n", item.ItemCount, item.Name, itemsubtype)
				if local_debug_mode then player:sleep(); end;
				
				GuildDonateBagID(item.BagId)
				donated = true;
			end
		end
	end
	if not donated then
		cprintf_ex("|lightgreen| There was nothing to donate to the guild.\n");
	end;

	if local_debug_mode then
		cprintf_ex("|purple| Donation finished.\n");
	end;
end

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest