#TypeError (Apparently)

1 messages · Page 1 of 1 (latest)

thorny leaf
#

use @wicked lotus

wicked lotusBOT
#
Debug Result

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

<repl>.js:18:14 - error TS2304: Cannot find name 'random'.

18           if(random > 0.08) caveArray[x][y][z] = "stone"
                ~~~~~~
<repl>.js:29:25 - error TS2304: Cannot find name 'API'.

29           const block = API.overworld.getBlock(new BlockLocation(x,-63 + y,z))
                           ~~~

thorny leaf
#

you need to use the apps feature to activate it

wicked lotusBOT
#
Debug Result

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

<repl>.js:1:3 - error TS1128: Declaration or statement expected.

1   static createCave(x,y,z){
    ~~~~~~
<repl>.js:1:10 - error TS2304: Cannot find name 'createCave'.

1   static createCave(x,y,z){
           ~~~~~~~~~~
<repl>.js:1:21 - error TS2304: Cannot find name 'x'.

1   static createCave(x,y,z){
                      ~
<repl>.js:1:23 - error TS2304: Cannot find name 'y'.

1   static createCave(x,y,z){
                        ~
<repl>.js:1:25 - error TS2304: Cannot find name 'z'.

1   static createCave(x,y,z){
                          ~
<repl>.js:1:27 - error TS1005: ';' expected.

1   static createCave(x,y,z){
                            ~
<repl>.js:33:25 - error TS2304: Cannot find name 'API'.

33           const block = API.overworld.getBlock(new BlockLocation(x,-63 + y,z))
                           ~~~

thorny leaf
#

perhaps send the whole file, the debugger can debug files

#

whats the error in content log

#

full log

wicked lotusBOT
#
Debug Result

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

thorny leaf
#

what does the caveArray thing return

#

print the value to content log to see what comes

#

print MinecraftBlockTypes[caveArray[x][y][z]] to see what comes out

ivory valve
#

How does one use that debugger?

thorny leaf
#

?script debug

earnest riverBOT
#
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

ivory valve
#

What is the "like this" section?

thorny leaf
#

its just code

ivory valve
#

Where do I add that to my code?

thorny leaf
#
console.log("Like this")
timber sable
#

@ripe knoll

ripe knoll
#

thx

timber sable
#

np

ripe knoll
#

but what is question here

timber sable
#

ig he deleted it...

#

code...

ripe knoll
#

xd

#

ok

#

so stone is defined on MinecraftBlockTypes

#

but maybe is not what are u sending in

#

try

#

if(str in MiencraftBlockTypes)

#

test

#

test if string is in MinecraftBlockTypes

#

so then it didnt returns undefined

ripe knoll
#

? JS

earnest riverBOT
#
Learn Javascript!

As the Script API is a framework built on JavaScript code, having an understanding of JavaScript is key.

If you are being shown this, then you most likely are a beginner with JS and could use a little guidance.

📺 Videos on Learning JavaScript
Javascript in 1 hour
Javascript Classes in 1 hour

Web Guide:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide

Reference Sites:
https://www.w3schools.com/jsref/default.asp
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference
https://javascript.info

ripe knoll
#

ya

#

or just goodle JS "in" operator

timber sable
#
world.say(JSON.stringify(caveArray[x][y][z]));
block.setType(MinecraftBlockTypes[caveArray[x][y][z]]);
```see where it stops
#

the ores keys are valid in MCblocktypes

#

why still test for that