Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Move ├───────────────────────────────────────────────────────────────────────
- function move()
- return { { map = '-1,13', custom = main } }
- end
- -- Main ├───────────────────────────────────────────────────────────────────────
- function main()
- if not onMap('-1,13') then
- return
- end
- local change_map = lua.fn:chain(changeMap)
- local function door(cell)
- use(cell, -1)
- return door
- end
- local npc_reply = lua.fn:chain(npc.reply)
- local npc_dopple = function(id, start)
- npc.npc(id, 1)
- if start then -- ugly
- npc_reply(-1)(-2)(-1)
- else
- npc_reply(-1)(-1)
- end
- -- Start fight
- leaveDialog()
- end
- -- Sadida
- go({0,13})({0,9})({-1,9})
- door(342)(274)
- npc_dopple(442, ({ start = true }).start)
- change_map(408)(397)
- -- Cra
- go({0,9})({0,3})
- door(401)(311)
- npc_dopple(439)
- change_map(472)(({451,465})[1])
- -- Iop
- go({1,3})
- door(356)
- change_map(({415,429})[1])
- npc_dopple(434)
- door(269)
- change_map(({410,425})[1])
- -- Rogue
- go({3,3})
- door(191)
- npc.npc(1422, 1)
- npc_reply(-1)
- door(159)(338)(311)(323)
- npc_dopple(1414)
- door(({495,509})[1])
- change_map(347)
- door(({439,453})[1])(({329,343})[1])
- npc.npc(1422, 1)
- npc_reply(-2)
- door(241)
- -- Xelor
- go({3,1})
- door(373)(346)
- npc_dopple(437)
- change_map(410)(({397,411})[1])
- -- Eliotrope
- go({4,0})
- door(274)
- change_map('right')('left')
- npc_dopple(2834)
- change_map('right')('bottom')
- use(498, ({ sufokia = 166742, amakna = 166741 }).amakna)
- -- Eniripsa
- go({7,1})
- door(412)(290)(426)(346)
- npc_dopple(435)
- door(({348,362})[1])(({337,350})[1])(({319,333})[1])
- change_map('bottom')
- -- Osamodas
- go({8,2})
- door(261)(242)
- npc_dopple(436)
- change_map(458)(424)
- -- Feca
- go({8,5})({12,5})
- door(400)(290)
- npc_dopple(433)
- door(451)(424)
- -- Foggernaut
- go({9,5})({9,1})
- door(217)(344)(398)
- change_map(499)
- npc_dopple(1594)
- door(311)
- change_map(494)(({452,466})[1])
- use(438, ({ sufokia = 146232, amakna = 146308 }).amakna)
- -- Pandawa
- go({4,1})({4,-2})
- door(381)(317)
- npc_dopple(672)
- change_map(452)(452)
- -- Huppermage
- go({-4,-2})
- door(272)
- change_map('top')('right')('top')
- door(474)
- npc_dopple(3053)
- change_map('left|bottom')('bottom')('left')('left|bottom')
- door(177)
- -- Sram
- go({-3,-2})({-3,0})({-4,0})
- door(({317,384})[1])(275)
- npc_dopple(441)
- door(416)
- change_map(({388,442})[1])
- -- Enutrof
- go({-3,0})({-1,-4})
- door(415)(311)
- npc_dopple(440)
- door(325)
- change_map(({456,469})[1])
- -- Ecaflip
- go({1,-4})({1,-5})
- door(314)(245)(305)
- npc_dopple(438)
- door(233)(214)
- change_map(({382,397})[1])
- -- Masqueraider
- go({1,-8})
- door(144)(107)(184)(184)(287)(290)
- npc_dopple(1425)
- door(284)
- change_map(511)
- door(402)(393)(394)(347)
- -- Sacrier
- go({0,-8})({0,-7})({-2,-7})
- door(194)
- change_map(394)
- go({-2,-8})
- door(286)(285)(243)
- npc_dopple(443)
- change_map(({460,473})[1])(({401,414})[1])(({486,499})[1])
- go({-2,-5})
- door(367)
- change_map(({437,452})[1])
- go({0,-4})({0,13})
- end
- -- Utility ├────────────────────────────────────────────────────────────────────
- function go(destination, fn)
- local destination_str = lua.table:join(destination, ',')
- local current_map = lua.table:map(lua.string:split(currentMap(), ','), tonumber)
- local x_current, y_current = unpack(current_map)
- local x_destination, y_destination = unpack(destination)
- local direction = function(start, stop) return (start == stop) and 0 or (start < stop) and 1 or -1 end
- local x_direction = { [-1] = 'left', [0] = nil, [1] = 'right' }
- local y_direction = { [-1] = 'top', [0] = nil, [1] = 'bottom' }
- local map = { map = current_map,
- direction = lua.table:join(lua.table:compact({ x_direction[direction(x_current, x_destination)],
- y_direction[direction(y_current, y_destination)] }), '|') }
- local saved_current_map_str = currentMap()
- if fn then fn(map) end
- if (currentMap() == saved_current_map_str) then
- changeMap(map.direction)
- end
- return (currentMap() == destination_str) and go or go(destination, fn)
- end
- -- Library ├────────────────────────────────────────────────────────────────────
- lua = {
- fn = {
- chain = function(self, fn)
- local function helper(...)
- fn(...)
- return helper
- end
- return helper
- end,
- curry = function(self, fn, nargs)
- nargs = nargs or debug.getinfo(fn, 'u').nparamsend
- local helper = function(args, n)
- return n < 1 and fn(unpack(args)) or (function(...) return helper(lua.table:concat(args, {...}), n - #{...}) end)
- end
- return helper({}, nargs)
- end,
- },
- math = {
- infinite = (1/0),
- },
- object = {
- compare = function(self, a, b)
- if type(a) ~= type(b) then
- return false
- end
- if type(a) ~= 'table' or type(b) ~= 'table' then
- return a == b
- end
- for key, value_a in pairs(a) do local value_b = b[key]
- if not value_b or not self:compare(value_a, value_b) then
- return false
- end
- end
- for key, value_b in pairs(b) do local value_a = a[key]
- if not value_a then
- return false
- end
- end
- return true
- end,
- copy = function(self, object)
- if type(object) ~= 'table' then
- return object
- end
- local res = {}
- for key, value in pairs(object) do
- res[self:copy(key)] = self:copy(value)
- end
- return res
- end,
- range = function(self, start, stop, step)
- local step = (step ~= nil) and step or (start < stop) and 1 or -1
- local res = {}
- for value = start, stop, step do
- res[#res + 1] = value
- end
- return res
- end,
- tap = function(self, object, fn)
- return fn(object)
- end,
- },
- string = {
- split = function(self, str, sep)
- res = {}
- pattern = string.format("([^%s]+)", sep)
- str:gsub(pattern, (function(match) res[#res + 1] = match end))
- return res
- end,
- },
- table = {
- compact = function(self, _table)
- return self:filter(_table, (function(value) return (value ~= nil) end))
- end,
- concat = function(self, head, ...)
- local head = lua.object:copy(head)
- for key, tail in pairs({...}) do
- for key, value in pairs(tail) do
- head[#head + 1] = value
- end
- end
- return head
- end,
- filter = function(self, _table, fn)
- local filtered = {}
- for key, value in pairs(lua.object:copy(_table)) do
- if fn(value) then
- filtered[#filtered + 1] = value
- end
- end
- return filtered
- end,
- flatten = function(self, _table, level)
- level = level or lua.math.infinite
- return self:inject((function(memo, value)
- return (level < 1) or (type(value) ~= 'table') and self:push(memo, value) or self:concat(memo, self:flatten(value, (level - 1)))
- end), {}, _table)
- end,
- head = function(self, _table)
- return _table[1]
- end,
- inject = function(self, fn, initial, _table)
- local memo = lua.object:copy(initial)
- for key, value in pairs(_table) do
- memo = fn(memo, value)
- end
- return memo
- end,
- insert = function(self, index, _table, object)
- local smart_index = (function(index, length) return (index > 0) and index or ((length + 2) + index) end)
- local res = lua.object:copy(_table)
- local index = smart_index(index, #res)
- local entry = res[index]
- res[index] = object
- return not entry and res or self:insert((index + 1), res, entry)
- end,
- join = function(self, _table, separator)
- return self:inject((function(memo, value) return memo .. (separator or '') .. value end), self:head(_table), self:tail(_table))
- end,
- map = function(self, objects, fn)
- local collection = {}
- for key, object in pairs(objects) do
- collection[key] = fn(object)
- end
- return collection
- end,
- merge = function(self, a, b, fn)
- local a_copy, b_copy = lua.object:copy(a), lua.object:copy(b)
- local merged = a_copy
- for key, value in pairs(b_copy) do
- merged[key] = (merged[key] == nil) and value or (fn == nil) and value or fn(key, a_copy[key], b_copy[key])
- end
- return merged
- end,
- push = function(self, _table, object)
- return self:insert(-1, _table, object)
- end,
- reverse = function(self, _table)
- local reversed = {}
- for key, value in pairs(_table) do
- reversed[#_table + 1 - key] = value
- end
- return reversed
- end,
- select = function(self, _table, fn)
- return self:head(self:filter(_table, fn))
- end,
- tail = function(self, _table)
- return { select(2, unpack(_table)) }
- end,
- },
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement