-- ver 3.0 --[[ DX: - By locking the field m_MouseEnterFurnishingID to item number (from house item list) and doing a player:target_NPC("Large Mayan Plant Pot") u can avoid using focus/mouse to click on pots. - Keep the PlantCare stuff but make new scan/selection stuff --]] local p_find = string.char(0x51, 0x8b, 0x0d, 0x0, 0x0, 0x0, 0x0, 0x80, 0x79, 0x0e) local m_find = "xxx????xxx" local mouseOverOffset = 0x1488 function PlantCare() seeds = {} pots = {} furniture = {} --=== populate seeds to a table ===-- root = xml.open(getExecutionPath() .. "/database/seeds.xml"); elements = root:getElements(); for i,v in pairs(elements) do local name, id, type; local tmp = {} name = v:getAttribute("name"); id = v:getAttribute("id"); type = v:getAttribute("type"); if( type == "WOOD" ) then type = NTYPE_WOOD; elseif( type == "ORE" ) then type = NTYPE_ORE; elseif( type == "HERB" ) then type = NTYPE_HERB; end; tmp.Name = name; tmp.Id = id; tmp.Type = type; seeds[id] = tmp; end --=== check zone ===-- local zoneid = RoMScript("GetZoneID()") if zoneid ~= 400 then printf("Need to be in your House, move to your house and then press Delete.\n") player:sleep() end --=== Find the House info ===-- local foundAddress = findPatternInProcess(getProc(), p_find, m_find, 0x401000, 0x4f1000) local staticPointer = memoryReadUInt(getProc(), foundAddress + 3) local HousesFrame = memoryReadUInt(getProc(), staticPointer) -- Check furniture for some pots local _,_,_,numItems = RoMScript("Houses_GetHouseInfo()") --print("House furniture: "..numItems) -- target and click pot function clickPot(ID, name) local function selectItem(ID) memoryWriteInt(getProc(), HousesFrame + mouseOverOffset, ID) end registerTimer("Lock", 1, selectItem, ID) player:target_NPC(name) unregisterTimer("Lock") end -- Scan for all pots for i=1,numItems do local enable, name, texture, Placed, ID = RoMScript("Houses_GetFurnitureItemInfo("..i..")") if(enable and Placed) then if(string.match(name, "Pot")) then RoMScript("HideUIPanel(PlantFrame);") print(string.format("Found [%d]: %s\n", ID, name)) -- Click the pot to get up Plantcare clickPot(ID, name) -- Now handle Plantcare repeat local szState, szPotName, nPotType = RoMScript("Plant_GetInfo();") yrest(1000) until szState ~= nil yrest(500) local szState, szPotName, nPotType = RoMScript("Plant_GetInfo();") if nPotType == 2 then nPotType = 3 elseif nPotType == 3 then nPotType = 2 end --print(szState, szPotName, nPotType) if szState == "none" then --=== find seed in inv to use ===-- inventory:update() for slot,item in pairs(inventory.BagSlot) do local seedid = seeds[item.Id]; if seedid and ( seedid.Type == nPotType or nPotType == 0 ) then -- guessed that ALL would be 0, I don't have a pot to test it on. RoMScript("PickupBagItem("..item.BagId..")") yrest(1000) RoMScript('Plant_PickupItem("seed");') yrest(1000) RoMScript('Plant_Grow("seed");') yrest(500) end end --=== update to feed/water it. ===-- -- needs fixing RoMScript("HideUIPanel(PlantFrame);") player:clearTarget(); memoryWriteInt(getProc(), player.Address + addresses.pawnTargetPtr_offset, v.Address); yrest(500) printf("click it again to feed\n") clickPot(ID, name) yrest(500) clickPot(ID, name) end end end end end