hm strange. I use notepad++ as editor and all is well indentrock5 wrote:My pet peave. You're like Lisa. You don't indent properly. Grrrr.
Guild Donation
Forum rules
Only post additional bot resources here. Please do not ask unrelated questions.
Only post additional bot resources here. Please do not ask unrelated questions.
Re: Guild Donation
Last edited by Rickster on Tue Mar 13, 2012 12:22 am, edited 1 time in total.
userfunction_GuildDonate - new version 1.43
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
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
Re: Guild Donation
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
Re: Guild Donation
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
wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
Re: Guild Donation
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 )
i just found your suggestions in the AT thread and hijacked it to here
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.
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 )
i just found your suggestions in the AT thread and hijacked it to here
My idea for using GuildDonate() is, to donate everything possible to guild.rock5 wrote:So nil doesn't work anymore? It doesn't default to "all"? Hm... shouldn't it?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.
Maybe, thisshould beCode: Select all
if ( _type == nil and _quality == nil and _lesser == nil ) then _lesser = "true" _type = "all" _quality = 15 end
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 useCode: Select all
GuildDonate()
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.
Re: Guild Donation
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.
("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
wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
Re: Guild Donation
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 or
or whatever resource they are doing or
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.
The only situation I can see users accidentally donating items is if they do something like this
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:
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)
Code: Select all
GuildDonate("herb","green",false)
Code: Select all
GuildDonate(nil,"green",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()
Code: Select all
GuildDonate(ore,"green",false)
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.
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 end
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 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.
Code: Select all
if _type == "stone" then
- 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
Re: Guild Donation
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
Re: Guild Donation
I added option to donate any item in backpack by name or id, ex:
-dx
Code: Select all
GuildDonateItems({"Guild Stone", "Guild Rune", "Handcrafted Ruby"})
- Attachments
-
- userfunction_GuildDonate.lua
- (3.92 KiB) Downloaded 171 times
Re: Guild Donation
Code: Select all
GuildDonateItems({"Guild Stone", "Guild Rune", "Handcrafted Ruby"})
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
Re: Guild Donation
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
Re: Guild Donation
Yes, I believe so, was just debugging, can't figure out how to delete my postrock5 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.
Re: Guild Donation
Yes it was a bug in my code. Now that its fixed, this function runs well, listing the items I have:
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.
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
Re: Guild Donation
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
Re: Guild Donation
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.
Re: Guild Donation
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.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.
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
Re: Guild Donation
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
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
Re: Guild Donation
line 10 hasCindy wrote:I even added an inventory:update() (the developer of GuildDonateItems() didn't, this may be an issue).
Code: Select all
inventory:update()
have a look at the pics down the bottom of this link, it might explain why the numbers are weird.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.
http://www.theromwiki.com/API:UseBagItem
So it is finding the items but isn't donating them?Cindy wrote:At any rate, none of them actually got donated, including the Guild Runes
I can't find that print in the code anywhere, what version are you using???Cindy wrote:Name Guild Rune at 139
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
wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
Re: Guild Donation
I was using the command line testing the donation function.
Re: Guild Donation
And yes, the items are found, but then its not donated.
This is the code im using (downloaded from one of the threads here) :
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
Who is online
Users browsing this forum: No registered users and 1 guest