CCBlueX Forum

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    [JS][1.8.9][1.12.2]新手模板|避坑|排错|水影脚本编写中文教程|LiquidBounce Script

    Chinese
    1
    1
    123
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ?
      A Former User last edited by A Former User

      /// api_version=2
      // 第一行三个斜杠的注释不要动,是脚本版本2的固定标识
      // 下面是固定写法
      var script = registerScript({
          name: "MyScript",
          version: "1.0.0",
          authors: ["My Name"]
      })
      // 玩家在游戏内发送消息
      // mc.thePlayer.sendChatMessage()
      // 让文本显示在游戏聊天框里(不会发送聊天消息)
      // 支持原版颜色符号§,不支持&
      // Chat.print()
      
      script.registerModule(
          {
              name: "MyModule",//模块名称
              category: "Misc", //分类 Movement, Misc, Combat, Fun, Player, Exploit, World, Render
              description: "An example module created with LiquidBounce's script API."//描述
          },
          function (module) {
              Chat.print("Module registered.")//模块已注册
              module.on(
                  "enable",
                  function () {
                      Chat.print("Module enabled.")//模块已启用
                  }
              )
              module.on(
                  "disable",
                  function () {
                      Chat.print("Module disabled.")//模块已禁用
                  }
              )
              module.on(
                  "update",
                  function () {
                      //Minecraft游戏每秒有20 tick
                      //此function每一个tick就运行一次
                      //所以每秒执行20次
                      //不要在这里写for、while循环,否则Windows电脑的内存会立刻升高,
                      //而且会把虚拟内存也占满,电脑马上就会蓝屏,写循环要去script.registerModule的外面写,也就是和script.registerModule并列。
                  }
              )
          })
      // 如果要定义变量名,直接写,前面好像只能加var
      // js代码会被编译成java字节码,所以如果是从网上复制的js代码,需要把let,const这些去掉
      // 不然的话,游戏里不会出现你写的功能
      // 如果js代码在浏览器上正常运行,不代表在这里能运行,多用Chat.print(),一步一测试
      

      参考 https://liquidbounce.net/docs/ScriptAPI/Getting Started

      1 Reply Last reply Reply Quote 0
      • First post
        Last post
      About
      • Terms of Service
      • Privacy Policy
      • Status
      • Contact Us
      Downloads
      • Releases
      • Source code
      • License
      Docs
      • Tutorials
      • CustomHUD
      • AutoSettings
      • ScriptAPI
      Community
      • Forum
      • Guilded
      • YouTube
      • Twitter
      • D.Tube