Code: Select all
def FindResources():
  global Resource
  Cache = []
Code: Select all
def FindResources():
  global Resource
  Cache = []
Code: Select all
Resources = set()
Code: Select all
  for i in Cache:
    for j in Resources:
      if i == j:
        Match = 1
        break
    if not Match:
      Resources += i
Code: Select all
Resources |= set(Cache)
Code: Select all
from datetime import datetime as dt
import time
Resources = set(); t_Hatchet = 0x0F43; t_Pickaxe = 0x0E85; id_LogsContainer = 1; id_IngotsContainer = 1; id_ToolsContainer = 1
def FindResources():
  Cache = []
  Match = 0
  global Resources
  for i in [3274, 3275, 3276, 3277, 3280, 3283, 3286, 3289, 3291, 3292, 3294, 3295, 3296, 3299, 3302, 3394, 3395, 3417, 3440, 3461, 4792, 4793, 4794, 4795]:
    for t, x, y, z in GetStaticTilesArray(GetX(Self()) - 50, GetY(Self()) - 50, GetX(Self()) + 50, GetY(Self()) + 50, WorldNum(), i):
      Cache.append((t, x, y, z, 'Tree'))
  for i in [240, 241, 242, 243]:
    for t, x, y, z in GetLandTilesArray(GetX(Self()) - 50, GetY(Self()) - 50, GetX(Self()) + 50, GetY(Self()) + 50, WorldNum(), i):
      Cache.append((t, x, y, z, 'Rock'))
  Resources |= set(Cache)
def FindDistanceToResource(x, y):
  if abs(GetX(Self()) - x) < abs(GetY(Self()) - y):
    return abs(GetX(Self()) - x)
  else:
    return abs(GetY(Self()) - y)
def FindTheNearestPoint(res = 'all'):
  i = 100500
  Point = []
  global Resources
  for t, x, y, z, rt in Resources:
    if FindDistanceToResource(x, y) < i:
      i = FindDistanceToResource(x, y)
      if not GetGlobal('stelth', str(x) + ',' + str(y)) or int(GetGlobal('stelth', str(x) + ',' + str(y))) + 600 <= time.time():
        if res == 'all':
          Point = (t, x, y, rt)
        elif res == 'Tree' == rt:
          Point = (t, x, y, rt)
        elif res == 'Rock' == rt:
          Point = (t, x, y, rt)
  return Point
def GetResources(Point = ()):
  msg_t, msg_e = 'put|loosen some rocks|fail', 'There is no|far away|mining|so close|line of sight|t use|appears immune|nothing|reach this|far away'
  t, x, y, rt = Point
  SetGlobal('stelth', str(x) + ',' + str(y), str(time.time()))
  while GetX(Self()) not in range(x - 1, x + 2) or GetY(Self()) not in range(y - 1, y + 2):
    newMoveXY(x, y, 0, 1, 1)
  Now = dt.now()
  while InJournalBetweenTimes(msg_e, Now, dt.now()) < 0:
    if TargetPresent():
      CancelTarget()
    if WarMode():
      SetWarMode(0)
    WaitTargetTile(t, x, y, GetZ(Self()))
    if rt == 'Tree':
      UseType(t_Hatchet, -1)
    elif rt == 'Rock':
      UseType(t_Pickaxe, -1)
    WaitJournalLine(dt.now(), msg_t + '|' + msg_e, 15000)
FindResources()
print(Resources)
print(FindTheNearestPoint(res = 'Rock'))Для того, чтобы стелс+питон понимал кириллицу, нужно чтобы 1ая или 2ая строка в файле со скриптом была такаяnah nah wrote:И ещё вопрос, можно ли как-то изменить кодировку юникода, которая используется по умолчанию?
Code: Select all
# -*- coding: mbcs -*-Code: Select all
Stack += {'Craft': {'Item': i, 'Count': Count - FindCount()}}Code: Select all
05:06:18:668 [Charname]: CraftCode: Select all
def Reload(ToolType = 0x1EBC, Count = 2, Container = id_ToolsContainer):
  while Count(ToolType) < Count and FindType(ToolType, Container) != 0:
    MoveItem(FindType(ToolType, Container), Count, Backpack())
    Wait(MoveDelay)Code: Select all
01:37:21:306 [Charname]:   File "D:\Games\UO\Stealth\Scripts\Crafter Bot Yew UORPG.py", line 126, in Reload
TypeError: 'int' object is not callable