tiles = [] from tlib import * import sys import time z = 0 x = 0 # sys.argv.append("world1.wld") if len(sys.argv) < 2: print "No World supplied, shutting down in 5 seconds" time.sleep(5) else: origin = sys.argv[1] world = World(origin) header = world.header for tile in world.tiles: if tile[2] >= 0: tile = (tile[0], tile[1], 255, tile[3]) tiles.append(tile) ## if tile[0] == 0: ## ntile = (1, tile[1], tile[2], tile[3]) ## elif tile[0] == 2: ## if random()>0.01: ## ntile = (1, tile[1], tile[2], tile[3]) ## else: ## ntile = tile ## elif tile[2] > 0:
from tinterface import World world = World("world3.wld") world.ready_chests() z = 0 items = {} for x in world.chests: if x != None: print x world.ready_signs() for x in world.signs: if x: print x world.ready_npcs() print "NPCs" for x in world.npcs: print x print world.header with open("world2.wld", "rb") as f: f.seek(world.signs.endpos - 2) content = f.read(2) for c in content: print c,
def run(worldpath=None): if hasattr(sys, "frozen"): os.chdir(os.path.dirname(unicode(sys.executable, sys.getfilesystemencoding()))) if len(sys.argv) < 2 and worldpath == None: print("No World supplied, shutting down in 5 seconds") time.sleep(5) else: if len(sys.argv) < 2: world = World(worldpath) else: world = World(sys.argv[1]) print("Reading world data, this may take a while") world.ready_npcs() print("Data prepared") npcs = [] print("Following NPCs found:") for npc in world.npcs: npcs.append(npc) if npc[2]: print("%s without a home") % (npc[0]) else: print("%s with a home") % (npc[0]) world.make_split() while 1: print("") print("Select a NPC to add") x = 1 print("0: Save & Exit") for npc in npclist: print("%d: %s") % (x, npc) x += 1 pick = x while pick >= x or pick < 0: try: pick = int(raw_input("NPC:")) except: pass if pick >= x or pick < 0: print("Please put in a number and then hit enter, cant be that hard, right?") i = pick if pick == 0: print("Writing world data") with open("4.part", "wb") as f: for npc in npcs: set_npc(f, npc) set_npc(f, None) join("worldx.wld") cleanup() print("Done") time.sleep(5) break else: pick = 0 print("There are %d remaining slots for npcs") % (1000 - len(npcs)) print('How many of "%s" do you want to add?') % (npclist[i - 1]) while pick < 1: try: pick = int(raw_input("NPC:")) except: print("Error occured when parsing input, please try again writing ONE number") if pick > 1000 - len(npcs): print("You cant add that many npcs, Terraria cant take it, have pity.") pick = 0 for x in range(pick): npcs.append(( npclist[i - 1], (world.header["spawn"][0] * 16, (world.header["spawn"][1] - 3) * 16), 1, (world.header["spawn"][0], world.header["spawn"][1] - 3))) print("%d %s added to 'to do' list") % (pick, npclist[i - 1])
try: os.remove(n) except: pass def cleanup(): for x in range(6): try: os.remove(str(x) + ".part") except: pass if __name__ == "__main__": from tinterface import World world = World("world2.wld") # world.make_split() from tlib import * with open("0.part", "rb") as f: h = get_header(f) with open("other.part", "wb") as f: set_header(f, h) with open("other.part", "rb") as f: print(f.read()) join("world6.wld", False) print(world.header["name"] + " done")