0% found this document useful (0 votes)
78 views

PTHT

This document contains code for an automated Growtopia script. The script contains functions for planting seeds, harvesting crops, checking stock levels, and reporting status via Discord webhook. Key variables include world name, magplant coordinates, item IDs, and wait time between runs.

Uploaded by

ArtaDex
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
78 views

PTHT

This document contains code for an automated Growtopia script. The script contains functions for planting seeds, harvesting crops, checking stock levels, and reporting status via Discord webhook. Key variables include world name, magplant coordinates, item IDs, and wait time between runs.

Uploaded by

ArtaDex
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 15

RemoveCallbacks()

local WEBHOOK = "" -- Discord Webhook Link


local WORLD = "POGUSER" -- World name IN ALL CAPITALS (ex. local WORLD = "FGPD")
local WAIT_TIME = 0 -- Minutes that the script will pause after harvesting OR IF
YOUR MAGPLANT IS EMPTY
local MRAY = true -- Set to true if you use MRAY

local COLLECT_GEMS = 1 -- 1 - Auto collect gems, 2 - Don't collect gems


local WORLD_SIZE_X = 200 -- Set your world's X size (Island: 200, Default: 100)
local WORLD_SIZE_Y = 200 -- Set your world's Y size (Island: 200, Default: 60)
local ITEM_ID = 14767 -- Default is Pot O' Gems Seed
local PLATFORM_ID = 7520 -- Default is rayman - band land platform ID : 13216

local MAG_X = 2 -- Set your magplant's x position


local MAG_Y = 195 -- Set your magplant's y position

-- Optional Settings
local IGNORE_UNHARVESTED_AFTER_PUNCH = true -- (MRAY ONLY) Set to true if you only
want to punch a row once to harvest it (and ignore unharvested trees)
local RAW_MOVE = true -- Set to false if you're lagging

-- Do not touch
local REMOTE_X = MAG_X -- do not touch
local REMOTE_Y = MAG_Y -- do not touch

local MAG_STOCK = 0 -- do not touch


local CHECK_STOCK = true -- do not touch
local START_PLANT = 0

local IS_GHOST, CHECK_GHOST = false, false -- do not touch


local DELAY_FINDPATH = 70 -- do not touch
local DELAY_PLANT = 140 -- do not touch
local RAW_SLEEP = -1 -- do not touch
local MAG_EMPTY = false -- do not touch
local CHANGE_REMOTE = false -- do not touch
local START_MAG_X = MAG_X -- do not touch
local START_MAG_Y = MAG_Y -- do not touch
local ROTATION_COUNT = 0 -- do not touch

local DISABLED = false -- ABSOLUTELY DO NOT FUCKING TOUCH

local function WARN(text)


local packet = {
[0] = "OnAddNotification",
[1] = "interface/atomic_button.rttex",
[2] = text,
[3] = 'audio/hub_open.wav',
[4] = 0,
netid = -1
}
SendVarlist(packet)
end

if MAG_X == -1 or MAG_Y == -1 then


WARN("You must set MAG_X / MAG_Y at the top of the script! The script is now
disabled.")
CALL_NILL_FUNCTION()
end
if MRAY then
RAW_SLEEP = 50
elseif not MRAY then
RAW_SLEEP = 115
end

for _, TILE in pairs(GetTiles()) do


if TILE.water then
DISABLED = true
end
end

function removeColorAndSymbols(str) -- Credits to KimPanzi


local cleanedStr = string.gsub(str, "`(%S)", '')
cleanedStr = string.gsub(cleanedStr, "`{2}|(~{2})", '')
return cleanedStr
end

local function FormatNumber(num) -- Credits to KimPanzi


num = math.floor(num + 0.5)

local formatted = tostring(num)


local k = 3
while k < #formatted do
formatted = formatted:sub(1, #formatted - k) .. "," ..
formatted:sub(#formatted - k + 1)
k = k + 4
end

return formatted
end

function FORMAT_TIME(seconds) -- Credits to KimPanzi


local days = math.floor(seconds / 86400)
local hours = math.floor((seconds % 86400) / 3600)
local minutes = math.floor((seconds % 3600) / 60)
local remaining_seconds = seconds % 60

local parts = {}
if days > 0 then
table.insert(parts, tostring(days) .. " day" .. (days > 1 and "s" or ""))
end
if hours > 0 then
table.insert(parts, tostring(hours) .. " hour" .. (hours > 1 and "s" or
""))
end
if minutes > 0 then
table.insert(parts, tostring(minutes) .. " minute" .. (minutes > 1 and "s"
or ""))
end
if remaining_seconds > 0 then
table.insert(parts, tostring(remaining_seconds) .. " second" ..
(remaining_seconds > 1 and "s" or ""))
end

if #parts == 0 then
return "0 seconds"
elseif #parts == 1 then
return parts[1]
else
local last_part = table.remove(parts)
return table.concat(parts, ", ") .. " and " .. last_part
end
end

local function GET_TELEPHONE()


local TILE_X = 0
local TILE_Y = 0

for _,tile in pairs(GetTiles()) do


if tile.fg == 3898 then
if tile.pos_x < 0 then
TILE_X = math.floor(tile.pos_x + 256)
else
TILE_X = tile.pos_x
end

if tile.pos_y < 0 then


TILE_Y = math.floor(tile.pos_y + 256)
else
TILE_Y = tile.pos_y
end

return TILE_X, TILE_Y


end
end
end

local function CHECK_FOR_GHOST()


if GetLocal().world ~= WORLD then return end

CHECK_GHOST = true
SendPacket(2, "action|wrench\n|netid|"..GetLocal().netid)
end

local function ENABLE_GHOST()


if GetLocal().world ~= WORLD then return end

CHECK_FOR_GHOST()
Sleep(500)

if not IS_GHOST then


SendPacket(2, "action|input\ntext|/ghost")
Sleep(200)
CHECK_FOR_GHOST()
end
end

local function Place(x, y,id)


local pkt_punch = {
type = 3,
int_data = id,
pos_x = GetLocal().pos_x,
pos_y = GetLocal().pos_y,
int_x = x,
int_y = y,
}
SendPacketRaw(pkt_punch)
end

local function Punch(x, y, itemID)


local pkt = {}
pkt.type = 3
pkt.int_data = itemID
pkt.pos_x = GetLocal().pos_x
pkt.pos_y = GetLocal().pos_y
pkt.int_x = x
pkt.int_y = y
pkt.flags = 2560
SendPacketRaw(pkt)
Sleep(90)
end

function RAW_PLANT(x, y)
pkt = {
type = 0,
pos_x = x * 32,
pos_y = y * 32,
int_x = -1,
int_y = -1
}
SendPacketRaw(pkt)
Sleep(RAW_SLEEP)
end

function FACE_DIRECTION(direction)
if direction == "LEFT" then
FLAG = 50
elseif direction == "RIGHT" then
FLAG = 34
end

pkt = {
type = 0,
pos_x = GetLocal().tile_x * 32,
pos_y = GetLocal().tile_y * 32,
int_x = -1,
int_y = -1,
flags = FLAG
}
SendPacketRaw(pkt)
Sleep(RAW_SLEEP)
end

function RAW_PLANT_MRAY(x, y, direction)


local FLAG = 0
if direction == "LEFT" then
FLAG = 50
elseif direction == "RIGHT" then
FLAG = 34
end

pkt = {
type = 0,
pos_x = x * 32,
pos_y = y * 32,
int_x = -1,
int_y = -1,
flags = FLAG
}
SendPacketRaw(pkt)
Sleep(RAW_SLEEP)
end

--local function Planting(y)


-- if y == nil or GetLocal().world == "EXIT" then return end
--
-- local payload = [[
-- {
-- "content": "",
-- "embeds": [{
-- "color": 1146986,
-- "fields": [{
-- "name":"Account:",
-- "value": "Name: **%s**",
-- "inline": false
-- },
-- {
-- "name": "Information:",
-- "value": ":earth_asia: Current World: **%s**\n:gem: Gems: **%s**\
n:seedling: UWS Stock: **%s**",
-- "inline": false
-- },
-- {
-- "name": "Status",
-- "value": ":green_circle: Planting [Y Axis: **%s**]",
-- "inline": false
-- }
-- ],
-- "thumbnail": {
-- "url": "https://cdn.growtopia.tech/items/5638.png"
-- },
-- "footer": {
-- "text": "%s"
-- }
-- }]
-- }]]
--
-- SendWebhook(WEBHOOK, payload:format(removeColorAndSymbols(GetLocal().name),
GetLocal().world, FormatNumber(GetLocal().gems), FormatNumber(GetItemCount(12600)),
y, os.date("!%a, %b/%d/%Y at %I:%M %p", os.time() + 8 * 60 * 60)))
--end

-- function Harvesting(y)
-- if y == nil or GetLocal().world == "EXIT" then return end
--
-- local payload = [[
-- {
-- "content": "",
-- "embeds": [{
-- "color": 1146986,
-- "fields": [{
-- "name":"Account:",
-- "value": "Name: **%s**",
-- "inline": false
-- },
-- {
-- "name": "Information:",
-- "value": ":earth_asia: Current World: **%s**\n:gem: Gems: **
%s**\n:seedling: UWS Stock: **%s**",
-- "inline": false
-- },
-- {
-- "name": "Status",
-- "value": ":green_circle: Harvesting [Y Axis: **%s**]",
-- "inline": false
-- }
-- ],
-- "thumbnail": {
-- "url": "https://cdn.growtopia.tech/items/1966.png"
-- },
-- "footer": {
-- "text": "%s"
-- }
-- }]
-- }]]
--
-- SendWebhook(WEBHOOK, payload:format(removeColorAndSymbols(GetLocal().name),
GetLocal().world, FormatNumber(GetLocal().gems), FormatNumber(GetItemCount(12600)),
y, os.date("!%a, %b/%d/%Y at %I:%M %p", os.time() + 8 * 60 * 60)))
-- end

function WAIT_HOOK()
local payload = [[
{
"content": "",
"embeds": [{
"color": 1146986,
"fields": [{
"name":"Account:",
"value": "Name: **%s**",
"inline": false
},
{
"name": "Information:",
"value": ":earth_asia: Current World: **%s**\n:gem: Gems: **%s**\
n:seedling: UWS Stock: **%s**",
"inline": false
},
{
"name": "Status",
"value": ":yellow_circle: Done harvesting, taking a **%s minutes**
break.",
"inline": false
}
],
"footer": {
"text": "%s"
}
}]
}]]

SendWebhook(WEBHOOK, payload:format(removeColorAndSymbols(GetLocal().name),
GetLocal().world, FormatNumber(GetLocal().gems), FormatNumber(GetItemCount(12600)),
WAIT_TIME, os.date("!%a, %b/%d/%Y at %I:%M %p", os.time() + 8 * 60 * 60)))
end

local function MAG_STOCK_HOOK()


if GetLocal().world ~= WORLD or CHANGE_REMOTE then return end

local payload = [[
{
"content": "",
"embeds": [{
"color": "1146986",
"fields": [{
"name":"Account:",
"value": ":alien: Name: **%s**",
"inline": false
},
{
"name": "Information:",
"value": ":earth_asia: Current World: **%s**\n:gem: Gems: **%s**\
n:seedling: UWS Stock: **%s**",
"inline": false
},
{
"name": "MAGPLANT:",
"value": "Current remote: [**%s**, **%s**]\nStock: **%s**",
"inline": false
}
],
"thumbnail": {
"url": "https://cdn.growtopia.tech/items/32.png"
},
"footer": {
"text": "%s"
}
}]
}]]
SendWebhook(WEBHOOK, payload:format(removeColorAndSymbols(GetLocal().name),
GetLocal().world, FormatNumber(GetLocal().gems), FormatNumber(GetItemCount(12600)),
MAG_X, MAG_Y, MAG_STOCK, os.date("!%a, %b/%d/%Y at %I:%M %p", os.time() + 8 * 60 *
60)))
end

function Reconnected()
local payload = [[
{
"content": "",
"embeds": [{
"color": 1146986,
"fields": [{
"name":"Account:",
"value": "Name: **%s**",
"inline": false
},
{
"name": "Information:",
"value": ":earth_asia: Current World: **%s**\n:gem: Gems: **%s**\
n:seedling: UWS Stock: **%s**",
"inline": false
},
{
"name": "Status",
"value": ":red_circle: Reconnected, you probably disconnected
recently.",
"inline": false
}
],
"footer": {
"text": "%s"
}
}]
}]]

SendWebhook(WEBHOOK, payload:format(removeColorAndSymbols(GetLocal().name),
GetLocal().world, FormatNumber(GetLocal().gems), FormatNumber(GetItemCount(12600)),
os.date("!%a, %b/%d/%Y at %I:%M %p", os.time() + 8 * 60 * 60)))
end

local function CHECK_FOR_AIR()


for y = 0, WORLD_SIZE_Y do
local startX = 0
local endX = WORLD_SIZE_X
local incrementX = 1
if not MRAY then
if y % 4 == 2 then
startX = WORLD_SIZE_X - 1
endX = -1
incrementX = -1
end
end

for x = startX, endX, incrementX do


if GetLocal().world ~= WORLD then return end

if GetTile(x, y).fg == PLATFORM_ID then

if x > 1 and x < WORLD_SIZE_X and y-1 >= 0 and y-1 < WORLD_SIZE_Y
and GetTile(x, y-1).fg == 0 then
return true
end
end
end
end

return false
end

local function CHECK_FOR_TREE()


if MAG_EMPTY then return end
for y = WORLD_SIZE_Y, 0, -1 do
for x = 0, WORLD_SIZE_X do
if GetLocal().world ~= WORLD then return end

if x >= 0 and x < WORLD_SIZE_X and y >= 0 and y < WORLD_SIZE_Y then
local tile = GetTile(x, y)

if tile.fg == ITEM_ID and tile.ready == true and GetTile(x, y+1).fg


== PLATFORM_ID then
return true
end
end
end
end

return false
end

local function AUTOPLANT_SETTINGS()


for y = 0, WORLD_SIZE_Y do
for x = 0, WORLD_SIZE_X do
if GetTile(x, y).fg == ITEM_ID and GetTile(x, y+1).fg ~= PLATFORM_ID
then
EditToggle("modfly", false)
EditToggle("antibounce", false)

ENABLE_GHOST()
Sleep(1000)

SendPacket(2, "action|dialog_return\ndialog_name|cheats\
ncheck_autoplace|0\ncheck_gems|".. COLLECT_GEMS)

WalkTo(x, y)
Sleep(1000)

SendPacket(2, "action|dialog_return\ndialog_name|cheats\
ncheck_autoplace|1\ncheck_gems|".. COLLECT_GEMS)
return
end
end
end
end

local function CheckRemote()


if GetLocal().world ~= WORLD then return end

if GetItemCount(5640) < 1 or MAG_EMPTY or CHECK_STOCK then


ENABLE_GHOST()
Sleep(100)
FindPath(REMOTE_X, REMOTE_Y - 1)
Place(REMOTE_X,REMOTE_Y,32)
Sleep(600)
SendPacket(2, "action|dialog_return\ndialog_name|magplant_edit\nx|"..
REMOTE_X .."|\ny|" .. REMOTE_Y .. "|\nbuttonClicked|getRemote")
Sleep(250)
Place(REMOTE_X, REMOTE_Y-1, 5640)
end

if GetItemCount(5640) >= 1 and MAG_EMPTY then


MAG_EMPTY = false
end

return GetItemCount(5640) >= 1


end

local LAST_PLANTED_Y = -1
local LAST_HARVESTED_Y = -1

local function PLANT_LOOP()


if MAG_EMPTY then return end
if MRAY then
for x = 0, WORLD_SIZE_X, 1 do
local DIRECTION = "RIGHT"

for y = 0, WORLD_SIZE_Y do
if MAG_EMPTY then return end
if GetLocal().world ~= WORLD then
return
end

if GetTile(x, y).fg == PLATFORM_ID then


local PLACE_X = x
local PLACE_Y = y - 1

if PLACE_X >= 0 and PLACE_X < WORLD_SIZE_X and


PLACE_Y >= 0 and PLACE_Y < WORLD_SIZE_Y and GetTile(PLACE_X, PLACE_Y).fg == 0 then

if RAW_MOVE then
RAW_PLANT_MRAY(PLACE_X, PLACE_Y,
DIRECTION)
else
FindPath(PLACE_X, PLACE_Y)
Sleep(RAW_SLEEP/2)
FACE_DIRECTION("RIGHT")
end

Sleep(RAW_SLEEP)
Place(PLACE_X, PLACE_Y, 5640)
Sleep(RAW_SLEEP)
end
end
end
end
elseif not MRAY then
for y = 0, WORLD_SIZE_Y do
local startX = 0
local endX = WORLD_SIZE_X
local incrementX = 1
if y % 4 == 2 then
startX = WORLD_SIZE_X - 1
endX = -1
incrementX = -1
end

for x = startX, endX, incrementX do


if MAG_EMPTY then return end
if GetLocal().world ~= WORLD then return end

if GetTile(x, y).fg == PLATFORM_ID then

if x >= 0 and x < WORLD_SIZE_X and y-1 >= 0 and y-1 <
WORLD_SIZE_Y and GetTile(x, y-1).fg == 0 then
if ROTATION_COUNT ~= 0 then
FindPath(x, y-1)
Sleep(DELAY_FINDPATH)
Place(x, y-1, 5640)
Sleep(DELAY_PLANT)
else
RAW_PLANT(x, y-1)
end

--if y-1 ~= LAST_PLANTED_Y then


-- LAST_PLANTED_Y = y-1
-- Planting(y-1)
--end
end
end
end
end
end
end

local function Hold()


local pkt = {}
pkt.type = 0
pkt.flags = 16779298
SendPacketRaw(pkt)
Sleep(90)
end

function WalkTo(x, y)
pkt = {}
pkt.type = 0
pkt.pos_x = x * 32
pkt.pos_y = y * 32
pkt.int_x = -1
pkt.int_y = -1
SendPacketRaw(pkt)
Sleep(100)
end

function HARVEST()
ENABLE_GHOST()
for y = WORLD_SIZE_Y, 0, -1 do
for x = 0, WORLD_SIZE_X do
if GetLocal().world ~= WORLD then return end

if x >= 0 and x < WORLD_SIZE_X and y >= 0 and y < WORLD_SIZE_Y then
local tile = GetTile(x, y)

if tile.fg == ITEM_ID and GetTile(x, y+1).fg == PLATFORM_ID and


tile.ready == true then

FindPath(x, y)
Sleep(40)
Punch(x, y, 18)
Hold()
if not IGNORE_UNHARVESTED_AFTER_PUNCH then
if not MRAY then
Sleep(250)
elseif MRAY then
Sleep(100)
end
else
Sleep(150)
break
end
end
end
end
end
end

function hook(varlist)
if varlist[0]:find("OnTalkBubble") and (varlist[2]:find("The MAGPLANT 5000 is
empty")) then
CHANGE_REMOTE = true
MAG_EMPTY = true
return true
end

if varlist[0]:find("OnDialogRequest") and varlist[1]:find("magplant_edit")


then
local x = varlist[1]:match('embed_data|x|(%d+)')
local y = varlist[1]:match('embed_data|y|(%d+)')
local amount = varlist[1]:match("The machine contains (%d+)")
if amount == nil then amount = 0 end

if x == ""..REMOTE_X.."" and y == ""..REMOTE_Y.."" then


MAG_STOCK = amount
end
return true
end

if varlist[0]:find("OnDialogRequest") and (varlist[1]:find("Item Finder") or


varlist[1]:find("The MAGPLANT 5000 is disabled.")) then
return true
end

if varlist[0]:find("OnDialogRequest") and varlist[1]:find("add_player_info")


then
if CHECK_GHOST then
if varlist[1]:find("|290|") then
IS_GHOST = true
else
IS_GHOST = false
end

CHECK_GHOST = false
end

return true
end

if varlist[0]:find("OnTalkBubble") and varlist[1] == GetLocal().netid and


varlist[2]:find("Ultra World Spray``.") then
local TREES_SPRAYED = varlist[2]:match("Sprayed `2(%w+) trees")
local TIME_TO_PLANT_ALL = os.time() - START_PLANT
RunThread(function()

local payload = [[
{
"content": "",
"embeds": [{
"color": 1146986,
"fields": [{
"name":"Account:",
"value": "Name: **%s**",
"inline": false
},
{
"name": "Information:",
"value": ":earth_asia: Current World: **%s**\
n:gem: Gems: **%s**\n:seedling: UWS Stock: **%s**",
"inline": false
},
{
"name": "Status",
"value": ":green_circle: Used **Ultra World
Spray**!",
"inline": false
},
{
"name": "Statistics",
"value": "<:UWS:1111357396414103602> Sprayed **
%s** trees\n:clock1: Planting took **%s**",
"inline": false
}
],
"thumbnail": {
"url":
"https://cdn.growtopia.tech/items/12600.png"
},
"footer": {
"text": "%s"
}
}]
}]]

SendWebhook(WEBHOOK,
payload:format(removeColorAndSymbols(GetLocal().name), GetLocal().world,
FormatNumber(GetLocal().gems), FormatNumber(GetItemCount(12600)), TREES_SPRAYED,
TIME_TO_PLANT_ALL, os.date("!%a, %b/%d/%Y at %I:%M %p", os.time() + 8 * 60 * 60)))
end)
end
end

AddCallback("Main Hook", "OnVarlist", hook)


Sleep(50)

if not DISABLED then


while true do
Sleep(2000)

if GetLocal().world ~= WORLD then


SendPacket(2, "action|join_request\nname|" .. WORLD .. "")
SendPacket(3, "action|join_request\nname|" .. WORLD .. "\
ninvitedWorld|0")
Sleep(6000)
ENABLE_GHOST()
Sleep(100)
Reconnected()
end

if CHANGE_REMOTE then
Sleep(150)
if GetTile(REMOTE_X + 1, REMOTE_Y).fg == 5638 then
REMOTE_X = REMOTE_X + 1
CheckRemote()
elseif GetTile(REMOTE_X + 1, REMOTE_Y).fg ~= 5638 then
REMOTE_X = START_MAG_X
CheckRemote()
end
CHANGE_REMOTE = false
Sleep(150)
end

if CheckRemote() then
if CHECK_FOR_TREE() then
Sleep(200)

SendPacket(2, "action|dialog_return\ndialog_name|cheats\
ncheck_gems|1")
Sleep(50)

while CHECK_FOR_TREE() do
EditToggle("modfly", true)
HARVEST()
end

if WAIT_TIME > 0 then


WAIT_HOOK()
Sleep(WAIT_TIME * 60 * 1000)
else
Sleep(500)
end
else
CHECK_STOCK = true
Sleep(200)

EditToggle("antibounce", false)
EditToggle("modfly", false)

ROTATION_COUNT = 0

if not MRAY then


START_PLANT = os.time()
while CHECK_FOR_AIR() do
if ROTATION_COUNT == 0 then
AUTOPLANT_SETTINGS()
else
SendPacket(2, "action|dialog_return\
ndialog_name|cheats\ncheck_autoplace|0\ncheck_gems|"..COLLECT_GEMS)
end

Sleep(500)
ENABLE_GHOST()

PLANT_LOOP()
ROTATION_COUNT = ROTATION_COUNT + 1
end
elseif MRAY then
if not RAW_MOVE then
EditToggle("modfly", true)
end
--AUTOPLANT_SETTINGS()
START_PLANT = os.time()

Sleep(250)

PLANT_LOOP()
ROTATION_COUNT = ROTATION_COUNT + 1
end

Sleep(1000)
ROTATION_COUNT = 0

if not MAG_EMPTY and GetLocal().world == WORLD then


log("Total time to plant: "..os.time()-START_PLANT.."
seconds")
Sleep(500)
Sleep(250)
SendPacket(2, "action|dialog_return\ndialog_name|
ultraworldspray")
Sleep(5000)
end
end
end
end
elseif DISABLED then
WARN("`cRemove all water from your world! The script has now been disabled.")
RemoveCallbacks()
end

You might also like