#Script API Debugger Playground

1 messages · Page 1 of 1 (latest)

lapis lagoon
#

Dedicated to posting code blocks just to use @teal vortex to debug your code. Hopefully this doesn't flood #1067535608660107284. And you can submit your feedback here about the bot.

#

Script API Debugger Playground

ocean imp
#

ayo

#
world.scoreboard
teal vortexBOT
#
Debug Result

There are errors in this [code](#1078766125057327194 message):

@minecraft/server-gametest.d.ts:120:13 - error TS2416: Property 'setVelocity' in type 'SimulatedPlayer' is not assignable to the same property in base type 'Player'.
  Type '(velocity: Vector3) => void' is not assignable to type '(velocity: Vector3) => never'.
    Type 'void' is not assignable to type 'never'.

120             setVelocity(velocity: minecraftserver.Vector3): void;
                ~~~~~~~~~~~
@minecraft/server-gametest.d.ts:331:9 - error TS2416: Property 'setVelocity' in type 'SimulatedPlayer' is not assignable to the same property in base type 'Player'.
  Type '(velocity: Vector3) => void' is not assignable to type '(velocity: Vector3) => never'.
    Type 'void' is not assignable to type 'never'.

331         setVelocity(velocity: minecraftserver.Vector3): void;
            ~~~~~~~~~~~

ocean imp
#

fine..

naive hemlock
#
world.getDimension(„aether“).runCommandAsync(„give @a dirt“)
#

How to debug this?

lapis lagoon
#

?script debug

gilded brambleBOT
#
ScriptAPI - Debug Bot

Here have a test bot dedicated towards debuging script-api code blocks within discord by yourself.

Usage
1. Make sure to use JS Code Block formating
`

console.warn("like this")

2. ` Long press Code Block message

3. Click Apps from the menu

4. Select Debug (Preview) for beta and Debug (Stable) for stable

5. Pog! you should be seeing all the issues, if any

lapis lagoon
teal vortexBOT
#
Debug Result

There are errors in this [code](#1078766125057327194 message):

<repl>.js:1:20 - error TS1127: Invalid character.

1 world.getDimension(„aether“).runCommandAsync(„give @a dirt“)
                     ~
<repl>.js:1:21 - error TS2304: Cannot find name 'aether'.

1 world.getDimension(„aether“).runCommandAsync(„give @a dirt“)
                      ~~~~~~
<repl>.js:1:27 - error TS1127: Invalid character.

1 world.getDimension(„aether“).runCommandAsync(„give @a dirt“)
                            ~
<repl>.js:1:46 - error TS1127: Invalid character.

1 world.getDimension(„aether“).runCommandAsync(„give @a dirt“)
                                               ~
<repl>.js:1:47 - error TS2304: Cannot find name 'give'.

1 world.getDimension(„aether“).runCommandAsync(„give @a dirt“)
                                                ~~~~
<repl>.js:1:52 - error TS1005: ',' expected.

1 world.getDimension(„aether“).runCommandAsync(„give @a dirt“)
                                                     ~
<repl>.js:1:54 - error TS1146: Declaration expected.

1 world.getDimension(„aether“).runCommandAsync(„give @a dirt“)
                                                       
<repl>.js:1:55 - error TS2304: Cannot find name 'dirt'.

1 world.getDimension(„aether“).runCommandAsync(„give @a dirt“)
                                                        ~~~~
<repl>.js:1:59 - error TS1127: Invalid character.

1 world.getDimension(„aether“).runCommandAsync(„give @a dirt“)
                                                            ~
<repl>.js:1:60 - error TS1128: Declaration or statement expected.

1 world.getDimension(„aether“).runCommandAsync(„give @a dirt“)
                                                             ~

#
Debug Result

There are errors in this [code](#1078766125057327194 message):

<repl>.js:1:20 - error TS1127: Invalid character.

1 world.getDimension(„aether“).runCommandAsync(„give @a dirt“)
                     ~
<repl>.js:1:21 - error TS2304: Cannot find name 'aether'.

1 world.getDimension(„aether“).runCommandAsync(„give @a dirt“)
                      ~~~~~~
<repl>.js:1:27 - error TS1127: Invalid character.

1 world.getDimension(„aether“).runCommandAsync(„give @a dirt“)
                            ~
<repl>.js:1:46 - error TS1127: Invalid character.

1 world.getDimension(„aether“).runCommandAsync(„give @a dirt“)
                                               ~
<repl>.js:1:47 - error TS2304: Cannot find name 'give'.

1 world.getDimension(„aether“).runCommandAsync(„give @a dirt“)
                                                ~~~~
<repl>.js:1:52 - error TS1005: ',' expected.

1 world.getDimension(„aether“).runCommandAsync(„give @a dirt“)
                                                     ~
<repl>.js:1:54 - error TS1146: Declaration expected.

1 world.getDimension(„aether“).runCommandAsync(„give @a dirt“)
                                                       
<repl>.js:1:55 - error TS2304: Cannot find name 'dirt'.

1 world.getDimension(„aether“).runCommandAsync(„give @a dirt“)
                                                        ~~~~
<repl>.js:1:59 - error TS1127: Invalid character.

1 world.getDimension(„aether“).runCommandAsync(„give @a dirt“)
                                                            ~
<repl>.js:1:60 - error TS1128: Declaration or statement expected.

1 world.getDimension(„aether“).runCommandAsync(„give @a dirt“)
                                                             ~
@minecraft/server-gametest.d.ts:120:13 - error TS2416: Property 'setVelocity' in type 'SimulatedPlayer' is not assignable to the same property in base type 'Player'.
  Type '(velocity: Vector3) => void' is not assignable to type '(velocity: Vector3) => never'.
    Type 'void' is not assignable to type 'never'.

120             setVelocity(velocity: minecraftserver.Vector3): void;
                ~~~~~~~~~~~
@minecraft/server-gametest.d.ts:331:9 - error TS2416: Property 'setVelocity' in type 'SimulatedPlayer' is not assignable to the same property in base type 'Player'.
  Type '(velocity: Vector3) => void' is not assignable to type '(velocity: Vector3) => never'.
    Type 'void' is not assignable to type 'never'.

331         setVelocity(velocity: minecraftserver.Vector3): void;
            ~~~~~~~~~~~

naive hemlock
#

Too many?

#

I think i broke it bcs of the „

teal vortexBOT
#
No errors

No errors in [code](#1078766125057327194 message)

lapis lagoon
#

Reverted setVelocity return type change

teal vortexBOT
#
Debug Result

There are errors in this [code](#1078766125057327194 message):

<repl>.js:1:20 - error TS1127: Invalid character.

1 world.getDimension(„aether“).runCommandAsync(„give @a dirt“)
                     ~
<repl>.js:1:21 - error TS2304: Cannot find name 'aether'.

1 world.getDimension(„aether“).runCommandAsync(„give @a dirt“)
                      ~~~~~~
<repl>.js:1:27 - error TS1127: Invalid character.

1 world.getDimension(„aether“).runCommandAsync(„give @a dirt“)
                            ~
<repl>.js:1:46 - error TS1127: Invalid character.

1 world.getDimension(„aether“).runCommandAsync(„give @a dirt“)
                                               ~
<repl>.js:1:47 - error TS2304: Cannot find name 'give'.

1 world.getDimension(„aether“).runCommandAsync(„give @a dirt“)
                                                ~~~~
<repl>.js:1:52 - error TS1005: ',' expected.

1 world.getDimension(„aether“).runCommandAsync(„give @a dirt“)
                                                     ~
<repl>.js:1:54 - error TS1146: Declaration expected.

1 world.getDimension(„aether“).runCommandAsync(„give @a dirt“)
                                                       
<repl>.js:1:55 - error TS2304: Cannot find name 'dirt'.

1 world.getDimension(„aether“).runCommandAsync(„give @a dirt“)
                                                        ~~~~
<repl>.js:1:59 - error TS1127: Invalid character.

1 world.getDimension(„aether“).runCommandAsync(„give @a dirt“)
                                                            ~
<repl>.js:1:60 - error TS1128: Declaration or statement expected.

1 world.getDimension(„aether“).runCommandAsync(„give @a dirt“)
                                                             ~

rapid bane
#

@lapis lagoon, any way they might be considerate on pinning this so it doesn't get lost or mixed up with the other traffic flow?

#

I would also suggest maybe restricting the bot here if that is even possible for a forum or better yet, just restrict usage in the general chat while allowing it to be used in this forum and other forums related to questions? To reduce clutter in the general chat which appears to be your main goal.

tardy oyster
#
world.events.tick.subscribe(data => {
  
})
teal vortexBOT
#
No errors

No errors in [code](#1078766125057327194 message)

warm forge
#
let {events: {beforeChat: chat, beforeItemUseOn: itemBlock},say: s} = world
chat.subscribe((evd) => {s(evd.message)})
itemBlock.subscribe((evd) => {s(evd.item.typeId)})
teal vortexBOT
#
No errors

No errors in [code](#1078766125057327194 message)

warm forge
#
let {events: {beforeChat: {subscribe: chat}, beforeItemUseOn: {subscribe: itemBlock}},say: s} = world
chat((evd) => {s(evd.message)})
itemBlock((evd) => {s(evd.item.typeId)})
teal vortexBOT
#
No errors

No errors in [code](#1078766125057327194 message)

lapis lagoon
# rapid bane I would also suggest maybe restricting the bot here if that is even possible for...

Discord doesn't have permissions split between posts in forums. Imo the bot is needed in gen chat due to someone in general chat just post a problem with their code not working. This place is mainly for people testing the bot's usage, and sometimes they might send large code blocks in general chat to test the bot and flood the chat because there wasn't any places for that sort of stuff (in this server btw, my discord server already is for bot testing).

lapis lagoon
#

Which one is better?

vestal shell
# lapis lagoon Which one is better?

On the first thought 2 but secondly, I think both got their ups and downs. The right one has a little highlighting which is nice, but ONE error takes up a minimum of 5 lines while the first one only takes 2 per error.

#

btw did u code the debugger itselt all by yourself?

lapis lagoon
vestal shell
#

Ah k

vestal shell
# lapis lagoon Which one is better?

Maybe its worth a thought to not use embeds, sure they look really nice but at the cost of (what feels) like 200px width not sure if thats really worth it. Esspecially for the right one; Cuz the red underline always kinda points to nowhere because of the line break it takes up a lot of lines in general as mentioned and theres also just an extra line needed to seperate 2 error blocks. And btw just a quick addition to the right one would maybe be that its you trim the whitespaces before the code line because thats just straight imported from the code.

rapid bane
#

I always favor syntax highlighting. Additional lines at the cost of readability and simply making it easier on the eyes is always worth the cost imho.

#

I choose the second one.

lean kernel
#
world.events.playerJoin.subscribe(data => data.player.addTag('joined') && data.playerId.removeTag('sidebar'));
setTickInterval(() => {
    world.getAllPlayers().filter(p => p.hasTag('joined')).forEach(p => {
        if (!p.isSneaking || p.velocity.y <= 0.5)
            return p.removeTag('joined');
    });
}, 10);
teal vortexBOT
#
Debug Result

There are errors in this [code](#1078766125057327194 message):

<repl>.js:1:48 - error TS2551: Property 'player' does not exist on type 'PlayerJoinEvent'. Did you mean 'playerId'?

1 world.events.playerJoin.subscribe(data => data.player.addTag('joined') && data.playerId.removeTag('sidebar'));
                                                 ~~~~~~

  @minecraft/server.d.ts:3499:22
    3499             readonly playerId: string;
                              ~~~~~~~~
    'playerId' is declared here.
<repl>.js:1:89 - error TS2339: Property 'removeTag' does not exist on type 'string'.

1 world.events.playerJoin.subscribe(data => data.player.addTag('joined') && data.playerId.removeTag('sidebar'));
                                                                                          ~~~~~~~~~
<repl>.js:2:1 - error TS2304: Cannot find name 'setTickInterval'.

2 setTickInterval(() => {
  ~~~~~~~~~~~~~~~

lapis lagoon
#

cool stuff

charred pulsar
#

good

ocean imp
#
/**@param {ContainerSlot} contSlot */
function validateItem(contSlot) {
    let { typeId, nameTag, amount } = contSlot,
        lore = contSlot.getLore(),
        itemType = Items.get(typeId)

    if (
        !itemType ||
        /(:boat|:dye|frosted_ice|spawn_egg)/.test(typeId) ||
        (/dragon_egg/.test(typeId) && amount > 1) ||
        nameTag?.length > 30 ||
        lore?.length > 1 ||
        amount > 64
    ) {
        if (!/written_book/.test(typeId)) {
            contSlot.setItem()
            return { typeId, nameTag, amount }
        }
    }
}```
teal vortexBOT
#
No errors

No errors in [code](#1078766125057327194 message)

#
Debug Result

There are errors in this [code](#1078766125057327194 message):

<repl>.js:4:30 - error TS2339: Property 'clearItem' does not exist on type 'ContainerSlot'.

4         clearItem = contSlot.clearItem.bind(contSlot),
                               ~~~~~~~~~
<repl>.js:10:51 - error TS2554: Expected 1-2 arguments, but got 3.

10         !new ItemStack(Items.get(typeId), amount, data) ||
                                                     ~~~~

ocean imp
#

weird

#

weierd

ocean imp
#

No need for the long list anymore

warm forge
warm forge
ocean imp
#

Items.get already got that cover3d

warm forge
ocean imp
teal vortexBOT
#
Debug Result

There are errors in this [code](#1078766125057327194 message):

<repl>.js:9:45 - error TS2554: Expected 1-2 arguments, but got 3.

9         !new ItemStack(itemType.id, amount, data) ||
                                              ~~~~
<repl>.js:17:22 - error TS2339: Property 'clearItem' does not exist on type 'ContainerSlot'.

17             contSlot.clearItem()
                        ~~~~~~~~~

#
Debug Result

There are errors in this [code](#1078766125057327194 message):

<repl>.js:17:22 - error TS2339: Property 'clearItem' does not exist on type 'ContainerSlot'.

17             contSlot.clearItem()
                        ~~~~~~~~~

#
No errors

No errors in [code](#1078766125057327194 message)

#
No errors

No errors in [code](#1078766125057327194 message)

ocean imp
#

W

naive hemlock
#
import { world } from "@minecraft/server"

world.events.tick.subscribe((data) => {
    for (let p of world.getPlayers()) {
        setScore("health", p, 11)
    }
})


function setScore (objectiveId, entity, score) {
    const objective = world.scoreboard.getObjective(objectiveId)
    entity.scoreboard.setScore(objective, score)
}
teal vortexBOT
#
Debug Result

There are errors in this [code](#1078766125057327194 message):

<repl>.js:3:14 - error TS2339: Property 'tick' does not exist on type 'Events'.

3 world.events.tick.subscribe((data) => {
               ~~~~

naive hemlock
#

sus

frank fable
#
import { world, system } from "@minecraft/server"

world.events.tick.subscribe(async () => {
    for (let player of world.getAllPlayers()) {
        const pos = world.getDimension("overworld").getBlockFromRay(player.location, player.viewDirection, { "maxDistance": 10} )
        console.error(pos)
    }
}); 
teal vortexBOT
#
Debug Result

There are errors in this [code](#1078766125057327194 message):

<repl>.js:5:69 - error TS2345: Argument of type 'Vector3' is not assignable to parameter of type 'Location'.
  Type 'Vector3' is missing the following properties from type 'Location': equals, isNear

5         const pos = world.getDimension("overworld").getBlockFromRay(player.location, player.viewDirection, { "maxDistance": 10} )
                                                                      ~~~~~~~~~~~~~~~

teal vortexBOT
#
Error!

Module name does not match the pattern of "^(?:@[a-z-*~][a-z-*.~]*\\/)?[a-z-~][a-z-.~]*$"

tardy oyster
#
import {
  world,
  ScoreboardIdentity,
  ScoreboardObjective,
} from "@minecraft/server";

const WILDCARD_INT = {
  MIN: -2_147_483_648,
  MAX: 2_147_483_647,
};

/**
 * Test target's score on specific number range
 *
 * @param {string|ScoreboardIdentity} player
 * Target/score holder
 *
 * @param {string|ScoreboardObjective} objective
 * Scoreboard objective
 *
 * @param {string|number|null} min
 * Minimum value/number (Allowed value: "*" - Wildcard Int)
 *
 * @param {string|number|null} max
 * Maximum value/number (Allowed value: "*" - Wildcard Int)
 *
 * @return {boolean}
 */
export default function testScore(
  player,
  objective,
  min = WILDCARD_INT.MIN,
  max = WILDCARD_INT.MAX
) {
  // Score
  if (min === "*" || min === null) {
    min = WILDCARD_INT.MIN;
  }

  if (max === "*" || max === null) {
    max = WILDCARD_INT.MAX;
  }

  if (min > max) {
    this.min = max;
    this.max = min;
  } else {
    this.min = min;
    this.max = max;
  }

  // Objective
  if (typeof objective == "string") {
    this.obj = world.scoreboard.getObjective(objective);
  } else {
    this.obj = objective;
  }

  // Player
  if (typeof player == "string") {
    this.plr = this.obj.getParticipants().find((v) => (v.displayName == player));
  } else {
    this.plr = player;
  }

  this.scr = this.plr.getScore(this.obj);

  if (min < this.scr && this.scr > max) return true;
  else return false;
}
teal vortexBOT
#
Debug Result

There are errors in this [code](#1078766125057327194 message):

<repl>.js:61:58 - error TS2540: Cannot assign to 'displayName' because it is a read-only property.

61     this.plr = this.obj.getParticipants().find((v) => (v.displayName = player));
                                                            ~~~~~~~~~~~

#
No errors

No errors in [code](#1078766125057327194 message)

tardy oyster
#

Nice

pearl ferry
#

/script writefile module_name:test-score attachment:1080353714742759484

tardy oyster
#

@lapis lagoon

charred pulsar
#

bot offline

tardy oyster
#

Oo

teal vortexBOT
#

Uptime: 1 minutes, 14 seconds
Latency: 97 ms

lapis lagoon
#

try again

teal vortexBOT
#
Success!

Created pull request: #135

tardy oyster
#

Ok it's works

lapis lagoon
#
scripts/minecraft-discord-chat/SimpleDiscordChat.js(12,8): error TS2307: Cannot find module 'mojang-net' or its corresponding type declarations.
scripts/minecraft-discord-chat/SimpleDiscordChat.js(13,25): error TS2307: Cannot find module '@minecraft/server-server-admin' or its corresponding type declarations.

welp the build failed

tardy oyster
#

Welp, I guess I'll just delete the file, since it's just for testing

teal vortexBOT
#
Success!

Deleted file in: scripts/minecraft-discord-chat/SimpleDiscordChat.js

tardy oyster
#

Hmmm... SimulatedPlayer has soo many issue

tardy oyster
#
const item = player.getComponent("minecraft:inventory").container.getItem(player.selectedSlot) ?? "minecraft:air";
    if (item.typeId == "minecraft:diamond_sword") {
      let k = getScore("kills", player)
      let d = getScore("deaths", player)
      let kd = k / d
      let kdr = Math.round(100*kd)/100;
      let kit = player.getTags().find((tag) => tag.startsWith("kit-"))?.substring(4)?.replaceAll("-", "") ?? `No Kit`
      let f = player.getTags().find((tag) => tag.startsWith("tag-"))?.substring(4)?.replaceAll("-", "") ?? `No Faction`
      player.runCommandAsync(`title @s title   §l§5 Hy§dp§5er§fPvP §r§8| §fFactions\n§8--------------------\n§a§l Kills§r§8: §f${k}\n§c§l Deaths§r§8: §f${d}\n§6§l KDR§r§8: §f${kdr}\n§d§l Faction§r§8: §f${f}\n§b§l Kit§r§8: §f${kit}\n§8--------------------`)
    }
teal vortexBOT
#
Debug Result

There are errors in this [code](#1078766125057327194 message):

<repl>.js:1:14 - error TS2552: Cannot find name 'player'. Did you mean 'Player'?

1 const item = player.getComponent("minecraft:inventory").container.getItem(player.selectedSlot) ?? "minecraft:air";
               ~~~~~~

  @minecraft/server.d.ts:13364:15
    13364         class Player extends Entity {
                        ~~~~~~
    'Player' is declared here.
<repl>.js:1:75 - error TS2552: Cannot find name 'player'. Did you mean 'Player'?

1 const item = player.getComponent("minecraft:inventory").container.getItem(player.selectedSlot) ?? "minecraft:air";
                                                                            ~~~~~~

  @minecraft/server.d.ts:13364:15
    13364         class Player extends Entity {
                        ~~~~~~
    'Player' is declared here.
<repl>.js:3:15 - error TS2304: Cannot find name 'getScore'.

3       let k = getScore("kills", player)
                ~~~~~~~~
<repl>.js:3:33 - error TS2552: Cannot find name 'player'. Did you mean 'Player'?

3       let k = getScore("kills", player)
                                  ~~~~~~

  @minecraft/server.d.ts:13364:15
    13364         class Player extends Entity {
                        ~~~~~~
    'Player' is declared here.
<repl>.js:4:15 - error TS2304: Cannot find name 'getScore'.

4       let d = getScore("deaths", player)
                ~~~~~~~~
<repl>.js:4:34 - error TS2552: Cannot find name 'player'. Did you mean 'Player'?

4       let d = getScore("deaths", player)
                                   ~~~~~~

  @minecraft/server.d.ts:13364:15
    13364         class Player extends Entity {
                        ~~~~~~
    'Player' is declared here.
<repl>.js:7:17 - error TS2552: Cannot find name 'player'. Did you mean 'Player'?

7       let kit = player.getTags().find((tag) => tag.startsWith("kit-"))?.substring(4)?.replaceAll("-", "") ?? `No Kit`
                  ~~~~~~

  @minecraft/server.d.ts:13364:15
    13364         class Player extends Entity {
                        ~~~~~~
    'Player' is declared here.
<repl>.js:8:15 - error TS2552: Cannot find name 'player'. Did you mean 'Player'?

8       let f = player.getTags().find((tag) => tag.startsWith("tag-"))?.substring(4)?.replaceAll("-", "") ?? `No Faction`
                ~~~~~~

  @minecraft/server.d.ts:13364:15
    13364         class Player extends Entity {
                        ~~~~~~
    'Player' is declared here.
<repl>.js:9:7 - error TS2552: Cannot find name 'player'. Did you mean 'Player'?

9       player.runCommandAsync(`title @s title   §l§5 Hy§dp§5er§fPvP §r§8| §fFactions\n§8--------------------\n§a§l Kills§r§8: §f${k}\n§c§l Deaths§r§8: §f${d}\n§6§l KDR§r§8: §f${kdr}\n§d§l Faction§r§8: §f${f}\n§b§l Kit§r§8: §f${kit}\n§8--------------------`)
        ~~~~~~

tardy oyster
#
const players = world.getPlayers()
  for (const player of players) {

    const item = player.getComponent("minecraft:inventory").container.getItem(player.selectedSlot) ?? "minecraft:air";
    if (item.typeId == "minecraft:diamond_sword") {
      let k = getScore("kills", player)
      let d = getScore("deaths", player)
      let kd = k / d
      let kdr = Math.round(100*kd)/100;
      let kit = player.getTags().find((tag) => tag.startsWith("kit-"))?.substring(4)?.replaceAll("-", "") ?? `No Kit`
      let f = player.getTags().find((tag) => tag.startsWith("tag-"))?.substring(4)?.replaceAll("-", "") ?? `No Faction`
      player.runCommandAsync(`title @s title   §l§5 Hy§dp§5er§fPvP §r§8| §fFactions\n§8--------------------\n§a§l Kills§r§8: §f${k}\n§c§l Deaths§r§8: §f${d}\n§6§l KDR§r§8: §f${kdr}\n§d§l Faction§r§8: §f${f}\n§b§l Kit§r§8: §f${kit}\n§8--------------------`)
    } 
teal vortexBOT
#
Debug Result

There are errors in this [code](#1078766125057327194 message):

<repl>.js:5:14 - error TS2339: Property 'typeId' does not exist on type 'ItemStack | "minecraft:air"'.
  Property 'typeId' does not exist on type '"minecraft:air"'.

5     if (item.typeId == "minecraft:diamond_sword") {
               ~~~~~~
<repl>.js:6:15 - error TS2304: Cannot find name 'getScore'.

6       let k = getScore("kills", player)
                ~~~~~~~~
<repl>.js:7:15 - error TS2304: Cannot find name 'getScore'.

7       let d = getScore("deaths", player)
                ~~~~~~~~
<repl>.js:14:1 - error TS1005: '}' expected.

14 
   

  <repl>.js:2:33
    2   for (const player of players) {
                                      ~
    The parser expected to find a '}' to match the '{' token here.

warm forge
#
let someNum = [7,9,10]
let multiples = someNum.map(num => { return num * 2})
console.log(multiples)
willow ruinBOT
ocean imp
#

now try { num * 2}

warm forge
#

Undefined

#

Sry

ocean imp
#

I thought the same before as well

#

now do {return num * 2}

willow ruinBOT
warm forge
ocean imp
#
let someNum = [7,9,10]
let ar = []
for (let k in someNum) ar.push(k)
console.log(ar)
console.log(someNum[ar[0]])
willow ruinBOT
ocean imp
#

ye

#

w8

willow ruinBOT
ocean imp
#

works same when used in array

warm forge
#
let someNum = [7,9,10]
let ar = []
for (let k in someNum) ar.push(k)
console.log(ar)
let newAr = []
for (let i in someNum) newAr.push(someNum[i])
console.log(newAr)
#
let someNum = [7,9,10]
console.log(someNum['0'])
willow ruinBOT
warm forge
lapis lagoon
#

just found out that you can debug code in my bot's DM. Well we can get rid of this channel lol

ocean imp
#

Nooo

#

Y tho

keen basalt
#

xd

ocean imp
#

What about let this channel be the script api bot channel

keen basalt
#

problem is we cant pin this channel

#

but that was the idea

#

but maybe we could suggest separate channel in SCRIPTING category

naive hemlock
#
import { world } from "@minecraft/server";

let player = world.getPlayers({ name:"Jean majidYT" })
console.warn(getInv(player))
function getInv (entity) {
    const items = [];
    const inv = entity.getComponent("minecraft:inventory").container;
    for (let i = 0; i < inv.lenght ; i++) {
        items.push(inv.getItem(i)); 
    }
    return items
}
teal vortexBOT
#
No errors

No errors in [code](#1078766125057327194 message)

ocean imp
#

false

naive hemlock
#

yr

#

yes

#

can you tell me what i did wrong?

ocean imp
#

getPlayers is plural so name it like players

naive hemlock
#

lol

ocean imp
#

then

getInv([...players].shift())
#

or

getInv(Array.from(players).shift())
naive hemlock
#

i will try but i think i got a different error

ocean imp
#

length

#

w8, size

naive hemlock
#

ah ok

#

Thank you very much

ocean imp
#

wc

keen basalt
#
while(true) {
     console.log("test");
}
ocean imp
#

ohno

willow ruinBOT
# keen basalt ```js while(true) { console.log("test"); } ```
Program Output
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test

ocean imp
#

F

keen basalt
#

time limit is 20ms

#

but output is reducer way more xd

warm forge
charred pulsar
#

nah

warm forge
charred pulsar
#

servers are meant to be like that but since its for public they gotta put limit

#

server can run things forever

keen basalt
warm forge
#

Once i tried to print from 1 to infinity

#

And it just freezed

teal vortexBOT
#

Click the link above to get code for 'calc-player-view-offset' in ScriptAPI repository.

#
Error!

The package doesn't exist on remote (1.19.60).

lapis lagoon
#

I implemented script versioning for scripts

charred pulsar
#

hm

warm forge
#
let {events: {beforeChat: {subscribe: chat},beforeItemUseOn: {subscribe: itemOnBlock},beforeItemUse: {subscribe: itemUse}, entityHit: {subscribe: hit}, entityHurt: { subscribe: hurt},blockPlace: {subscribe: place}, blockBreak: {subscribe: blBreak}},say: s} = world
chat(evd => {
let {message: msg,sender:player} = evd
let [cmd,...subcmd] = msg.split(/\s+/g)
if (cmd.startsWith("!")) evd.cancel = true
switch (cmd) {
case "!say":
s(subcmd.join(" "))
break;
case "!tell":
let plr = world.getAllPlayers().find(plrr => plrr.name == subcmd[0]);
subcmd.shift();
plr.tell(subcmd.join(" "));
break;
case "!color":
let clr = subcmd[0];
subcmd.shift()
let index = ["red","yellow"].indexOf(clr)
switch (index) {
case 0: 
s("§c" + subcmd.join(" "))
break;
case 1:
s("§e" + subcmd.join(" "))
break;
default:
s(subcmd.join(" "))
}
break;
default: 
player.tell("§cUnknown Command")
}
})
//written in discord
teal vortexBOT
#
Debug Result

There are errors in this [code](#1078766125057327194 message):

<repl>.js:1:239 - error TS2451: Cannot redeclare block-scoped variable '(Missing)'.

1 let {events: {beforeChat: {subscribe: chat},beforeItemUseOn: {subscribe: itemOnBlock},beforeItemUse: {subscribe: itemUse}, entityHit: {subscribe: hit}, entityHurt: { subscribe: hurt},blockPlace: {subscribe: place}, blockBreak: {subscribe: break}},say: s} = world
                                                                                                                                                                                                                                                
<repl>.js:1:240 - error TS1359: Identifier expected. 'break' is a reserved word that cannot be used here.

1 let {events: {beforeChat: {subscribe: chat},beforeItemUseOn: {subscribe: itemOnBlock},beforeItemUse: {subscribe: itemUse}, entityHit: {subscribe: hit}, entityHurt: { subscribe: hurt},blockPlace: {subscribe: place}, blockBreak: {subscribe: break}},say: s} = world
                                                                                                                                                                                                                                                 ~~~~~
<repl>.js:1:240 - error TS2339: Property 'break' does not exist on type 'BlockBreakEventSignal'.

1 let {events: {beforeChat: {subscribe: chat},beforeItemUseOn: {subscribe: itemOnBlock},beforeItemUse: {subscribe: itemUse}, entityHit: {subscribe: hit}, entityHurt: { subscribe: hurt},blockPlace: {subscribe: place}, blockBreak: {subscribe: break}},say: s} = world
                                                                                                                                                                                                                                                 ~~~~~
<repl>.js:1:245 - error TS2451: Cannot redeclare block-scoped variable '(Missing)'.

1 let {events: {beforeChat: {subscribe: chat},beforeItemUseOn: {subscribe: itemOnBlock},beforeItemUse: {subscribe: itemUse}, entityHit: {subscribe: hit}, entityHurt: { subscribe: hurt},blockPlace: {subscribe: place}, blockBreak: {subscribe: break}},say: s} = world
                                                                                                                                                                                                                                                      
<repl>.js:1:245 - error TS1005: ':' expected.

1 let {events: {beforeChat: {subscribe: chat},beforeItemUseOn: {subscribe: itemOnBlock},beforeItemUse: {subscribe: itemUse}, entityHit: {subscribe: hit}, entityHurt: { subscribe: hurt},blockPlace: {subscribe: place}, blockBreak: {subscribe: break}},say: s} = world
                                                                                                                                                                                                                                                      ~

#
No errors

No errors in [code](#1078766125057327194 message)

warm forge
#

Now replaced them with blBreak and no errors!

ocean imp
#
const arg = '@e[scores={be=! 9 , aha=! .. 32,"ins v"=!..99,ban=5..,adventure=0}]'

console.log(toQueryScore(arg))

function toQueryScore(text) {
    const query = {}
    return query
}
willow ruinBOT
ocean imp
#

weo

willow ruinBOT
willow ruinBOT
ocean imp
#

too long, but aigth

willow ruinBOT
warm forge
#

It results something else in ide

#

Hve u edited that?

ocean imp
#

Ye

#

I'm working it out

hallow needle
#
function getScore(player, objectiveId, rNull = false) {
    try {
        return world.scoreboard
            .getObjective(objectiveId)
            .getScore(player.scoreboard);
    } catch (error) {
        return rNull ? null : 0;
    }
}

const bankacc = getScore( Player, "bank")
const money = getScore( Player, "money")
let existplayers = world
    .getAllPlayers()
    .map( player => player.name )

function withdrawform(player) {
    let withdraw = new ModalFormData();
    withdraw.title("Withdraw")
    withdraw.slider("Amount", 0, `${bankacc}`, 10, 0)
    
    withdraw.show(player).then(result => {
        const money1 = result.formValues[0]
        
    player.runCommandAsync(`scoreboard players remove @s bank ${money1}`)  
    player.runCommandAsync(`scoreboard players add @s money ${money1}`)
    player.tell(`§aSuccessfully withdraw $${money1}`)
    }
}

function depositform(player) {
    let deposit = new ModalFormData();
    deposit.title("Deposit")
    deposit.dropdown("Players", existplayers)
    deposit.slider("Amount", 0, `${money}`, 10, 0)
    deposit.toggle("Announce the transaction")
    
    deposit.show(player).then(result => {
        const amount = result.formValues[1]
        const toggle = result.formValues[2]
        const target = result.formValues[0]

 player.runCommandAsync(`scoreboard players remove @s money ${amount}`)
        player.runCommandAsync(`scoreboard players add @s bank ${amount}`)
        if (toggle == true) {
            world.say(`${player.name} sended §a$${amount}§f to ${target}'s bank account`)
        }
    })
}```
teal vortexBOT
#
Debug Result

There are errors in this [code](#1078766125057327194 message):

<repl>.js:20:34 - error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'.

20     withdraw.slider("Amount", 0, `${bankacc}`, 10, 0)
                                    ~~~~~~~~~~~~
<repl>.js:29:1 - error TS1005: ',' expected.

29 }
   ~
<repl>.js:35:33 - error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'.

35     deposit.slider("Amount", 0, `${money}`, 10, 0)
                                   ~~~~~~~~~~

warm forge
#
if (!(false && false)) {
console.log ("huh")
}
willow ruinBOT
# warm forge ```js if (!(false && false)) { console.log ("huh") } ```
Program Output
/home/jail/prog.js:1
if !(true && true) {
   ^

SyntaxError: Unexpected token '!'
    at Object.compileFunction (node:vm:352:18)
    at wrapSafe (node:internal/modules/cjs/loader:1032:15)
    at Module._compile (node:internal/modules/cjs/loader:1067:
willow ruinBOT
odd ingot
#
world.events.playerJoin.subscribe(data => data.player.addTag('joined') && data.playerId.removeTag('sidebar'));
setTickInterval(() => {
    world.getAllPlayers().filter(p => p.hasTag('joined')).forEach(p => {
        if (!p.isSneaking || p.velocity.y <= 0.5)
            return p.removeTag('joined');
    });
}, 10);
#

/debug Stable

teal vortexBOT
#
Debug Result

There are errors in this [code](#1078766125057327194 message):

<repl>.js:1:48 - error TS2551: Property 'player' does not exist on type 'PlayerJoinEvent'. Did you mean 'playerId'?

1 world.events.playerJoin.subscribe(data => data.player.addTag('joined') && data.playerId.removeTag('sidebar'));
                                                 ~~~~~~

  @minecraft/server.d.ts:13876:22
    13876             readonly playerId: string;
                               ~~~~~~~~
    'playerId' is declared here.
<repl>.js:1:89 - error TS2339: Property 'removeTag' does not exist on type 'string'.

1 world.events.playerJoin.subscribe(data => data.player.addTag('joined') && data.playerId.removeTag('sidebar'));
                                                                                          ~~~~~~~~~
<repl>.js:2:1 - error TS2304: Cannot find name 'setTickInterval'.

2 setTickInterval(() => {
  ~~~~~~~~~~~~~~~

keen basalt
#

oh ok

dull cave
#
s
teal vortexBOT
#
Debug Result

There are errors in this [code](#1078766125057327194 message):

<repl>.js:1:1 - error TS2304: Cannot find name 's'.

1 s
  ~

dull cave
#

omg no way

#

i was coding this 6h

#

to get error

charred pulsar
#

dont drink and code

teal vortexBOT
#
Debug Result

JavaScript/TypeScript code blocks not detected in [message](#1078766125057327194 message ).
Example:
```js
console.log("Hi mom!")
```

dull cave
#

💀

#

jk

#

im <18

warm forge
#
function Use(me) {
console.log("Use " + me)
}
Use("lawnmower")
willow ruinBOT
vestal shell
#
function Use(me) {
console.log("Use " + me)
Use(me)
}
Use("lawnmower")
willow ruinBOT
warm forge
teal vortexBOT
#
No errors

No errors in [code](#1078766125057327194 message)

warm forge
vestal shell
#

XD

warm forge
#
function wth(why) {
let rp
let i = 0
try {
let id = setInterval(() => {
if (i !== 7) {
 i++
} else {
rp = why
}
},300)
} finally {
return "wth "+ why
}
}
console.log(wth("bro, why"))
vestal shell
#

returns "wth bro, why"

warm forge
#

😂

vestal shell
#

I havent compiled yet

warm forge
#
function wth(why) {
let rp
let i = 0
try {
let id = setInterval(() => {
if (i !== 7) {
 i++
} else {
rp = why
clearInterval(id)
}
},300)
} finally {
return "wth "+ why
}
}
console.log(wth("bro, why"))
vestal shell
#

The bot is not responding what did you-

willow ruinBOT
warm forge
vestal shell
vestal shell
warm forge
vestal shell
#

😂

warm forge
vestal shell
#

Lmao

charred pulsar
#
import { 
  world,
  Player
} from "@minecraft/server"

world.events.entityHit.subscribe( eventData => {
  const { 
    entity, 
    hitEntity 
  } = eventData

  if (! (hitEntity && hitEntity instanceof Player) ) return;

  // do stuff on hit

} )

teal vortexBOT
#
No errors

No errors in [code](#1078766125057327194 message)

warm forge
#
for (let i = 0; i < 20; i++) {
console.log(i + i)
}
willow ruinBOT
hallow needle
#
function a(min, max){

}
console.log(a)```
warm forge
hallow needle
#

Im just testing stuff but thx tho

willow ruinBOT
willow ruinBOT
warm forge
#

Wth

willow ruinBOT
willow ruinBOT
warm forge
#

Again 52?

willow ruinBOT
lapis lagoon
#
function getRandomInt(min, max) {
  min = Math.ceil(min);
  max = Math.floor(max);
  return Math.floor(Math.random() * (max - min) + min); // The maximum is exclusive and the minimum is inclusive
}

for (let i = 0; i < 10; i++) {
  console.log(getRandomInt(0, 100));
}

willow ruinBOT
hallow needle
#
function a(min, max){
return Math.floor(Math.random() * (max - min)) + min
}
console.log(a(1.4,2.4))```
hallow needle
#

Ohh

hallow needle
dull cave
#
!false
willow ruinBOT
dull cave
#
console.log(!true == false);
willow ruinBOT
warm forge
willow ruinBOT
warm forge
#
let veges = {
potato: { color: "yellow" },
tomato: { color: "red" }
}
console.log(veges.potato == veges.tomato)
console.log(veges.potato.color)
console.log(veges.tomato.color)
willow ruinBOT
warm forge
#
let veges = {
potato: { color: "yellow" },
tomato: { color: "red" }
}
console.log(veges.potato == veges.tomato)
console.log("tomatoes are: " + veges.potato.color)
console.log("potatoes  are : " + veges.tomato.color)
willow ruinBOT
warm forge
#

What?
Potatoes are red and tomatoes yellow

#

Oh wait

#

😂

#
let veges = {
potato: { color: "yellow" },
tomato: { color: "red" }
}
console.log(veges.potato == veges.tomato)
console.log("tomatoes are: " + veges.tomato.color)
console.log("potatoes  are : " + veges.potato.color)
willow ruinBOT
summer smelt
#
const mom = {
    urMom: {
        color: 'black'
    },
    urMom1: {
        color: 'white'
    }
}
console.log(mom.urMom.color == mom.urMom1.color)
console.log(`urMoms color is: ${mom.urMom.color}`)
console.log(`urMoms1 color is: ${mom.urMom1.color}`)```
#

how tf u run this?

warm forge
summer smelt
#

;compile

const mom = {
    urMom: {
        color: 'black'
    },
    urMom1: {
        color: 'white'
    }
}
console.log(mom.urMom.color == mom.urMom1.color)
console.log(`urMoms color is: ${mom.urMom.color}`)
console.log(`urMoms1 color is: ${mom.urMom1.color}`)```
willow ruinBOT
#
Program Output
false
urMoms color is: black
urMoms1 color is: white

ocean imp
#
const arr = []
for(let i=0;i<10;i++) arr.push(random(-60))
console.log(arr)
function random(a, b = 0) {
  const { floor: f, random: r } = Math
  return f(!b?(r()*a):(r()*(a-b)+b))
}
willow ruinBOT
willow ruinBOT
vestal shell
#
while(true) {}
#

I am

#

I just wrote that to make the bot think XD

willow ruinBOT
vestal shell
#
while(true) {console.error("im f***ing this console")}
#

YES

willow ruinBOT
# vestal shell ```js while(true) {console.error("im f***ing this console")} ```
Program Output
im f***ing this console
im f***ing this console
im f***ing this console
im f***ing this console
im f***ing this console
im f***ing this console
im f***ing this console
im f***ing this console
im f***ing this console
im f***ing this console
im f***ing
vestal shell
#

It doesnt show it as an error tho

#

Sad

teal vortexBOT
#
No errors

No errors in [code](#1078766125057327194 message)

vestal shell
#
while(true) {try{throw "frick this code";} catch {}}
teal vortexBOT
#
No errors

No errors in [code](#1078766125057327194 message)

ocean imp
#
const ar = [];for (const k in globalThis)ar.push(k);console.log(ar)
willow ruinBOT
ocean imp
#
async function obj(a){
   for (const k in a) {
      const v = a[k]
      this[[typeof v,k]] = v.toString()
   }
   return this
};
(async()=>console.log(await obj(globalThis)))()
willow ruinBOT
tardy oyster
#
system.runSchedule(function isSneak () {
  for (const player of world.getPlayers()) {
    if (!player.isSneaking) continue;

    const objective = world.scoreboard.getObjective("sneak")
    objective.setScore(player.scoreboard, objective.getScore(player.scoreboard) + 1)

    system.runSchedule(() => {
      objective.setScore(player.scoreboard, objective.getScore(player.scoreboard) - 1)
    }, 40)
  }
}, 1)
teal vortexBOT
#
Debug Result

There are errors in this [code](#1078766125057327194 message):

<repl>.js:6:15 - error TS2554: Expected 2 arguments, but got 1.

6     objective.setScore(objective.getScore(player.scoreboard)++)
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  @minecraft/server.d.ts:14205:55
    14205             setScore(participant: ScoreboardIdentity, score: number): boolean;
                                                                ~~~~~~~~~~~~~
    An argument for 'score' was not provided.
<repl>.js:6:24 - error TS2357: The operand of an increment or decrement operator must be a variable or a property access.

6     objective.setScore(objective.getScore(player.scoreboard)++)
                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<repl>.js:9:17 - error TS2554: Expected 2 arguments, but got 1.

9       objective.setScore(objective.getScore(player.scoreboard)--)
                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  @minecraft/server.d.ts:14205:55
    14205             setScore(participant: ScoreboardIdentity, score: number): boolean;
                                                                ~~~~~~~~~~~~~
    An argument for 'score' was not provided.
<repl>.js:9:26 - error TS2357: The operand of an increment or decrement operator must be a variable or a property access.

9       objective.setScore(objective.getScore(player.scoreboard)--)
                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#
Debug Result

There are errors in this [code](#1078766125057327194 message):

<repl>.js:6:43 - error TS2357: The operand of an increment or decrement operator must be a variable or a property access.

6     objective.setScore(player.scoreboard, objective.getScore(player.scoreboard)++)
                                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<repl>.js:9:45 - error TS2357: The operand of an increment or decrement operator must be a variable or a property access.

9       objective.setScore(player.scoreboard, objective.getScore(player.scoreboard)--)
                                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#
No errors

No errors in [code](#1078766125057327194 message)

warm forge
#
let aक = "This Character Is Supported Ig";
console.log("yes " + aक)
willow ruinBOT
willow ruinBOT
warm forge
#

Yup

teal vortexBOT
#
No errors

No errors in [code](#1078766125057327194 message)

warm forge
#
let getRandomValue = (length) => {
    let chars = "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz1234567890+=%_|<>{}[]!@#$/^&*()`~-':;,?".split("")
    let str = ""
    for (var i = 0; i < length; i++) {
        str += chars[getRandomInt(0,chars.length)]
    }
    return str
}
var getRandomInt = (min = 0, max =100000) => Math.floor(Math.random() * (max - min)) + min
let db = {}
let obf = (str) => {
    let random = getRandomValue(str.length);
    db[random] = str;
    return random;
}
let deobf = (str) => db[str];
for (var i = 0; i < 20; i++) {
let obfstr = obf ("just use it")
console.log (obfstr.includes("?")? "Found ? In " + obfstr: obfstr)
}
willow ruinBOT
willow ruinBOT
willow ruinBOT
willow ruinBOT
warm forge
ocean imp
#

try to get the ?

warm forge
#

Really

#

?

ocean imp
#

there's no need to .split('')

ocean imp
warm forge
#

Yup ik

#

I was doing smthing else before that

#

So there's split

ocean imp
#

ok

warm forge
#

How is it btw?

ocean imp
#

what

warm forge
#

Function

ocean imp
#

huh....

willow ruinBOT
willow ruinBOT
ocean imp
#

well...

#

since there's math.floor, there's no need to chars.length - 1

#

just chars.length

warm forge
ocean imp
#
const str = '8yuigwets.[z23,pxuwt4'
console.log(str[4])
console.log(str[Math.floor(str.length)])
willow ruinBOT
warm forge
#

I thought strings are 0 based

#

But well that's an array

ocean imp
#

its like a target thingy

warm forge
#
let arr = [1,2,3,4,5]
console.log (arr.length)
console.log (arr [arr.length])
console.log (arr [arr.length -1 ])
willow ruinBOT
willow ruinBOT
ocean imp
#

still no ??

warm forge
#

After printing 2000 still no ?

ocean imp
#

remove - 1

warm forge
#

Okay a try

ocean imp
#

well, ur doing randomizer

warm forge
#

Yup

warm forge
#

After removing -1

ocean imp
#

mk

warm forge
#

Oh in randomizer max is exclusive

ocean imp
#

because of Math.floor

#
const rand = (value) => Math.random() * (value + value) - value
let ar = new Array(10)
for(let i=0;i<100;i++) ar.push(Math.floor(rand(i)))
console.log(ar)
willow ruinBOT
willow ruinBOT
warm forge
#
let getRandomValue = (length) => {
    let chars = "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz1234567890+=%_|<>{}[]!@#$/^&*()`~-':;,?"
    let str = ""
    for (var i = 0; i < length; i++) {
        str += chars[getRandomInt(0,chars.length + 1)]
    }
    return str
}
var getRandomInt = (min = 0, max =100000) => Math.floor(Math.random() * (max - min)) + min
let db = {}
let obf = (str) => {
    let random = getRandomValue(str.length);
    db[random] = str;
    return random;
}
let deobf = (str) => db[str];
let obfstr = obf({a: "a",b: "b"})
console.log(obfstr)
let deobfstr = deobf(obfstr)
console.log(deobfstr)
willow ruinBOT
willow ruinBOT
warm forge
#
let getRandomValue = (length) => {
    let chars = "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz1234567890+=%_|<>{}[]!@#$/^&*()`~-':;,?"
    let str = ""
    for (var i = 0; i < length; i++) {
        str += chars[getRandomInt(0,chars.length + 1)]
    }
    return str
}
var getRandomInt = (min = 0, max =100000) => Math.floor(Math.random() * (max - min)) + min
let db = {}
let obf = (prm) => {
if (typeof prm == "string") {
    let random = getRandomValue(prm.length);
    db[random] = prm;
    return random;
} else if (typeof prm == 'object') {
let str = JSON.stringify(prm)
let random = getRandomValue(str.length);
    db[random] = prm;
    return random;
}
}
let deobf = (str) => db[str];
let obfstr = obf({a: "a",b: "b"})
console.log(obfstr)
let deobfstr = deobf(obfstr)
console.log(deobfstr)
willow ruinBOT
warm forge
#
console.log(typeof "this")
console.log(typeof {})```
willow ruinBOT
willow ruinBOT
teal vortexBOT
#
Debug Result

There are errors in this [code](#1078766125057327194 message):

<repl>.js:13:19 - error TS2339: Property 'say' does not exist on type 'World'.

13             world.say(orelocation[0])
                     ~~~
<repl>.js:20:8 - error TS2339: Property 'runSchedule' does not exist on type 'System'.

20 system.runSchedule(() => {
          ~~~~~~~~~~~
<repl>.js:22:30 - error TS2304: Cannot find name 'BlockLocation'.

22         const location = new BlockLocation(orelocation[i].x,orelocation[i].y,orelocation[i].z)
                                ~~~~~~~~~~~~~

warm forge
#
let smthng = ["eg","bg"]
for (let i of smthng) {
eval(`var ${i} = () => console.log(${i})`)
}
eg()
bg()
willow ruinBOT
teal vortexBOT
#
Debug Result

There are errors in this [code](#1078766125057327194 message):

<repl>.js:5:1 - error TS2304: Cannot find name 'eg'.

5 eg()
  ~~
<repl>.js:6:1 - error TS2304: Cannot find name 'bg'.

6 bg()
  ~~

warm forge
#

What how?

warm forge
keen basalt
#

also it cant find variables called eg and bg

#

so u must define them also

warm forge
tardy oyster
tardy oyster
#

So that's not an issue

warm forge
#
eval(`world.events.beforeChat.subsctibe((evd) => {
evd.message.cancel.yes.sir
})`)
teal vortexBOT
#
No errors

No errors in [code](#1078766125057327194 message)

warm forge
#
world.events.beforeChat.subsctibe((evd) => {
evd.message.cancel.yes.sir
})
teal vortexBOT
#
Debug Result

There are errors in this [code](#1078766125057327194 message):

<repl>.js:1:25 - error TS2551: Property 'subsctibe' does not exist on type 'BeforeChatEventSignal'. Did you mean 'subscribe'?

1 world.events.beforeChat.subsctibe((evd) => {
                          ~~~~~~~~~

  @minecraft/server.d.ts:298:13
    298             subscribe(callback: (arg: BeforeChatEvent) => void): (arg: BeforeChatEvent) => void;
                    ~~~~~~~~~
    'subscribe' is declared here.

warm forge
#

Wow

warm forge
#
function ItemConstructor(id) {
    let Data = {
        ["minecraft:item"] : {
            component: {},
            description: {}
        }
    }
    Data["minecraft:item"].description.identifier = id
    this.name = (str) => {
        Data["minecraft:item"].component["minecraft:display_name"] = {value: str}
    }
    this.ver = (context) => {
        Data["format_version"] = context
    }
    this.comp = (d,v) => {
        Data["minecraft:item"].component[d] = v
    }
    this.create = () => {
        return JSON.stringify(Data,0,5);
    }
    this.category = (v) => {
        Data["minecraft:item"].description.category = v
    }
    this.specificComponent = {
        category: (str) => {
            Data["minecraft:item"].component["minecraft:creative_category"] = {parent: str}
        }
    }
}
let item = new ItemConstructor("item:id")
item.name("My Item")
item.category("Equipment")
item.ver("1.16.100")
item.comp("minecraft:durablity",550)
item.specificComponent.category("itemGroup.name.tools")
console.log(item.create())
willow ruinBOT
warm forge
#
function ItemConstructor(id) {
    let Data = {
        ["minecraft:item"] : {
            component: {},
            description: {}
        }
    }
    Data["minecraft:item"].description.identifier = id
    this.name = (str) => {
        Data["minecraft:item"].component["minecraft:display_name"] = {value: str}
    }
    this.ver = (context) => {
        Data["format_version"] = context
    }
    this.comp = (d,v) => {
        Data["minecraft:item"].component[d] = v
    }
    this.create = () => {
        return JSON.stringify(Data);
    }
    this.category = (v) => {
        Data["minecraft:item"].description.category = v
    }
    this.specificComponent = {
        category: (str) => {
            Data["minecraft:item"].component["minecraft:creative_category"] = {parent: str}
        }
    }
}
let item = new ItemConstructor("item:id")
item.name("My Item")
item.category("Equipment")
item.ver("1.16.100")
item.comp("minecraft:durablity",550)
item.specificComponent.category("itemGroup.name.tools")
console.log(item.create())
willow ruinBOT
warm forge
#
function ItemConstructor(id) {
    let Data = {
        ["minecraft:item"] : {
            component: {},
            description: {}
        }
    }
    Data["minecraft:item"].description.identifier = id
    this.name = (str) => {
        Data["minecraft:item"].component["minecraft:display_name"] = {value: str}
    }
    this.ver = (context) => {
        Data["format_version"] = context
    }
    this.comp = (d,v) => {
        Data["minecraft:item"].component[d] = v
    }
    this.create = () => {
        return JSON.stringify(Data);
    }
    this.category = (v) => {
        Data["minecraft:item"].description.category = v
    }
    this.specificComponent = {
        category: (str) => {
            Data["minecraft:item"].component["minecraft:creative_category"] = {parent: str}
        }
    }
}
let item = new ItemConstructor("item:id")
item.name("My Item")
item.category("Equipment")
item.ver("1.16.100")
item.specificComponent.category("itemGroup.name.tools")
console.log(item.create())
willow ruinBOT
dull cave
#
{"minecraft:item":{"component":{"minecraft:display_name":{"value":"My Item"},"minecraft:creative_category":{"parent":"itemGroup.name.tools"}},"description":{"identifier":"item:id","category":"Equipment"}},"format_version":"1.16.100"}

warm forge
#

New console

#

xd

subtle finch
#
const cooldowns
world.events.beforeItemUse.subscribe(data => {
    if (data.source.typeId !== 'minecraft:player') return
    const player = data.source
    if (data.item.typeId === '"bridge:wizard_ability_3') cooldown(player)
})
function cooldown(player)
player.runCommandAsync('tag @s add cool1')
}
if (player.hasTag ('cool1')) {
player.tell('wait 1 second');
player.runCommandAsync('tag @s remove cool1')
} 
keen basalt
#

Please move ur testing and JS running to #debug-playground