Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- from ctypes import * # Used to interact with DLL
- from direct.task import Task # Used to manage the Callback timer
- class DiscordRPC:
- zone2imgdesc =
- {
- 1000: ["rainbow-reef", "In Rainbow Reef"],
- 1100: ["coral-court", "On Coral Court"],
- 1200: ["ocean-overpass", "On Ocean Overpass"],
- 1300: ["pirate-place", "On Pirate Place"],
- 2000: ["toon-island-central", "In Toon Island Central"],
- 2100: ["beach-ball-boulevard", "On Beach Ball Boulevard"],
- 2200: ["aloha-avenue", "On Aloha Avenue"],
- 2300: ["pineapple-place", "On Pineapple Place"],
- 3000: ["cirrus-circus", "In Cirrus Circus"],
- 3100: ["balloon-boulevard", "On Balloon Boulevard"],
- 3200: ["horizon-hill", "On Horizon Hill"],
- 3300: ["stratus-strait", "On Stratus Strait"],
- 4000: ["olive-oasis", "In Olive Oasis"],
- 4100: ["desert-drive", "On Desert Drive"],
- 4200: ["sandy-station", "On Sandy Station"],
- 4300: ["palm-tree-place", "On Palm Tree Place"],
- 5000: ["withering-woods", "In Withering Woods"],
- 5100: ["willow-way", "On Willow Way"],
- 5200: ["torched-terrace", "On Torched Terrace"],
- 5300: ["dastardly-drive", "On Dastardly Drive"],
- 6000: ["acorn-acres", "At Acorn Acres"],
- 8000: ["toontown-speedway", "In Toontown Speedway"],
- 9000: ["minty-mines", "In Minty Mines"],
- 9100: ["candy-close", "On Candy Close"],
- 9200: ["peppermint-place", "On Peppermint Place"],
- 10000: ["bossbot-hq", "In Bossbot HQ"],
- 10100: ["bossbot-hq", "In the CEO Lobby"],
- 10500: ["front-three", "In the Front Three"],
- 10600: ["middle-six", "In the Middle Six"],
- 10700: ["back-nine", "In the Back Nine"],
- 11000: ["sellbot-hq","At Sellbot HQ"],
- 11100: ["sellbot-hq", "In the VP Lobby"],
- 11200: ["sellbot-factory", "In the Sellbot Factory"],
- 11500: ["sellbot-factory", "In the Sellbot Factory"],
- 12000: ["cashbot-hq", "At Cashbot HQ"],
- 12100: ["cashbot-hq", "In the CFO Lobby"],
- 12500: ["cashbot-mint", "In A Coin Mint"],
- 12600: ["cashbot-mint", "In A Dollar Mint"],
- 12700: ["cashbot-mint", "In A Bullion Mint"],
- 13000: ["lawbot-hq", "At Lawbot HQ"],
- 13100: ["lawbot-hq","In The CJ Lobby"],
- 13200: ["lawbot-hq","In The DA Office Lobby"],
- 13300: ["lawbot-office", "In The Lawbot Office A"],
- 13400: ["lawbot-office", "In The Lawbot Office B"],
- 13500: ["lawbot-office", "In The Lawbot Office C"],
- 13600: ["lawbot-office", "In The Lawbot Office D"],
- 14000: ["tutorial", "In The Toontorial"],
- 16000: ["estate", "At A Toon Estate"],
- 17000: ["minigames", "In The Minigames Area"],
- 18000: ["party", "At A Toon Party"],
- }
- def __init__(self):
- self.CodeHandle = cdll.LoadLibrary("SDK.dll") # Load the RP code
- self.CodeHandle.DLLMain()
- self.UpdateTask = None
- self.details = "Loading" # The writing next to the photo
- self.image = "logo" #The main photo
- self.imageTxt = "Loading Toontown" # Hover text for the main photo
- self.smallLogo = "" # Small photo in corner
- self.smallTxt = "" # Text on hover of that photo
- self.state = "" # Displayed underneath details - used for boarding groups
- self.PartySize = 0
- self.MaxParty = 0
- def stopBoarding(self): #Boarding groups :D
- self.PartySize = 0
- self.state = ""
- self.MaxParty = 0
- self.setData()
- def AllowBoarding(self, size):
- self.state = "In A Boarding Group"
- self.PartySize = 1
- self.MaxParty = size
- self.setData()
- def setBoarding(self, size): # Sets how many members are in a boarding group
- self.PartySize = size
- self.setData()
- def setData(self): # Manually update all vars
- self.CodeHandle.DoCallbacks()
- details = self.details
- image = self.image
- imageTxt = self.imageTxt
- smallLogo = self.smallLogo
- smallTxt = self.smallTxt
- state = self.state
- party = self.PartySize
- maxSize = self.MaxParty
- self.CodeHandle.SetData(details.encode('utf_8'), state.encode('utf_8'), smallLogo.encode('utf_8'), smallTxt.encode('utf_8'), image.encode('utf_8'), imageTxt.encode('utf_8'), maxSize, party)
- def DoCallbacks(self, task): # Recieves any messages from discord and handles them
- self.CodeHandle.DoCallbacks()
- return task.again
- def UpdateTasks(self, task):
- self.UpdateTask = True
- self.setData()
- return task.again
- def AvChoice(self): # Call in pick-a-toon
- self.image = "logo"
- self.details = "Picking-A-Toon"
- self.setData()
- def Launching(self): # Call When loading game - toontownstart
- self.image = "logo"
- self.details = "Loading"
- self.setData()
- def Making(self): # Call in make-a-toon
- self.image = "logo"
- self.details = "Making A Toon"
- self.setData()
- def StartTasks(self): # Call JUST before base.run() in toontown-start
- taskMgr.doMethodLater(10, self.UpdateTasks, 'UpdateTask')
- taskMgr.doMethodLater(0.016, self.DoCallbacks, 'RPC-Callbacks')
- def setZone(self,Zone): # Set image and text based on the zone
- if not isinstance(Zone, int):
- return
- Zone -= Zone % 100
- data = self.zone2imgdesc.get(Zone,None)
- if data:
- self.image = data[0]
- self.details = data[1]
- self.setData()
- else:
- print("Error: Zone Not Found!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement