----------------------------------- -- Control lootomatic via script -- -- Version 0.2 -- -- by rintintin ------------------- -- History -- 0.1 initial version -- 0.2 fixed a bug when itemname contained doublequotes. local function lootomaticEnable() cprintf(cli.lightgreen,"Setting Lootomatic-State to [ON]\n"); RoMScript("/script Lootomatic_Settings.Enabled=true;"); end local function lootomaticDisable() cprintf(cli.lightgreen,"Setting Lootomatic-State to [OFF]\n"); RoMScript("/script Lootomatic_Settings.Enabled=false;"); end -- checks whether the addOn is enabled or not. -- If verbose is set to false, no output will be given local function lootomaticGetStatus(_verbose) if _verbose == nil or type(_verbose) ~="boolean" then _verbose = true end local _state = RoMScript("Lootomatic_Settings.Enabled"); if _state then if _verbose then cprintf(cli.lightgreen,"Lootomatic is active\n"); end return true else if _verbose then cprintf(cli.lightgreen,"Lootomatic is disabled\n"); end return false end end -- Returns Version of the installed Lootomatic Version (i.E. 'V1.0') local function lootomaticGetAddOnVersion() return RoMScript("Lootomatic_Settings.Version") end -- Adds an item to the itemlist of lootomatic. -- @param item String/int the id or name of the Item -- @param loot String one of the following: 'dont_loot','loot','drop' -- @param roll String one of the following: 'pass','greed','need','manual' local function lootomaticAddItem(item,loot,roll) local lootmodes = {dont_loot=2,loot=3,drop=4}; local rollmodes = {pass=2,greed=3,need=4,manual=5}; if type(item) ==nil or type(loot) ==nil or type(roll) ==nil then local errormsg = "\nERROR: lootomaticAddItem needs 3 arguments and you missed at least one.\n"; errormsg = errormsg .."Usage: lootomaticAddItem(item,loot,roll). \n\n"; errormsg = errormsg .."values for loot: 'dont_loot','loot','drop'\n"; errormsg = errormsg .."values for roll: 'pass','greed','need','manual'\n"; error(errormsg,0); end local params = {}; if type(item) == "number" then item = GetIdName(item); if type (item) == nil then print ("No valid Item found for ObjectId" .. item); end end params[0] = string.gsub(item,"\"","\\\""); params[1] = lootmodes[loot]; params[2] = rollmodes[roll]; for i = 0,2 do if params[i] == nil then error ("\nERROR: paramater "..i.." is nil!"); end end sendMacro ("Lootomatic.Func.ItemFilter_AddItem(\"LBUTTON\",\""..params[0].."\","..params[1]..","..params[2]..")"); end local function lootomaticRemoveItem(item) local itemFilterSize = RoMScript ("table.getn(Lootomatic_Settings.ItemFilter)") local i; local foundItem = false; if type(item) == "number" then item = GetIdName(item); if type (item) == nil then error ("No valid Item found for ObjectId" .. item,0); end end -- TODO: might become faster whem using : itemfilter=sendMacro("table.save(Lootomatic_Settings.ItemFilter)"); for i = 1,itemFilterSize do local currentItem = RoMScript("Lootomatic_Settings.ItemFilter["..i.."][\"Name\"]"); if currentItem == item then RoMScript ("table.remove(Lootomatic_Settings.ItemFilter,"..i..");Lootomatic.Func.ItemFilter_Repaint();"); foundItem = true; break; end end if foundItem then cprintf(cli.lightred,"Item: "..item.." successfully removed."); else cprintf(cli.lightred,"Item: "..item.." not found in list!"); end end -- Put all local punction in a table/class lootomatic={enable=lootomaticEnable, disable=lootomaticDisable, status=lootomaticGetStatus, addOnVersion=lootomaticGetAddOnVersion, addItem=lootomaticAddItem, removeItem=lootomaticRemoveItem }