Skip to content

Commit

Permalink
feat: add sdk6 request teleport (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
kuruk-mm authored Nov 17, 2023
1 parent 5e008a1 commit 2d930c4
Showing 1 changed file with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1 +1,23 @@
module.exports.requestTeleport = async function (body) { return {} }
// @deprecated, only available for SDK6 compatibility. Use RestrictedActions/TeleportTo
module.exports.requestTeleport = async function (body) {
const { destination } = req
if (destination === 'magic' || destination === 'crowd') {
return await Deno.core.ops.op_teleport_to([
0,
0,
]);
} else if (!/^\-?\d+\,\-?\d+$/.test(destination)) {
return await Promise.reject(`teleportTo: invalid destination ${destination}`)
}

const coords = destination.split(',');

// Convert the separate parts to whole numbers.
let x = parseInt(coords[0], 10);
let y = parseInt(coords[1], 10);

return await Deno.core.ops.op_teleport_to([
x,
y,
]);
}

0 comments on commit 2d930c4

Please sign in to comment.