def __init__(self,ip,port = 6000): SWSHReader.__init__(self,ip,port) from structure import EncounterNest8Archive, NestHoleDistributionEncounter8Archive buf = bytearray(open('../resources/bytes/local_raid','rb').read()) Den.LOCALTABLE = EncounterNest8Archive.GetRootAsEncounterNest8Archive(buf,0) buf = self.readEventBlock_RaidEncounter('Event/Current/') Den.EVENTTABLE = NestHoleDistributionEncounter8Archive.GetRootAsNestHoleDistributionEncounter8Archive(buf,0x20) self.resets = 0
# Go to root of PyNXReader import sys import json sys.path.append('../') from structure import PK8 from nxreader import SWSHReader config = json.load(open("../config.json")) r = SWSHReader(config["IP"]) for ii in range(1,7): print(f"Slot: {ii}") pk8 = PK8(r.readParty(ii)) if pk8.isValid() and pk8.ec() != 0: print(pk8.toString()) else: print('Empty') print() r.close()
# Go to root of PyNXReader import sys import json sys.path.append('../') from nxreader import SWSHReader config = json.load(open("../config.json")) r = SWSHReader(config["IP"]) print(f"TID: {r.TrainerSave.TID()}") print(f"SID: {r.TrainerSave.SID()}") print(f"TSV: {r.TrainerSave.TSV()}") print(f"Language: {r.TrainerSave.getLangName()}") print(f"Money: {r.TrainerSave.Money()}$") print(f"Watts: {r.TrainerSave.Watts()}\n") r.close()
# Script to read overworld pokemon # Save the game to update the KCoordinates block # Go to root of PyNXReader import sys import json import signal sys.path.append('../') from nxreader import SWSHReader # Connect to Switch config = json.load(open("../config.json")) r = SWSHReader(config["IP"]) def signal_handler(signal, frame): #CTRL+C handler print("Stop request") r.close() signal.signal(signal.SIGINT, signal_handler) last_info = [] while True: # Refresh KCoords block r.KCoordinates.refresh() pkms = r.KCoordinates.ReadOwPokemonFromBlock() info = [] for pkm in pkms: info.append(str(pkm)) if info != last_info: last_info = info
np = import_numpy() ReadFromConsole = False DumpPath = 'Event/Current/' LocalPath = 'Event/PersonalDump/' config = json.load(open("../config.json")) Island = 0 pmtext = PKMString() buf = bytearray(open('../resources/bytes/local_drop','rb').read()) drop = NestHoleReward8Archive.GetRootAsNestHoleReward8Archive(buf,0) buf = bytearray(open('../resources/bytes/local_bonus','rb').read()) bonus = NestHoleReward8Archive.GetRootAsNestHoleReward8Archive(buf,0) if ReadFromConsole: r = SWSHReader(config["IP"]) if Island == 0: buf = r.readEventBlock_RaidEncounter(DumpPath) elif Island == 1: buf = r.readEventBlock_RaidEncounter_IoA(DumpPath) else: buf = r.readEventBlock_RaidEncounter_CT(DumpPath) else: buf = bytearray(open(LocalPath + 'normal_encount','rb').read()) if Island == 0 else bytearray(open(LocalPath + f'normal_encount_rigel{Island}','rb').read()) eventencounter = NestHoleDistributionEncounter8Archive.GetRootAsNestHoleDistributionEncounter8Archive(buf,0x20) if ReadFromConsole: buf = r.readEventBlock_DropRewards(DumpPath) else: buf = bytearray(open(LocalPath + 'drop_rewards','rb').read()) dropreward = NestHoleDistributionReward8Archive.GetRootAsNestHoleDistributionReward8Archive(buf,0x20)
def connect(self): print("Connecting to: ", self.config["IP"]) self.SWSHReader = SWSHReader(self.config["IP"]) self.update()
class Application(tk.Frame): def __init__(self, master=None): super().__init__(master) self.config = json.load(open("../config.json")) self.master = master self.pack() self.create_widgets() self.last_info = "" signal.signal(signal.SIGINT, self.signal_handler) self.cache = [] def create_widgets(self): self.master.title("Overworld Reader") self.connect_button = tk.Button(self, text="Connect", fg="green", command=self.connect) self.connect_button.grid(column=0,row=1) self.displays = [] self.quit = tk.Button(self, text="Disconnect", fg="red", command=self.disconnect) self.quit.grid(column=1,row=1) def connect(self): print("Connecting to: ", self.config["IP"]) self.SWSHReader = SWSHReader(self.config["IP"]) self.update() def disconnect(self): print("Disconnecting") self.after_cancel(self.after_token) self.SWSHReader.close(False) self.SWSHReader = None def signal_handler(self, signal, frame): self.disconnect() sys.exit(0) def update(self): self.SWSHReader.KCoordinates = KCoordinates(self.SWSHReader.readKCoordinatesBlock()) pkms = self.SWSHReader.KCoordinates.ReadOwPokemonFromBlock() info = [] infocheck = [] for pkm in pkms: info.append(pkm) infocheck.append(pkm.toString()) if infocheck != self.last_info: i = 0 for display in self.displays: for widget in display: widget.grid_forget() self.displays = [] for pkm in info: self.displays.append([]) self.displays[i].append(tk.Text(self,height=5)) self.displays[i][0].grid(column=2+(5 if i%2 else 0), row=2+int((i*3)/2), columnspan=1, rowspan=2) self.displays[i].append(tk.Label(self)) self.displays[i][1].grid(column=0+(5 if i%2 else 0), row=2+int((i*3)/2), columnspan=2, rowspan=2) self.displays[i].append(tk.Label(self)) self.displays[i][2].grid(column=3+(5 if i%2 else 0), row=2+int((i*3)/2), columnspan=2, rowspan=2) s1 = pb.SpriteResource('pokemon', pkm.species, shiny=pkm.getShinyType((pkm.sid<<16) | pkm.tid, pkm.PID)).img_data try: s2 = urllib.request.urlopen(f"https://www.serebii.net/swordshield/ribbons/{pkm.Ribbons[pkm.mark].lower() if pkm.mark != 255 else ''}mark.png").read() im2 = Image.open(io.BytesIO(s2)) image2 = ImageTk.PhotoImage(im2) self.cache.append(image2) self.displays[i][2].config(image=image2) except Exception as e: pass im = Image.open(io.BytesIO(s1)) image = ImageTk.PhotoImage(im) self.cache.append(image) self.displays[i][1].config(image=image) self.last_info = pkm.toString() self.displays[i][0].delete(1.0, tk.END) self.displays[i][0].insert(1.0, pkm.toString()) i += 1 self.last_info = infocheck self.after_token = self.after(1000, self.update)
# Go to root of PyNXReader import sys import json sys.path.append('../') from structure import PK8 from nxreader import SWSHReader config = json.load(open("../config.json")) r = SWSHReader(config["IP"]) while True: empty = True box = int(input('Which box would you like to check? ')) print() for ii in range(1,31): pk8 = PK8(r.readBox(box,ii)) if pk8.isValid() and pk8.ec() != 0: print(f"Box: {box} Slot: {ii}") print(pk8.toString()) empty = False if empty: print('Box is empty\n') stop = input('Continue? (y/n) ' ) if stop != 'y' and stop != 'Y': break r.close()
# Go to root of PyNXReader import sys import json sys.path.append('../') from structure import PK8 from nxreader import SWSHReader config = json.load(open("../config.json")) r = SWSHReader(config["IP"]) while True: pk8 = PK8(r.readHorse()) if pk8.isValid and pk8.ec != 0: print(pk8) else: print("No horse fused\n") stop = input("Check again? (y/n): ") print() if stop == 'n' or stop == 'N': r.close()
# Go to root of PyNXReader import sys import json sys.path.append('../') from structure import PK8 from nxreader import SWSHReader config = json.load(open("../config.json")) r = SWSHReader(config["IP"]) while True: pk8 = PK8(r.readLegend()) if pk8.isValid and pk8.ec != 0: print(pk8) else: print("No battle started\n") stop = input("Check again? (y/n): ") print() if stop == 'n' or stop == 'N': r.close()
# Script to read overworld pokemon # Save the game to update the KCoordinates block # Go to root of PyNXReader import sys import json import signal sys.path.append('../') from nxreader import SWSHReader from structure import KCoordinates # Connect to Switch config = json.load(open("../config.json")) r = SWSHReader(config["IP"]) def signal_handler(signal, frame): #CTRL+C handler print("Stop request") r.close() signal.signal(signal.SIGINT, signal_handler) # Give the KCoords class access to the switch r.KCoordinates.r = r last_info = [] while True: # Refresh KCoords block r.KCoordinates = KCoordinates(r.readKCoordinatesBlock()) pkms = r.KCoordinates.ReadOwPokemonFromBlock()
class Application(tk.Frame): def __init__(self, master=None): super().__init__(master) self.config = json.load(open("../config.json")) self.master = master self.pack() self.create_widgets() self.last_info = "" signal.signal(signal.SIGINT, self.signal_handler) def create_widgets(self): self.master.title("SWSHReader") self.type_var = tk.IntVar() self.connect_button = tk.Button(self, text="Connect", fg="green", command=self.connect) self.connect_button.grid(column=0, row=1) self.current_info_display = tk.Text(self, height=5) self.current_info_display.grid(column=3, row=2, rowspan=3) self.image_display = tk.Label(self) self.image_display.grid(column=1, row=2, columnspan=2, rowspan=3) self.mark_display = tk.Label(self) self.mark_display.grid(column=4, row=2, columnspan=2, rowspan=3) self.wild_choice = tk.Radiobutton(self, text="Wild", variable=self.type_var, value=1) self.legend_choice = tk.Radiobutton(self, text="Legend", variable=self.type_var, value=2) self.horse_choice = tk.Radiobutton(self, text="Horse", variable=self.type_var, value=3) self.wild_choice.grid(column=0, row=2, columnspan=1, rowspan=1) self.legend_choice.grid(column=0, row=3, columnspan=1, rowspan=1) self.horse_choice.grid(column=0, row=4, columnspan=1, rowspan=1) self.wild_choice.select() self.quit = tk.Button(self, text="Disconnect", fg="red", command=self.disconnect) self.quit.grid(column=1, row=1) def connect(self): print("Connecting to: ", self.config["IP"]) self.SWSHReader = SWSHReader(self.config["IP"]) self.update() def disconnect(self): print("Disconnecting") self.after_cancel(self.after_token) self.SWSHReader.close(False) self.SWSHReader = None def signal_handler(self, signal, frame): self.disconnect() sys.exit(0) def update(self): commands = [ self.SWSHReader.readWild, self.SWSHReader.readLegend, self.SWSHReader.readHorse ] read_func = commands[self.type_var.get() - 1] try: pk8 = PK8(read_func()) error = False except Exception as e: print(e) error = True while error: try: pk8 = PK8(read_func()) error = False except: error = True if not pk8.isValid or pk8.ec == 0: print("Invalid or Not Present") self.last_info = "" self.image_display.config(image='') self.mark_display.config(image='') self.current_info_display.delete(1.0, tk.END) if pk8.isValid and pk8.ec != 0 and str(pk8) != self.last_info: info = str(pk8) # print(info) s1 = pb.SpriteResource('pokemon', pk8.species, shiny=pk8.shinyType).img_data if self.type_var.get() - 1 == 0: try: # print(f"https://www.serebii.net/swordshield/ribbons/{pk8.mark.lower()}mark.png") s2 = urllib.request.urlopen( f"https://www.serebii.net/swordshield/ribbons/{pk8.mark.lower()}mark.png" ).read() im2 = Image.open(io.BytesIO(s2)) image2 = ImageTk.PhotoImage(im2) self.image2 = image2 self.mark_display.config(image=image2) info += f"Mark: {pk8.mark}" # print(info) except Exception as e: print(e) else: self.mark_display.config(image='') im = Image.open(io.BytesIO(s1)) image = ImageTk.PhotoImage(im) self.image = image self.image_display.config(image=image) self.last_info = info self.current_info_display.delete(1.0, tk.END) self.current_info_display.insert(1.0, info) self.after_token = self.after(1000, self.update)
class Application(tk.Frame): def __init__(self, master=None): super().__init__(master) self.config = json.load(open("../config.json")) self.master = master self.pack() self.create_widgets() self.last_info = "" signal.signal(signal.SIGINT, self.signal_handler) self.cache = [] def create_widgets(self): self.master.title("Overworld Reader") self.connect_button = tk.Button(self, text="Connect", fg="green", command=self.connect) self.connect_button.grid(column=0,row=1) self.displays = [] self.quit = tk.Button(self, text="Disconnect", fg="red", command=self.disconnect) self.quit.grid(column=1,row=1) def connect(self): print("Connecting to: ", self.config["IP"]) self.SWSHReader = SWSHReader(self.config["IP"]) self.update() def disconnect(self): print("Disconnecting") self.after_cancel(self.after_token) self.SWSHReader.close(False) self.SWSHReader = None def signal_handler(self, signal, frame): self.disconnect() sys.exit(0) def update(self): self.SWSHReader.KCoordinates.refresh() pkms = self.SWSHReader.KCoordinates.ReadOwPokemonFromBlock() info = [] infocheck = [] for pkm in pkms: info.append(pkm) infocheck.append(pkm.ec) if infocheck != self.last_info: i = 0 for display in self.displays: for widget in display: widget.grid_forget() self.displays = [] for pkm in info: self.displays.append([]) self.displays[i].append(tk.Text(self,height=5)) self.displays[i][0].grid(column=2+(5 if i%2 else 0), row=2+int((i*3)/2), columnspan=1, rowspan=2) self.displays[i].append(tk.Label(self)) self.displays[i][1].grid(column=0+(5 if i%2 else 0), row=2+int((i*3)/2), columnspan=2, rowspan=2) self.displays[i].append(tk.Label(self)) self.displays[i][2].grid(column=3+(5 if i%2 else 0), row=2+int((i*3)/2), columnspan=2, rowspan=2) try: mark_image = get_mark(pkm.mark) self.cache.append(mark_image) self.displays[i][2].config(image=mark_image) except Exception as e: pass pokemon_image = get_pokemon(pkm.species, pkm.getShinyType(((pkm.sid<<16) | pkm.tid), pkm.pid)) self.cache.append(pokemon_image) self.displays[i][1].config(image=pokemon_image) self.last_info = str(pkm) self.displays[i][0].delete(1.0, tk.END) self.displays[i][0].insert(1.0, str(pkm)) i += 1 self.last_info = infocheck self.after_token = self.after(1000, self.update)