diff --git a/Examples/02-macro-targetself.lua b/Examples/02-macro-targetself.lua index 9bf29bd..266cad6 100755 --- a/Examples/02-macro-targetself.lua +++ b/Examples/02-macro-targetself.lua @@ -1,13 +1,13 @@ -- Triggers the action assigned to the first slot on the left panel Macro(0) --- Wait 3 seconds -sleep(3000) +-- Wait for target +WaitForTarget() -- Target self TargetSelf() -- Wait 1 second sleep(1000) -- Example of if condition -if tonumber(HEALTH) < tonumber(STR) then +if HEALTH < STR then -- Say something Say("I need healing!") else diff --git a/Examples/04-finditem-drag-split.lua b/Examples/04-finditem-drag-split.lua index 9ece56a..7d3e195 100755 --- a/Examples/04-finditem-drag-split.lua +++ b/Examples/04-finditem-drag-split.lua @@ -1,10 +1,10 @@ -- Search for bandages FindItem("bandage") -if FINDITEMID == "N/A" then +if FINDITEM == nil then print("Bandages not found!") return end -local bandage_id = FINDITEMID[1] +local bandage_id = FINDITEM[1].ID -- Example 1 -- Drag them all diff --git a/Examples/06-lumberjacking.lua b/Examples/06-lumberjacking.lua index c406d47..1b8b2f1 100644 --- a/Examples/06-lumberjacking.lua +++ b/Examples/06-lumberjacking.lua @@ -14,13 +14,13 @@ attackSpellKey = 11 function Equip(item) -- stole this from utils.lua FindItem (item) - local tool_id = FINDITEMID[1] - local cont_id = FINDITEMCNTID[1] - if tool_id == nil or tool_id == "N/A" then + if FINDITEM == nil then print(item .. " not found!") return end - if tostring(cont_id) == tostring(CHARID) then + local tool_id = FINDITEM[1].ID + local cont_id = FINDITEM[1].CNTID + if cont_id == CHARID then print(item .. " already equipped!") return end @@ -34,7 +34,7 @@ function MoveEx(x,y,z) -- starts you moving towards coordinates and waits until count = count + 1 Move(x,y,z) sleep(300) - until ((tonumber(CHARPOSX) == x) and (tonumber(CHARPOSZ) == z)) or count > 30 + until (CHARPOSX == x and CHARPOSZ == z) or count > 30 end function dropoff() @@ -43,33 +43,33 @@ function dropoff() Macro(gateToHouseKey) -- this is casting gate from a hotkey to my house sleep(4000) FindPanel("Moongate") - if FINDPANELID == "N/A" then - panelId = FINDPANELID + if FINDPANEL == nil then + panelId = nil else - panelId = FINDPANELID[1] + panelId = FINDPANEL[1].ID end until string.match(panelId, "ConfirmMoongate") - ClickButton(FINDPANELID[1], "0") -- "0" is the confirmation to travel button + ClickButton(FINDPANEL[1].ID, "0") -- "0" is the confirmation to travel button sleep(3000) - FindItem("Logs",tonumber(BACKPACKID)) -- finds all logs in my backpack - for id in FINDITEMID do - Drag(id) + FindItem("Logs",BACKPACKID) -- finds all logs in my backpack + for k, v in pairs(FINDITEM) do + Drag(v.ID) Dropc(dropoffBoxId) -- and drops them in a chest at my house sleep(500) end - FindItem("Kindling",tonumber(BACKPACKID)) -- moves kindling - Drag(FINDITEMID[1]) + FindItem("Kindling",BACKPACKID) -- moves kindling + Drag(FINDITEM[1].ID) Dropc(dropoffBoxId) sleep(500) - FindItem("Apple",tonumber(BACKPACKID)) -- and apples - Drag(FINDITEMID[1]) + FindItem("Apple",BACKPACKID) -- and apples + Drag(FINDITEM[1].ID) Dropc(dropoffBoxId) sleep(500) FindItem("Portal") -- and travels back through the moongate - UseSelected(tonumber(FINDITEMID[1])) + UseSelected(FINDITEM[1].ID) sleep(1000) FindPanel("Moongate") - ClickButton(FINDPANELID[1], "0") + ClickButton(FINDPANEL[1].ID, "0") sleep(3000) Equip("Hatchet") -- don't forget to re-equip your hatchet! end @@ -79,8 +79,8 @@ function defend() local x = CHARPOSX local y = CHARPOSY local z = CHARPOSZ - mId_s = MONSTERSID[1] - mId = tonumber(mId_s) + mId_s = NEARBYMONSTERS[1].ID + mId = mId_s Move(x-5,y,z) -- run away a bit sleep(1000) Say('all follow me') -- get your pets with you @@ -95,7 +95,7 @@ function defend() Equip("hatchet") -- re-equip yourself! MoveEx(x,y,z) FindPermanent("Tree") -- and re-engage the tree - closestId = FINDPERMAID[1] + closestId = FINDPERMANENT[1].ID Macro(28) sleep(500) TargetPermanent(closestId) @@ -106,7 +106,7 @@ function doTree(x,y,z) Equip("Hatchet") MoveEx(x,y,z) FindPermanent("Tree") -- find all trees - closestId = FINDPERMAID[1] -- finds the closest one + closestId = FINDPERMANENT[1].ID -- finds the closest one print('At spot with x/z: ' .. x .. ',' .. z) Macro(28) -- the 'q' key sleep(500) @@ -118,7 +118,7 @@ function doTree(x,y,z) startWeight = CHARWEIGHT print("startWeight" .. startWeight) FindItem("prospector", BACKPACKID) - prospectId = FINDITEMID[1] + prospectId = FINDITEM[1].ID UseSelected(prospectId) -- uses prospecting tool from pack on tree TargetPermanent(closestId) sleep(4000) @@ -126,7 +126,7 @@ function doTree(x,y,z) print("endWeight" .. endWeight) print('start/end weight: ' .. startWeight .. ','..endWeight) until startWeight == endWeight -- will move to next tree if, within 4 seconds-ish, weight didn't change (as in the tree is gone) - if tonumber(endWeight) > 300 then -- getting full, dropoff time! + if endWeight > 300 then -- getting full, dropoff time! dropoff() end end diff --git a/Examples/07-targetloc.lua b/Examples/07-targetloc.lua index c231d90..14939bb 100644 --- a/Examples/07-targetloc.lua +++ b/Examples/07-targetloc.lua @@ -1,7 +1,7 @@ --Digs with any shovel in your backpack 2 units to the west of your current character location -FindItem("shovel", tonumber(BACKPACKID)) -shovelId = FINDITEMID[1] +FindItem("shovel", BACKPACKID) +shovelId = FINDITEM[1].ID UseSelected(shovelId) -TargetLoc(true, tonumber(CHARPOSX) - 2, tonumber(CHARPOSY), tonumber(CHARPOSZ), 0) +TargetLoc(CHARPOSX - 2, CHARPOSY, CHARPOSZ) sleep(1000) \ No newline at end of file diff --git a/Examples/08-hunger.lua b/Examples/08-hunger.lua index 1e4a2db..7bbc5b4 100644 --- a/Examples/08-hunger.lua +++ b/Examples/08-hunger.lua @@ -2,7 +2,7 @@ FindPanel("Character" .. CHARID) -- Open the character window if it's not open yet -if FINDPANELID == "N/A" then +if FINDPANEL == nil then SayCustom(".x ToggleCharacterWindow") sleep(1000) end @@ -11,7 +11,7 @@ end FindLabel("Character" .. CHARID, "Hunger") -- Remove crap from the text -local Hunger = FINDLABELTEXT[1] +local Hunger = FINDLABEL[1].TEXT Hunger = string.gsub(Hunger, 'Hunger', '') Hunger = string.gsub(Hunger, '%b[]', '') -- The Hunger variable will contain the hunger level (Full, Peckish, etc.) diff --git a/Examples/10-fishing.lua b/Examples/10-fishing.lua index f7a79d3..35a83da 100644 --- a/Examples/10-fishing.lua +++ b/Examples/10-fishing.lua @@ -1,15 +1,16 @@ function Equip(item) FindItem (item) - local tool_id = FINDITEMID[1] - local cont_id = FINDITEMCNTID[1] - - if tool_id == nil or + + if FINDITEM == nil or tool_id == "N/A" then print(item .. " not found!") return end + + local tool_id = FINDITEM[1].ID + local cont_id = FINDITEM[1].CNTID - if tostring(cont_id) == tostring(CHARID) then + if cont_id == CHARID then print(item .. " already equipped!") return end diff --git a/Examples/11-restock-regs.lua b/Examples/11-restock-regs.lua index 0458e70..a46419a 100644 --- a/Examples/11-restock-regs.lua +++ b/Examples/11-restock-regs.lua @@ -1,48 +1,48 @@ function restockRegs(amount) - FindItem("Black Pearls", CLICKOBJID) - ContextMenu(FINDITEMID[1], "Split Stack") + FindItem("Black Pearls", CLICKOBJ.OBJECTID) + ContextMenu(FINDITEM[1].ID, "Split Stack") SetInput("StackSplit", "TextFieldStackAmount", tostring(amount)) ClickButton("StackSplit",2) Dropc(BACKPACKID) sleep(333) - FindItem("Blood Moss", CLICKOBJID) - ContextMenu(FINDITEMID[1], "Split Stack") + FindItem("Blood Moss", CLICKOBJ.OBJECTID) + ContextMenu(FINDITEM[1].ID, "Split Stack") SetInput("StackSplit", "TextFieldStackAmount", tostring(amount)) ClickButton("StackSplit",2) Dropc(BACKPACKID) sleep(333) - FindItem("Garlic", CLICKOBJID) - ContextMenu(FINDITEMID[1], "Split Stack") + FindItem("Garlic", CLICKOBJ.OBJECTID) + ContextMenu(FINDITEM[1].ID, "Split Stack") SetInput("StackSplit", "TextFieldStackAmount", tostring(amount)) ClickButton("StackSplit",2) Dropc(BACKPACKID) sleep(333) - FindItem("Mandrake Root", CLICKOBJID) - ContextMenu(FINDITEMID[1], "Split Stack") + FindItem("Mandrake Root", CLICKOBJ.OBJECTID) + ContextMenu(FINDITEM[1].ID, "Split Stack") SetInput("StackSplit", "TextFieldStackAmount", tostring(amount)) ClickButton("StackSplit",2) Dropc(BACKPACKID) sleep(333) - FindItem("Nightshade", CLICKOBJID) - ContextMenu(FINDITEMID[1], "Split Stack") + FindItem("Nightshade", CLICKOBJ.OBJECTID) + ContextMenu(FINDITEM[1].ID, "Split Stack") SetInput("StackSplit", "TextFieldStackAmount", tostring(amount)) ClickButton("StackSplit",2) Dropc(BACKPACKID) sleep(333) - FindItem("Spider's Silk", CLICKOBJID) - ContextMenu(FINDITEMID[1], "Split Stack") + FindItem("Spider's Silk", CLICKOBJ.OBJECTID) + ContextMenu(FINDITEM[1].ID, "Split Stack") SetInput("StackSplit", "TextFieldStackAmount", tostring(amount)) ClickButton("StackSplit",2) Dropc(BACKPACKID) sleep(333) - FindItem("Sulfurous Ash", CLICKOBJID) - ContextMenu(FINDITEMID[1], "Split Stack") + FindItem("Sulfurous Ash", CLICKOBJ.OBJECTID) + ContextMenu(FINDITEM[1].ID, "Split Stack") SetInput("StackSplit", "TextFieldStackAmount", tostring(amount)) ClickButton("StackSplit",2) Dropc(BACKPACKID) sleep(333) - FindItem("Ginseng", CLICKOBJID) - ContextMenu(FINDITEMID[1], "Split Stack") + FindItem("Ginseng", CLICKOBJ.OBJECTID) + ContextMenu(FINDITEM[1].ID, "Split Stack") SetInput("StackSplit", "TextFieldStackAmount", tostring(amount)) ClickButton("StackSplit",2) Dropc(BACKPACKID) diff --git a/Examples/utils.lua b/Examples/utils.lua index 862ce85..3a3bc4f 100755 --- a/Examples/utils.lua +++ b/Examples/utils.lua @@ -40,14 +40,14 @@ end function Equip(item) FindItem (item) - local tool_id = ExtractFirstId(FINDITEMID) - local cont_id = ExtractFirstId(FINDITEMCNTID) - - if tool_id == nil or - tool_id == "N/A" then + + if FINDITEM == nil then print(item .. " not found!") return end + + local tool_id = FINDITEM[1].ID; + local cont_id = FINDITEM[1].CNTID; if tostring(cont_id) == tostring(CHARID) then print(item .. " already equipped!")