コード例 #1
0
cf = ClientInterfacer()

# Find the cauldron on the ground.
itemsOn   = cf.getItemsOfType("on")
cauldrons = []
for item in itemsOn:
    if item.name == "cauldron":
        cauldrons.append(item)
if len(cauldrons) != 1:
    cf.logError("Expected 1 cauldron on ground, got %d" % len(cauldrons))
    sys.exit(0)
cauldron = cauldrons[0]

# Find the largest pile of waters in the player's inventory.
waters = None
inv = cf.getInventory()
for item in inv:
    if item.name.endswith(" water") or item.name.endswith(" waters"):
        if waters is None or item.num > waters.num:
            waters = item
    if "ingred" in item.name:
        cf.logError("You already have an item matching \"ingred\"; I'm not "
            "programmed to uniquify names well enough to deal with this.")
        sys.exit(0)
if waters is None:
    cf.logError("You don't have any water.")
    sys.exit(0)

# TODO: Generator instead of list.
commands = []
コード例 #2
0
from lib.client_interfacer import ClientInterfacer, Color

cf = ClientInterfacer(targetPendingCommands=100)

cf.draw("scripttell me the tag of an item to use for the test.")
cf.waitForScripttell()
s = cf.getNextScripttell()
tag = int(s)

testItem = None
for item in cf.getInventory():
    if item.tag == tag:
        testItem = item
        break

if testItem is None:
    cf.fatal("Couldn't find item with tag %d" % tag)

dropCmd   = cf.getDropCommand(testItem)
pickupCmd = cf.getPickupCommand(testItem)
for i in range(20):
    # We set targetPendingCommands high enough that these will all dispatch
    # immediately.
    cf.queueCommand(dropCmd)
    cf.queueCommand(pickupCmd)
cf.queueCommand("east")
cf._sendToClient("sync 6")

# Fall back to passthru.py.
while 1:
    s = cf._readLineFromClient()