• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript camelot-unchained.hasClientAPI函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中@csegames/camelot-unchained.hasClientAPI函数的典型用法代码示例。如果您正苦于以下问题:TypeScript hasClientAPI函数的具体用法?TypeScript hasClientAPI怎么用?TypeScript hasClientAPI使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了hasClientAPI函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: slash

export function slash(command: string, callback?: (response: any) => void) {
  if (hasClientAPI()) {
    // If the / command includes a callback, then send the response
    // back to the caller
    if (callback) listen(callback);
    client.SendSlashCommand(command);
  } else {
    if (callback) callback({ type: 'complete', complete: 'Simulated completion' });
  }
}
开发者ID:codecorsair,项目名称:Camelot-Unchained,代码行数:10,代码来源:slash.ts


示例2: listen

export function listen(cb: any) {
  if (hasClientAPI()) {
    callbacks[++listening] = cb;
    function cancel() {
      delete callbacks[this.id];
    }
    const res = {
      id: listening,
      cancel,
    };
    if (listening > 1) return res;
    client.OnConsoleText((text: string) => {
      const lines = text.split(/[\r\n]/g);
      const what = lines[0];
      switch (what) {
        default:
          // ERROR: prefixed errors
          if (text.match(/^ERROR: /)) {
            response.type = 'error';
            const errors = text.substr(7).split('\n');
            response.errors = (response.errors || []).concat(errors);
            return;
          }

          // Errors possibly
          if (text.match(/^Tried /)
            || text.match(/^No nearby /)                    // for /harvest
            || text.match(/^Failed /)
          ) {
            response.type = 'error';
            (response.errors = response.errors || []).push(text);
            return;
          }

          // Signals the end of the / command
          if (text.match(/^Running /)) {
            response.complete = text;
            delaySend();
            return;
          }

          (response.unknown = response.unknown || []).push(text);
          break;
      }
    });
    return res;
  }
}
开发者ID:codecorsair,项目名称:Camelot-Unchained,代码行数:48,代码来源:slash.ts


示例3: hasClientAPI

export const isClient = () => {
  return hasClientAPI();
};
开发者ID:codecorsair,项目名称:Camelot-Unchained,代码行数:3,代码来源:slash.ts


示例4: default

export default () => {
  if (!hasClientAPI()) return;

  /**
   * Set field of view
   */
  registerSlashCommand('fov', 'set your field of view, client accepts values from 20 -> 179.9', (params: string = '') => {
    const argv = parseArgs(params);
    const degrees = argv._.length > 0 ? argv._[0] : 120;
    client.FOV(degrees);
  });

  /**
   * Drop a temporary light at the characters feet
   */
  registerSlashCommand(
    'droplight',
    'drop a light at your location, options: (colors are 0-255) droplight <intensity> <radius> <red> <green> <blue>',
    (params: string = '') => {
      if (params.length === 0) return;

      const argv = parseArgs(params);
      if (argv._.length > 0) {
        const intensity = argv._.length >= 0 ? argv._[0] : 1;
        const radius = argv._.length > 1 ? argv._[1] : 20;
        const red = argv._.length > 2 ? argv._[2] : 100;
        const green = argv._.length > 3 ? argv._[3] : 100;
        const blue = argv._.length > 4 ? argv._[4] : 100;
        client.DropLight(intensity, radius, red, green, blue);
        return;
      }

      const intensity = argv.intensity ? argv.intensity : 1;
      const radius = argv.radius > 1 ? argv.radius : 20;
      const red = argv.red > 2 ? argv.red : 100;
      const green = argv.green > 3 ? argv.green : 100;
      const blue = argv.blue > 4 ? argv.blue : 100;
      client.DropLight(intensity, radius, red, green, blue);
    });

  /**
   * Remove the closest dropped light to the player
   */
  registerSlashCommand('removelight', 'removes the closest dropped light to the player', (params: string = '') => {
    client.RemoveLight();
  });

  /**
   * Remove all lights placed with the drop light command
   */
  registerSlashCommand('resetlights', 'removes all dropped lights from the world', (params: string = '') => {
    client.ResetLights();
  });

  /**
   * Count all the placed blocks in the world
   */
  registerSlashCommand('countblocks', 'count all placed blocks in the world.', () => {
    client.CountBlocks();
    setTimeout(() => systemMessage(`There are ${client.placedBlockCount} blocks in this world.`), 1000);
  });

  /**
   * Quit the game
   */
  registerSlashCommand('exit', 'quit the game', () => client.Quit());

  registerSlashCommand(
    'replacesubstance',
    'replace blocks with type args[0] with blocks with type of args[1]', (params: string = '') => {
      if (params.length === 0) return;
      const argv = parseArgs(params);
      if (argv._.length >= 2) {
        client.ReplaceSubstance(argv._[0], argv._[1]);
      }
      return;
    });
  registerSlashCommand(
    'replaceshape',
    'replace blocks with shape args[0] with blocks with shape of args[1]', (params: string = '') => {
      if (params.length === 0) return;
      const argv = parseArgs(params);
      if (argv._.length >= 2) {
        client.ReplaceShapes(argv._[0], argv._[1]);
      }
      return;
    });
  registerSlashCommand(
    'replaceselectedsubstance',
    'replace blocks with type args[0] with blocks with type of args[1] within selected range', (params: string = '') => {
      if (params.length === 0) return;
      const argv = parseArgs(params);
      if (argv._.length >= 2) {
        client.ReplaceSelectedSubstance(argv._[0], argv._[1]);
      }
      return;
    });
  registerSlashCommand(
    'replaceselectedshape',
    'replace blocks with shape args[0] to blocks with shape of args[1] within selected range', (params: string = '') => {
//.........这里部分代码省略.........
开发者ID:codecorsair,项目名称:Camelot-Unchained,代码行数:101,代码来源:clientCommands.ts



注:本文中的@csegames/camelot-unchained.hasClientAPI函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript camelot-unchained.registerSlashCommand函数代码示例发布时间:2022-05-28
下一篇:
TypeScript loading.TdLoadingService类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap