CCBlueX Forum

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

    Unsolved [HELP] Converting Core scripts to Script API v2 scripts.

    ScriptAPI
    6
    11
    315
    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.
    • G
      GolikeAzzis last edited by

      Hi, so I need help converting a Core script to the normal Script API version. I am using a custom build of Liquidbounce (Lint), so Core scripts don't work on it (From what I noticed). And I'm a complete noob at scripting.

      What do I need to do to convert this script from Core to the normal API v2 version?

      This script is by CzechHek

      ///api_version=2
      (script = registerScript({
          name: "AutoSafeWalk",
          version: "1.3",
          authors: ["CzechHek"]
      })).import("Core.lib");
      
      module = {
          category: "Movement",
          description: "SafeWalk that activates if there is a gap exceeding maximal fall distance.",
          values: [
              airsafe = value.createBoolean("AirSafe", true),
              maxfalldistance = value.createInteger("MaxFallDistance", 5, 0, 255)
          ],
          onMove: function (e) {
              (mc.thePlayer.onGround || airsafe.get()) && e.setSafeWalk(!isAboveGround());
          }
      }
      
      function isAboveGround() {
          for (i = 0, bp = new BlockPos(mc.thePlayer); i++ < maxfalldistance.get();) if (!mc.theWorld.isAirBlock(bp.down(i))) return true
      }
      

      This is what I could figure out so far from studying the normal API v2 scripts. (No, it doesn't work after I tested it.)

      ///api_version=2
      var script = registerScript({
          name: "AutoSafeWalk",
          version: "1.3",
          authors: ["CzechHek"]
      });
      
      script.registerModule({
          name: "AutoSafeWalk"
          category: "Movement",
          description: "SafeWalk that activates if there is a gap exceeding maximal fall distance.",
          values: [
              airsafe = value.createBoolean("AirSafe", true),
              maxfalldistance = value.createInteger("MaxFallDistance", 5, 0, 255)
          ],
          onMove: function (e) {
              (mc.thePlayer.onGround || airsafe.get()) && e.setSafeWalk(!isAboveGround());
          }
      });
      
      function isAboveGround() {
          for (i = 0, bp = new BlockPos(mc.thePlayer); i++ < maxfalldistance.get();) if (!mc.theWorld.isAirBlock(bp.down(i))) return true
      }
      

      I apologize in advance if I sound stupid.

      CzechHek 1 Reply Last reply Reply Quote 0
      • skiddermaster412
        skiddermaster412 Banned last edited by

        you nearly in the right path,
        see how the other scripts work.
        you are far away from converting the script
        here take it, just to educate you and not to steal it.

        ///api_version=2
        var script = registerScript({
            name: "AutoSafeWalk",
            version: "1.3",
            authors: ["CzechHek"]
        });
        var airsafe = Setting.boolean({
            name: "AirSafe",
            default: true
        });
        var maxfalldistance = Setting.integer({
            name:"MaxFallDistance",
            default: 5,
            min: 0,
            max: 255
        });
        script.registerModule({
            name: "AutoSafeWalk"
            category: "Movement",
            description: "SafeWalk that activates if there is a gap exceeding maximal fall distance.",
            settings: {
                airsafe: airsafe,
                maxfalldistance: maxfalldistance
            }
        }, function (module){
            module.on("move", function(e){
                (mc.thePlayer.onGround || airsafe.get()) && e.setSafeWalk(!isAboveGround());
            });
        });
        
        function isAboveGround() {
            var BlockPos = Java.type("net.minecraft.util.BlockPos");
            for (i = 0, bp = new BlockPos(mc.thePlayer); i++ < maxfalldistance.get();) if (!mc.theWorld.isAirBlock(bp.down(i))) return true
        }
        

        compare and see what errors you had.
        (btw i made this without testing so if it works it works)

        G ? 2 Replies Last reply Reply Quote 0
        • skiddermaster412
          skiddermaster412 Banned last edited by

          i used to port CzechHek's scripts all of the time, i don't really like core

          1 Reply Last reply Reply Quote 0
          • G
            GolikeAzzis @skiddermaster412 last edited by

            @skiddermaster412 After testing this, it did not work. I'm trying to fix it by reading more scripts. Thank you for your help though.

            1 Reply Last reply Reply Quote 0
            • ?
              A Former User @skiddermaster412 last edited by A Former User

              @skiddermaster412 do you even remember how to add a setting
              edit: nvm im retarded, the reason why it doesnt work its bcz you didnt import BlockPos
              edit 2:nvm im too retarded

              1 Reply Last reply Reply Quote 0
              • ?
                A Former User last edited by

                i just realized something

                chrome_QCsZ62uzah.png

                chrome_kGAA4HPbPW.png

                cant find setSafeWalk in the docs idfk

                V 1 Reply Last reply Reply Quote 1
                • V
                  vinci @Guest last edited by

                  @sigma-bot apparently its from api v1
                  https://github.com/CCBlueX/LiquidScript/blob/master/ScriptAPI-v1 Docs/module/event.md
                  7b8a7ad3-ffd0-4b6a-b2f0-c008af8a365e-image.png

                  CzechHek 1 Reply Last reply Reply Quote 1
                  • CzechHek
                    CzechHek @GolikeAzzis last edited by CzechHek

                    @golikeazzis they work on it, however as far as I remember Lint had nothing special to offer, spammed errors of missing images in logs and its scriptapi somehow didn't fully work

                    garbage

                    G Painis Bot 2 Replies Last reply Reply Quote 0
                    • CzechHek
                      CzechHek @vinci last edited by

                      @nvinci what does events have to do with scriptapi

                      1 Reply Last reply Reply Quote 0
                      • G
                        GolikeAzzis @CzechHek last edited by

                        @czechhek Oh okay, thanks.

                        1 Reply Last reply Reply Quote 0
                        • Painis Bot
                          Painis Bot Banned @CzechHek last edited by

                          This post is deleted!
                          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