|
@@ -550,15 +550,18 @@ class ScriptPort(object):
|
|
|
# Call this to chain something after we exit.
|
|
|
return self.defer
|
|
|
|
|
|
- def deactivate(self):
|
|
|
+ def deactivate(self, andExit=True):
|
|
|
self.state = 0
|
|
|
log.debug("ScriptPort.deactivate ({0})".format(self.times_left))
|
|
|
- self.queue_game.put(self.nl + Boxes.alert("Trading Script deactivating...", width=50))
|
|
|
+ self.queue_game.put(self.nl + Boxes.alert("Trading Script deactivating..."))
|
|
|
assert(not self.save is None)
|
|
|
self.observer.load(self.save)
|
|
|
self.save = None
|
|
|
if self.defer:
|
|
|
- self.defer.callback('done')
|
|
|
+ if andExit:
|
|
|
+ self.defer.callback({'exit':True})
|
|
|
+ else:
|
|
|
+ self.defer.callback('done')
|
|
|
self.defer = None
|
|
|
|
|
|
def player(self, chunk: bytes):
|
|
@@ -1001,8 +1004,6 @@ class ScriptExplore(object):
|
|
|
# Our Stuff, Not our pants!
|
|
|
self.dense = [] # We did a density, store that info.
|
|
|
self.clear = [] # Warps that we know are clear.
|
|
|
- self.didDense = False
|
|
|
- self.didHolo = False
|
|
|
self.highsector = 0 # Selected Sector to move to next!
|
|
|
self.highwarp = 0 # Selected Sector's Warp Count!
|
|
|
self.stacksector = set() # Set of sectors that we have not picked but are unexplored... even though we did a holo!
|
|
@@ -1046,19 +1047,22 @@ class ScriptExplore(object):
|
|
|
# Call this to chain something after we exit.
|
|
|
return self.defer
|
|
|
|
|
|
- def deactivate(self):
|
|
|
+ def deactivate(self, andExit=False):
|
|
|
self.state = 0
|
|
|
log.debug("ScriptExplore.deactivate()")
|
|
|
assert(not self.save is None)
|
|
|
self.observer.load(self.save)
|
|
|
self.save = None
|
|
|
if self.defer:
|
|
|
- self.defer.callback('done')
|
|
|
+ if andExit:
|
|
|
+ self.defer.callback({'exit':True})
|
|
|
+ else:
|
|
|
+ self.defer.callback('done')
|
|
|
self.defer = None
|
|
|
|
|
|
def player(self, chunk: bytes):
|
|
|
# If we receive anything -- ABORT!
|
|
|
- self.deactivate()
|
|
|
+ self.deactivate(True)
|
|
|
|
|
|
def send2game(self, txt):
|
|
|
self.queue_player.put(txt)
|
|
@@ -1069,8 +1073,6 @@ class ScriptExplore(object):
|
|
|
)
|
|
|
|
|
|
def resetStuff(self):
|
|
|
- self.didDense = False
|
|
|
- self.didHolo = False
|
|
|
self.dense = []
|
|
|
self.clear = []
|
|
|
self.highwarp = 0
|
|
@@ -1093,7 +1095,7 @@ class ScriptExplore(object):
|
|
|
|
|
|
else:
|
|
|
self.send2player(Boxes.alert("I've run out of places to look ({0}/{1}).".format(self.maxtimes - self.times, self.maxtimes)))
|
|
|
- self.deactivate()
|
|
|
+ self.deactivate(True)
|
|
|
|
|
|
def game_over(self, msg):
|
|
|
self.send2player(Boxes.alert("STOP: {0} ({1}/{2}).".format(msg, self.maxtimes - self.times, self.maxtimes)))
|
|
@@ -1156,7 +1158,7 @@ class ScriptExplore(object):
|
|
|
elif "You don't have a long range scanner." in line:
|
|
|
log.warn("FATAL: No Long Range Scanner Installed!")
|
|
|
self.send2player(Boxes.alert("You need a Long Range Scanner!"))
|
|
|
- self.deactivate()
|
|
|
+ self.deactivate(True)
|
|
|
return
|
|
|
# elif "Long Range Scan" in line:
|
|
|
# self.state += 1
|
|
@@ -1450,19 +1452,22 @@ class ScriptSpace(object):
|
|
|
# Call this to chain something after we exit.
|
|
|
return self.defer
|
|
|
|
|
|
- def deactivate(self):
|
|
|
+ def deactivate(self, andExit=False):
|
|
|
self.state = 0
|
|
|
log.debug("ScriptPort.deactivate ({0})".format(self.times_left))
|
|
|
assert(not self.save is None)
|
|
|
self.observer.load(self.save)
|
|
|
self.save = None
|
|
|
if self.defer:
|
|
|
- self.defer.callback('done')
|
|
|
+ if andExit:
|
|
|
+ self.defer.callback({'exit':True})
|
|
|
+ else:
|
|
|
+ self.defer.callback('done')
|
|
|
self.defer = None
|
|
|
|
|
|
def player(self, chunk: bytes):
|
|
|
# If we receive anything -- ABORT!
|
|
|
- self.deactivate()
|
|
|
+ self.deactivate(True)
|
|
|
|
|
|
def unknown_search(self, starting_sector):
|
|
|
seen = set()
|
|
@@ -1535,11 +1540,11 @@ class ScriptSpace(object):
|
|
|
self.this_sector = sector
|
|
|
else:
|
|
|
log.warn("FATAL: Density for {0} is {1}".format(sector, self.density[sector]))
|
|
|
- self.deactivate()
|
|
|
+ self.deactivate(True)
|
|
|
return
|
|
|
else:
|
|
|
log.error("{0} not in density scan? (how's that possible?)".format(sector))
|
|
|
- self.deactivate()
|
|
|
+ self.deactivate(True)
|
|
|
return
|
|
|
elif self.state == 7:
|
|
|
# Ok, we're in a new sector (single stepping through space)
|
|
@@ -1939,7 +1944,7 @@ class ProxyMenu(object):
|
|
|
# self.queue_game.put(self.prompt)
|
|
|
self.prompt = None
|
|
|
|
|
|
- # Possibly: Send '\r' to re-display the prompt
|
|
|
+ # Send '\r' to re-display the prompt
|
|
|
# instead of displaying the original one.
|
|
|
self.game.queue_player.put("d")
|
|
|
|
|
@@ -1958,9 +1963,43 @@ class ProxyMenu(object):
|
|
|
self.observer.connect("player", self.scripts_player)
|
|
|
self.scripts_menu()
|
|
|
|
|
|
- def deactivate_scripts_menu(self, *_):
|
|
|
+ def deactivate_scripts_menu(self, *data):
|
|
|
+ log.warn("deactivate_scripts_menu ({0})".format(data))
|
|
|
self.observer.disconnect("player", self.scripts_player)
|
|
|
- self.observer.connect("player", self.player)
|
|
|
+ self.observer.connect("player", self.player)
|
|
|
+
|
|
|
+ # Did they request exit?
|
|
|
+ if len(data) > 0 and type(data[0]) == dict:
|
|
|
+ info = data[0]
|
|
|
+ if 'exit' in info and info['exit']:
|
|
|
+ log.warn("exit proxy...")
|
|
|
+ # Exit Proxy Code
|
|
|
+ self.queue_game.put(Boxes.alert("Proxy done.", base="green",style=3))
|
|
|
+ self.observer.load(self.save)
|
|
|
+ self.save = None
|
|
|
+ # It isn't running (NOW), so don't try to stop it.
|
|
|
+ # self.keepalive.stop()
|
|
|
+ self.keepalive = None
|
|
|
+ # Ok, this is a HORRIBLE idea, because the prompt might be
|
|
|
+ # outdated.
|
|
|
+ # self.queue_game.put(self.prompt)
|
|
|
+ self.prompt = None
|
|
|
+
|
|
|
+ # I'm not sure where we are, we might not be at a prompt.
|
|
|
+ # let's check!
|
|
|
+ if re.match(r"Command \[TL=.* \(\?=Help\)\? :", self.game.getPrompt()):
|
|
|
+ # Send '\r' to re-display the prompt
|
|
|
+ # instead of displaying the original one.
|
|
|
+ self.game.queue_player.put("d")
|
|
|
+
|
|
|
+ # Were we asked to do something when we were done here?
|
|
|
+ if self.defer:
|
|
|
+ reactor.CallLater(0, self.defer.callback)
|
|
|
+ # self.defer.callback()
|
|
|
+ self.defer = None
|
|
|
+ return
|
|
|
+
|
|
|
+ log.warn("calling welcome_back")
|
|
|
self.welcome_back()
|
|
|
|
|
|
def scripts_menu(self, *_):
|