Skip to content

Commit

Permalink
updated examples
Browse files Browse the repository at this point in the history
closes #102
  • Loading branch information
Lady-Binary committed Aug 21, 2020
1 parent 62553bd commit d9437e3
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 60 deletions.
6 changes: 3 additions & 3 deletions Examples/02-macro-targetself.lua
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions Examples/04-finditem-drag-split.lua
Original file line number Diff line number Diff line change
@@ -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
Expand Down
48 changes: 24 additions & 24 deletions Examples/06-lumberjacking.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -118,15 +118,15 @@ 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)
endWeight = CHARWEIGHT
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
Expand Down
6 changes: 3 additions & 3 deletions Examples/07-targetloc.lua
Original file line number Diff line number Diff line change
@@ -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)
4 changes: 2 additions & 2 deletions Examples/08-hunger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.)
Expand Down
11 changes: 6 additions & 5 deletions Examples/10-fishing.lua
Original file line number Diff line number Diff line change
@@ -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
Expand Down
32 changes: 16 additions & 16 deletions Examples/11-restock-regs.lua
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
10 changes: 5 additions & 5 deletions Examples/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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!")
Expand Down

0 comments on commit d9437e3

Please sign in to comment.