TDS Automation API

Macro Recorder API

API-only reference for Space Hub Tower Defense Simulator automation. Use this page for recorder loading, global settings, tower methods, abilities, lobby control, and complete Lua snippets.

Premium required Tower Defense Simulator Lua snippets

How to Use

  1. Get your Premium key.
  2. Load the recorder script in your executor.
  3. Configure global _G settings before loading the library.
  4. For 24/7 auto-farm, place the script in autoexec and set _G.AutoRejoin = true.
loader.lua
script_key = "your_premium_key";
loadstring(game:HttpGet("https://f.spacehub.wtf/loader.lua"))()

Record files are saved to executor/workspace/Space-Hub/Games/TDS V2/script.lua. Put script.lua in executor/autoexec or run it manually.

example.lua
loadstring(game:HttpGet("https://f.spacehub.wtf/Scripts/TDS/Recorder/Library.lua"))()

Core Engine Methods + Global Config

VariableTypeDescription
_G.AutoPickupsboolAuto-collect SnowCharms / Lorebooks.
_G.AutoSkipboolAutomatically vote to skip waves.
_G.AutoChainboolCycle Commander "Call Of Arms".
_G.AutoDJboolAuto-activate DJ Booth "Drop The Beat".
_G.AutoNecroboolAuto-activate Necromancer "Raise The Dead".
_G.AutoMercenaryboolAuto Air-Drop from Mercenary Base.
_G.AutoMilitaryboolAuto Airstrike from Military Base.
_G.AntiLagboolRemove effects/projectiles to reduce lag.
_G.AutoRejoinboolAuto-rejoin after match with webhook logging.
_G.SendWebhookboolSend match results to Discord.
_G.WebhookstringDiscord webhook URL.
MethodParametersDescription
TDS:Place(name, x, y, z)name, coordinatesPlace tower and return a 1-based index.
TDS:Upgrade(idx, path)index, path 1/2Upgrade tower. Path defaults to 1.
TDS:Sell(idx, reqWave)index, optional waveSell tower and remove it from list.
TDS:SellAll(reqWave)optional waveSell all placed towers.
TDS:SetTarget(idx, mode, reqWave)First, Strong, Last, RandomSet targeting mode.
TDS:GetWave()noneReturns current wave number.
TDS:VoteSkip(start, end)start wave, optional end waveAuto vote-skip from start to end.
TDS:UnlockTimeScale()noneUnlock timescale tickets.
TDS:TimeScale(val)0.5, 1, 1.5, 2Cycle to desired speed.
TDS:Ready()noneReady up during match intermission.
config.lua
_G.AutoPickups = true
_G.AutoSkip = true
_G.AutoRejoin = true

local TDS = loadstring(game:HttpGet("...Library.lua"))()
TDS:Place("Scout", 0.29, -6.36, 17.00)

TDS:SetOption

TDS:SetOption(index, "OptionName", "Value", requiredWave)

TowerOptionValues
Mercenary Base"Unit 1" / "Unit 2" / "Unit 3""Grenadier", "Rifleman", "Riot Guard", "Field Medic"
Trapper"Trap""Spike" or "Landmine"
DJ Booth"Track""Green", "Red", "Purple"
setoption.lua
TDS:SetOption(1, "Unit 1", "Grenadier")
TDS:SetOption(2, "Trap", "Landmine")
TDS:SetOption(3, "Track", "Purple", 10)

TDS:Ability

TDS:Ability(index, "AbilityName", dataTable, loop)

TowerAbilityData format
Commander"Call Of Arms" / "Support Caravan"No data.
DJ Booth"Drop The Beat"No data.
Medic"Ubercharge"No data.
Hacker"Hologram Tower"{ towerToClone = index, towerPosition = Vector3 }
Pursuit"Patrol"{ ["position"] = Vector3 }
Gatling Gun"FPS"{ ["enabled"] = true }
Brawler"Reposition"{ ["position"] = Vector3 }
Mercenary / Military"Air-Drop" / "Airstrike"{ pathName = 1, dist = number, directionCFrame = CFrame.new() }
abilities.lua
TDS:Ability(1, "Call Of Arms", {}, true)
TDS:Ability(2, "Support Caravan", {})
TDS:Ability(3, "Drop The Beat", {})
TDS:Ability(4, "Ubercharge", {})
TDS:Ability(5, "Hologram Tower", { towerToClone = 6, towerPosition = Vector3.new(25, 10, 30) })
TDS:Ability(7, "Patrol", { ["position"] = Vector3.new(15, 5, 45) })
TDS:Ability(8, "FPS", { ["enabled"] = true })
TDS:Ability(9, "Reposition", { ["position"] = Vector3.new(30, 5, 60) })
TDS:Ability(10, "Air-Drop", { ["pathName"] = 1, ["dist"] = 100 })
TDS:Ability(11, "Airstrike", { ["pathName"] = 1, ["pointToEnd"] = 150, ["directionCFrame"] = CFrame.new(0, 0, 0) })
For Mercenary/Military, dist and pointToEnd control path position. 0 means enemy spawn; max value depends on the map.

Advanced

Use autoexec for 24/7 AFK automation and set _G.AutoRejoin = true.

  • dist defines where Mercenary Base Air-Drop triggers on the path.
  • pointToEnd defines where Military Base Airstrike triggers on the path.
  • 0 is enemy spawn; higher values are further down the path.
  • 999 often targets the very end.
airstrike.lua
TDS:Ability(militaryIdx, "Airstrike", { pathName = 1, pointToEnd = 110 })
MethodDescription
TDS:GetGameState()Returns "LOBBY" or "GAME".
TDS:GetRewards()Parses post-game screen into rewards data.
TDS:RestartWithRejoin()Resets and teleports back to game.
Your GitHub strategy should start only after START STRATEGY. You do not need TDS:Loadout(), TDS:Mode(), or TDS:GameInfo() inside the strategy body.
If you were teleported to lobby unexpectedly, make sure _G.AutoRejoin = false when you do not want rejoin automation.

Lobby Methods

MethodParametersDescription
TDS:Mode(difficulty)stringSelect matchmaking mode, for example "Frost", "Hardcore", "Pizza Party".
TDS:Loadout(...)tower namesEquip towers and unequip current loadout.
TDS:GameInfo(map, modifiers)map name, modifiers tableVote for map and modifiers. VIP uses override.
TDS:StartGame()noneSend ready in lobby.
lobby.lua
TDS:Loadout("Mercenary Base", "DJ Booth", "Hacker", "Scout", "Necromancer")
TDS:Mode("Frost")
TDS:GameInfo("Honey Valley", {})
TDS:StartGame()

Complete Configuration Snippet

complete_config.lua
_G.AutoPickups = true
_G.AutoSkip = true
_G.AutoChain = false
_G.AutoDJ = false
_G.AutoNecro = false
_G.AutoMercenary = false
_G.AutoMilitary = false
_G.AntiLag = true
_G.AutoRejoin = true
_G.SendWebhook = false

local TDS = loadstring(game:HttpGet("https://f.spacehub.wtf/Scripts/TDS/Recorder/Library.lua"))()

TDS:Loadout("Mercenary Base", "DJ Booth", "Hacker", "Scout", "Necromancer")
TDS:Mode("Frost")
TDS:GameInfo("Honey Valley", {})

TDS:UnlockTimeScale()
TDS:TimeScale(2)

TDS:Place("Scout", 0.2901, -6.3679, 17.0009, true)
TDS:Place("Scout", -1.0073, -6.3679, 17.8993, true)
TDS:Upgrade(1)
TDS:SetOption(19, "Track", "Red")
TDS:Ability(26, "Call Of Arms", nil, true)