Page 1 of 3

Guild Donation

Posted: Wed Feb 09, 2011 7:06 am
by lisa
V 1.43 done by Rickster

I did an update to lisas userfunction.
The idea was, to make the function work, independant from localisation and is based on the idea that itemtypestable.lua is build independant from localised clients ... please report, if this is not.

I tested this version on a german client. As I am not very good in things like coding and testing, this version is released as beta. Please feel free to report any bugs.
The main benefit goes to rock5 and lisa, who helped me in other threads on questions regarding to this topic.

It mainly contains lisas code with following changes:
  • using itemtypestable.lua for localised names
  • searches only backpacks 1-6 for ressources
  • donates woods, ores, herbs
  • minor changes for checking _type and _quality
For usage instructions I will mainly quote lisas first post:

This is a userfunction created for the purpose of donating gathered resources to your guild, inluding quality 8 guild resources from mini games.
It does not cover guild runes / guild stones / guild rubies, it is purely for herb / ore / wood.

Usage:

Code: Select all

	GuildDonate(arg1, arg2, arg3)
  • arg1 is the type of resource "ore", "wood", "herb" or "all"
  • arg2 is the quality "white"(0), "green"(1) "blue"(2), "purple"(3), "orange"(4), "gold"(5)
    You can also use numbers from 0-15 without quotes.
    To use mini game resources use 8 witout quotes.
  • arg3 is if you want to also donate lesser quality "true", defaults to "false"
arg1 and arg2 are mandatory in conjunction!!! You cant use one without the other!
This is, because users have to be sure what they want to donate!

Examples

Code: Select all

GuildDonate()
equals

Code: Select all

GuildDonate("all", 15, "true")
Donates all resources up to quality 15. This includes all ressources, also the mini game resources.

Code: Select all

GuildDonate("ore", "green")
Will donate all Ore of green quality only.

Code: Select all

GuildDonate("herb","blue","true")
Will donate all Herbs of blue & green & white quality.

Code: Select all

GuildDonate("all", "green")
Will donate all resources of green quality only.
userfunction_GuildDonate.lua
V 1.43 by Rickster
(3.79 KiB) Downloaded 375 times
Ric

V 1.44 again by Rickster
same old functions plus added a new function with a table as argument.
example.

Code: Select all

GuildDonateItems({"Guild Stone", "Guild Rune", "Handcrafted Ruby"})
userfunction_GuildDonate.lua
V 1.44 by Rickster
(3.94 KiB) Downloaded 309 times

Re: Guild Donation

Posted: Thu Feb 10, 2011 9:07 am
by lisa
Fixed an error that made the quality always be "white"

Re: Guild Donation

Posted: Thu Jun 09, 2011 2:33 am
by rock5
I found a bug.

I finally started using this addon. I added it to my logar crafting script. I added "GuildDonate("herb", "green")", "GuildDonate("ore", "green")" and "GuildDonate("wood", "green")" after the relevant crafting.

It didn't donate just the resource specified. It donated all. The problem is line 34. It should be.

Code: Select all

	if _type ~= "Herbs" and _type ~= "Wood" and _type ~= "Ores" then _type = "all" end

Re: Guild Donation

Posted: Tue Jun 21, 2011 1:47 am
by lisa
weird I thought I fixed that ages ago, I must have not changed it when I did the last version =(

All fixed now, thanks

Re: Guild Donation

Posted: Tue Feb 14, 2012 3:16 pm
by Germangold
hey lisa
unfortunately your functions doesnt work anymore for me

Re: Guild Donation

Posted: Wed Feb 29, 2012 11:22 am
by rock5
Does this function still work. Tried to use it today, didn't work.

Edit: Never mind. It works. The resources I was trying to contribute were quality 8. The function defaults to quality 5 or below. So this worked,

Code: Select all

GuildDonate(nil,8)

Re: Guild Donation

Posted: Mon Mar 05, 2012 1:38 pm
by Rickster
I have a problem getting this function to work. The file is corectly placed, wehre the other userfunctions are, too.

i use this code iin the wp file

Code: Select all

GuildDonate("all", "purple");
it is completly overrun, no windows open, no mm messages.

am i missing something?

Re: Guild Donation

Posted: Mon Mar 05, 2012 2:59 pm
by rock5
Are you sure the items are purple? Where did you get them from?

Re: Guild Donation

Posted: Mon Mar 05, 2012 3:37 pm
by Germangold
i have problems too
maybe german language wont work

Re: Guild Donation

Posted: Mon Mar 05, 2012 6:50 pm
by Rickster
rock5 wrote:Are you sure the items are purple? Where did you get them from?
i am sure. but i also tried

Code: Select all

GuildDonate("all", "purple", "true");
which also does not work. the function is overrun, without anything happening in the game client or any indications in the MM window.

The resources are from Ancient Treasure mini game.
As the AT mini game WP is nearly working perfect now :) ... i also want to automate the guild resource donation. but i would prefer to donate from my own wp file, not from AT.xml

I already told in the AT thread, that i tried to donate only once from rocks AT wp file, until i recognised the need of the donate userfunction ;) ... but with the userfunction it does not donate either :(

but as pointed out, i want to get it workinig in my own wp files.

Re: Guild Donation

Posted: Mon Mar 05, 2012 7:40 pm
by lisa
I just use this for AT

Code: Select all

			--=== guild donate resources ===--
			inventory:update()
			yrest(2000)
			for slot, item in pairs(inventory.BagSlot) do
				if item.Id == 206590 or item.Id == 206591 or item.Id == 206592 then
					RoMScript("PickupBagItem("..item.BagId..")")
					RoMScript("GCB_GetContributionItem(n)")
					if RoMScript("CursorHasItem()") then
							RoMScript("PickupBagItem("..item.BagId..")")            -- Put it back in the bag
					else
							RoMScript("GCB_OnOK()")
					end	
				end
			end
Haven't updated this userfunction but chances are the IS resources like you get from AT don't come under the type == "Ores", I might get time to update it next week.


I look at this code I did over 9 months ago and think "omg so many things are so wrong in it" lol
Sure it works but it is such a mess in setting out, the print to say it donated happens even if it doesn't donate because the prints are in the wrong places.

Re: Guild Donation

Posted: Mon Mar 05, 2012 8:47 pm
by Rickster
hehe ;) ok, i look forward to it.

the AT resources have the same resource tooltips, than normal wood, ore and herbs (german client)

Re: Guild Donation

Posted: Mon Mar 05, 2012 8:55 pm
by rock5
Well the resources from AT mini game are not "purple". "purple" are level 3 quality such as purple armor and weapons. The AT resources are like item shop items. They are level 8 quality. They might be purplish but not "purple". That's why in the AT script I used "GuildDonate(nil,8)". GuildDonate only supports upto "gold" quality (quality 5) using words; "green", "blue", "purple", "orange" and "gold". Anything higher and you have to use the number.

I hope that has cleared it up for you.

Re: Guild Donation

Posted: Mon Mar 05, 2012 8:59 pm
by Rickster
yes, thats fine for me :)
ok, i will try tomorrow, if this works with the ancient treasure resources.

how do you figure out which quality number belongs to a real ingame item color?

Re: Guild Donation

Posted: Mon Mar 05, 2012 9:42 pm
by rock5
Rickster wrote:how do you figure out which quality number belongs to a real ingame item color?
Put the item in the first bag slot. Started up the commandline script. Typed in

Code: Select all

print(inventory.BagSlot[61].Quality)

Re: Guild Donation

Posted: Thu Mar 08, 2012 12:56 pm
by Rickster
it seems that the localisation is not implemented.

i tried to change line 40
from

Code: Select all

if ( _type == "all" and (item:isType("Ores") or item:isType("Herbs") or item:isType("Wood")) ) or 
to

Code: Select all

if ( _type == "all" and (item:isType("Erz") or item:isType("Kraut") or item:isType("Holz")) ) or 
which are the ressource group names, shown in the german client tooltips.
this works and donates "Erz" and "Holz", but Herbs dont.

As there are many other places with localised words, i dont get the point, where to change what ;)
i remember there was a file in the database folder, which holds these resource group names. is it something we need for it? i cant find it anymore.

Re: Guild Donation

Posted: Thu Mar 08, 2012 6:29 pm
by Germangold

Code: Select all

[3] = { Name = "Materialien",
		[1] = { Name = "Holz" },
		[2] = { Name = "Kräuter" },
		[3] = { Name = "Rohmaterialien" },
		[4] = { Name = "Fertigungsrunen" },
		[5] = { Name = "Verarbeitete Güter" },
		[0] = { Name = "Erz" },
	},
is guess

"Kräuter" or "Kr\195\164uter" should work

Re: Guild Donation

Posted: Fri Mar 09, 2012 1:40 am
by Rickster
I did an update to lisas userfunction.
The idea was, to make the function work, independant from localisation and is based on the idea that itemtypestable.lua is build independant from localised clients ... please report, if this is not.

I tested this version on a german client. As I am not very good in things like coding and testing, this version is released as beta. Please feel free to report any bugs.
The main benefit goes to rock5 and lisa, who helped me in other threads on questions regarding to this topic.

It mainly contains lisas code with following changes:
  • using itemtypestable.lua for localised names
  • searches only backpacks 1-6 for ressources
  • donates woods, ores, herbs
  • minor changes for checking _type and _quality
For usage instructions I will mainly quote lisas first post:

This is a userfunction created for the purpose of donating gathered resources to your guild, inluding quality 8 guild resources from mini games.
It does not cover guild runes / guild stones / guild rubies, it is purely for herb / ore / wood.

Usage:

Code: Select all

	GuildDonate(arg1, arg2, arg3)
  • arg1 is the type of resource "ore", "wood", "herb" or "all"
  • arg2 is the quality "white"(0), "green"(1) "blue"(2), "purple"(3), "orange"(4), "gold"(5)
    You can also use numbers from 0-15 without quotes.
    To use mini game resources use 8 witout quotes.
  • arg3 is if you want to also donate lesser quality "true", defaults to "false"
arg1 and arg2 are mandatory in conjunction!!! You cant use one without the other!
This is, because users have to be sure what they want to donate!

Examples

Code: Select all

GuildDonate()
equals

Code: Select all

GuildDonate("all", 15, "true")
Donates all resources up to quality 15. This includes all ressources, also the mini game resources.

Code: Select all

GuildDonate("ore", "green")
Will donate all Ore of green quality only.

Code: Select all

GuildDonate("herb","blue","true")
Will donate all Herbs of blue & green & white quality.

Code: Select all

GuildDonate("all", "green")
Will donate all resources of green quality only.

Ric
userfunction_GuildDonate.lua
Version 1.41 beta
(3.71 KiB) Downloaded 198 times

Re: Guild Donation

Posted: Fri Mar 09, 2012 4:38 am
by rock5
All in all I'd say its a great job.

My comments:
  • My pet peave. You're like Lisa. You don't indent properly. Grrrr.
    I like the debug mode.
    I like all the extra checks you do.
    I like the use of "elseif". I think Lisa always had trouble using "elseif"s.
    You really should have declared the "item" variable local. It's too common a variable name and might conflict with other userfunctions.
    I've never seen the "cprintf_ex" function before. I wasn't even aware of it. LoL. I'll have to remember that if I ever want mixed color text on one line.
    I'm not sure I like the starting and ending messages. I like to see as few unneccessary messages as possible. What's wrong with just

    Code: Select all

    Donating 5 Maple Wood (Woods)
    This seems pointless

    Code: Select all

    Donating all to guild ...
    Donating 5 Maple Wood (Woods)
    Donation finished.
    Or if this happened

    Code: Select all

    Donating all to guild ...
    There was nothing to donate.
    Donation finished.

Re: Guild Donation

Posted: Fri Mar 09, 2012 9:46 am
by lisa
rock5 wrote:My pet peave. You're like Lisa. You don't indent properly. Grrrr.
lol that was 9 months ago, I do it much nicer now =)

I haven't had a chance to test it but when you are happy with it I'll add it to first post as a newer version. I really don't get as much time anymore to upgrade or test things =(