Re: Guild Donation
Posted: Fri Mar 09, 2012 10:13 am
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.

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.
•arg1 is the type of resource "ore", "wood", "herb" or "all"
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()
Code: Select all
GuildDonate("all","green",false)
Code: Select all
GuildDonate("herb","green",false)
Code: Select all
GuildDonate(nil,"green",false)
Code: Select all
GuildDonate()
Code: Select all
GuildDonate(ore,"green",false)
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
Code: Select all
if _type == "stone" then
Code: Select all
GuildDonateItems({"Guild Stone", "Guild Rune", "Handcrafted Ruby"})
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
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.
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
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
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.
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
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