коряво у меня расчитано - не кастует.
Покопался в сурсах твоей проги. Позаимствовал парочку решений, дабы ещё больше сократить код. Расччитывает также коряво, как и раньше, но хоть убей не вижу разницы.
Code:
sub test()
var String = VectorPoints(UO.GetX(), UO.GetY(), UO.GetX() + 15, UO.GetY() + 10), i
UO.Print(String)
For i = 2 to GetWordAmount(String, ' ') step 2
UO.MFGI('add', '1339', GetWord(String, i - 1, ' '), GetWord(String, i, ' '), UO.GetZ() + 1, '0x0025', 'cave floor')
Next
Endsub
sub deltile()
var MaxRange = 18
var X, Y, Z, Tiles
var mX, mY, mZ
mX = UO.GetX('self')
mY = UO.GetY('self')
mZ = UO.GetZ('self')
for Y = MaxRange - ( MaxRange * 2 ) to MaxRange
for X = MaxRange - ( MaxRange * 2 ) to MaxRange
UO.MFGI('clear', '1339', mX+X, mY+Y, UO.GetZ('self'))
next
next
end sub
Sub VectorPoints(sx, sy, ex, ey)
var Coordinates = str(sx) + ' ' + str(sy) + ' ', dx, dy, ax, ay, slope
Repeat
dx = sx - ex
dy = sy - ey
ax = Absolute(dx)
ay = Absolute(dy)
If dx <> 0 and dy <> 0 then
If int(ax / ay) > 2 or int(ay / ax) > 2 then
If int(ax / ay) > 2 then
slope = 'x'
else
slope = 'y'
Endif
else
slope = 0
Endif
else
slope = 1
Endif
If slope then
If ay == 0 or slope == 'x' then
sx = sx - Sing(dx)
Endif
If ax == 0 or slope == 'y' then
sy = sy - Sing(dy)
Endif
else
sx = sx - Sing(dx)
sy = sy - Sing(dy)
Endif
Coordinates = Coordinates + str(sx) + ' ' + str(sy) + ' '
UO.Print(str(sx) + ' ' + str(sy))
UO.Print(str(ax) + ' ' + str(ay))
Until sx == ex and sy == ey
Return Coordinates
Endsub
Sub GetWord(st, nom, div)
var tmpst, i, dlin, kol = 0, start = 0
dlin = len(st)
For i = 0 to dlin - 1
If mid(st, i, 1) == div or i == dlin - 1 then
kol = kol + 1
If kol == nom then
tmpst = mid(st, start, i - start)
Return tmpst
else
While mid(st, i, 1) == div
i = i + 1
Wend
If kol == nom - 1 then
start = i
Endif
Endif
Endif
Next
tmpst = ''
Return tmpst
Endsub
Sub GetWordAmount(str, div)
var i, Amount = 0
For i = 0 to len(str) - 1
If str[i] == div then
Amount = Amount + 1
Endif
Next
Return Amount
Endsub
Sub Sing(val)
If val < 0 then
Return -1
else
Return 1
Endif
Endsub
Sub Absolute(val)
If val < 0 then
Return -val
else
Return val
Endif
Endsub