#Non-experimental parts of Script API

1 messages · Page 1 of 1 (latest)

fresh vapor
#

The Bedrock Wiki mentions that some parts of Script API are not experimental, but does not mention which are and which are not. So that's my question.

analog copper
fresh vapor
analog copper
#

non-beta apis? No. With beta apis it really depends how you make it

fresh vapor
fresh vapor
fresh vapor
#

Basically, what I need is accessing entities with JS, so I can move with them based on player interactions and algorithm that decides opponents moves.

light yoke
#

rn all the usefull stuff is in beta api stable api is basically useless to do any good stuff

#

to use latest beta apis we use beta/preview version of the game

fresh vapor
#

Perfect, that's what I needed to know.

#

I just wish there was more information about the the actual API...

fresh vapor
light yoke
#

just get addon working first

fresh vapor
#

the addon is working and is inside of the development behaviors folder

light yoke
#

okay well i never used debugger as i do things manually so wait for someone :/

fresh vapor
#

Maybe a problem with versioning?

{
  "version": "0.3.0",
  "configurations": [
    {
      "type": "minecraft-js",
      "request": "attach",
      "name": "Wait for Minecraft Debug Connections",
      "mode": "listen",
      "localRoot": "${workspaceFolder}/",
      "port": 19144
    }
  ]
}```
fresh vapor
#

I mean in this case... Otherwise, of course that debugger does not do that.

fresh vapor
light yoke
#

uh it helps u debug code im realtime

fresh vapor
#

yup, I get that

#

but the documentation does not mention BDS in this setup

light yoke
#

BDS is a bedrock server software

fresh vapor
#

yup and from what I figured I need it to run the scripts

#

right?

light yoke
#

its nothing to with scripts

fresh vapor
#

uh

light yoke
#

ur local game is a server in itself

#

when we say server we mean host of the world not a BDS or such

fresh vapor
#

oh, right, it refers to BPs running on a server...

#

Wait, so now, I should be able to run my GameTest, no?

#

How do I call it?

light yoke
#

BDS is a server software that creates a minecraft server that host a world with there packs

ur game locally when opened also hosts a world with ur packs

scripts are server sided means its running from world side

#

thats not what ur looking for

#

gametests and scripts are 2 diff things

fresh vapor
#

So, BDS is something like Spigot on Java?

fresh vapor
light yoke
#

gametests are small unit testing scripts used to automate game mechanics testing

#

its not usefull for creators

fresh vapor
#

aha, that's what I also figured from the docs

#

it's useful for gameplay devs and testers

light yoke
#

creators uses generic sctipt api for content

fresh vapor
#

understood, lesson learned, getting an error

light yoke
#

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

fresh vapor
#

is the documentation incorrect then?

#

also is there a command to reload the scripts in the game?

light yoke
#

which doc u saw

light yoke
#

the mc plugin does it automatically

#

as soon u make changes its reloaded

fresh vapor
light yoke
#

lmao

#

@analog copper fix that

#

?manifest

#

?script manifest

rancid gorgeBOT
#
Script API manifest.json

v1.19.50.21+

{
    "format_version": 2,
    "header": {
        "name": "Bedrock Addons",
        "description": "Script API Template",
        "uuid": "bf67828b-e511-4c72-9922-b6dc179926f4",
        "version": [ 0, 1, 0 ],
        "min_engine_version": [ 1, 19, 50 ]
    },
    "modules": [
        {
            "type": "script",
            "language": "javascript",
            "uuid": "b7055392-4154-4aa8-813f-afa6291f1056",
            "entry": "scripts/server/script.js",
            "version": [ 0, 1, 0 ]
        }
    ],
    
    // to use eval() and Function()
    "capabilities": [ "script_eval" ],

    "dependencies": [
        {
            "module_name": "@minecraft/server",
            "version": "1.1.0-beta"
        },
        {
            "module_name": "@minecraft/server-ui",
            "version": "1.0.0-beta"
        }
    ]
}

?uuids in #bot-usage for the complete list of uuids

fresh vapor
#

aha, I see xd

light yoke
#

doc seems hard

#

need improovment

fresh vapor
light yoke
#

ur on stable mc ?

fresh vapor
#

yes, but with experiments

light yoke
#

?system

#

?await

rancid gorgeBOT
#
Tick Awaition

since 1.19.50, we recieved two new methods that can be used for delaying function execution

// next tick
 system.run(func); 

// like setInterval
system.runSchedule( func, tickDelay );

// like cancel run
system.clearRun( runId );

// like clearInterval
system.clearRunSchedule( intervalId );

Example
for running code every 20ticks (1sec)

const TICKS_IN_SEC = 20;

const runSchedule = system.runSchedule( () => {
    console.warn( "show this message every " + TICKS_IN_SEC + " ticks");
}, TICKS_IN_SEC );

system.clearRunSchedule( runSchedule ); //stop execution loop
light yoke
#

use system.runSchedule

#

in 1.19.70 names changed

#

use old name

#

since ur in .60

fresh vapor
#

world.sendMessage() is also not a thing in this version?

light yoke
#

ye

#

.say

#

.say renamed to .sendMessage

fresh vapor
#

And these things in stable will get replaced by the new ones that are in docs?

light yoke
#

yes

shell fog
#

Yeah, i recommend doing stuff in preview while using beta apis

light yoke
#

the guide seems to be using latest preview as base

shell fog
#

You'll run into breaking changes more often by using preview, but you also get the most up to date features

fresh vapor
#

finally bao_icon_scripting

light yoke
#

i suggest dont use stable for now atleast as .70 has huge changes

#

u will have hard time

#

just use latest preview mc

shell fog
#

Fyi, you don't need a server folder for the new script api, but you can obviously keep it if you prefer that

light yoke
#

yea

shell fog
#

Atm, there are tons of breaking changes because you're relying on the beta api which they are still fleshing out

#

As more features get put on a stable version, this will obviously cut down

fresh vapor
shell fog
fresh vapor
shell fog
#

You technically can use a version switcher to stay on one version of the game, or you could write utility functions that can help you adjust to changes much easier

light yoke
#

with what u are doing it wont be that painful if u start with .70

#

i think .70 stable is near

#

so using .60 as base is pointless

shell fog
#

For something like chess, you'll mostly be relying on javascript more than the api, so you should come into minimal issues

fresh vapor
#

mhmm, alright, thank you very much for all the info guys! I appreciate it. I will go on a lunch now and then right onto C++ programming lecture.

shell fog
#

Fyi, if you'd prefer to use typescript over javascript, there are tools to do so as well

fresh vapor
fresh vapor
#

I hope that Mojang won't write docs in TS only. xd

shell fog
#

Ah, the docs would never be in TS

#

They only natively support js

light yoke
#

yeah auto complete is enough ig

shell fog
#

You can still use the types in js anyway by using npm

fresh vapor
fresh vapor
#

why would I do that?

#

dynamically typed vars should be just fine, no?

light yoke
#

a the thing where u type a world and it suggest u stuff

shell fog
light yoke
#

using type definations u can get api suggestions

#

so no need to check doc again amd again

shell fog
#

Hopefully i typed that version format correctly

fresh vapor
#

doesn't debugger provide this?

light yoke
#

ye that

fresh vapor
#

the plugin does that for me

shell fog
#

Does it really? Huh

#

I don't use the debugger

light yoke
shell fog
#

I tried @preview the other day and confused myself

fresh vapor
shell fog
#

Yeah, i just dont use the debugger because my setup doesn't allow for it

fresh vapor
#

gotta go otherwise I will be late, thanks!

fresh vapor
#

u don't use vs code or something?

shell fog
#

I use ts and store my files in different directories than com.mojang

fresh vapor
#

how do you sync them to mc then?

shell fog
#

Not sure if it depends on com.mojang, but the ts part def breaks it

shell fog
fresh vapor
#

ahaaa

#

that's what it is for xd

shell fog
#

Yeah, i use regolith and run a filter to convert my ts to a js file

fresh vapor
#

Understood, the reason why I don't want to use TS is cause it gets translated into JS for execution...

#

so, it kinda does not make sense to me

#

but I get that it has static typing for vars and other cool features that JS does not

shell fog
#

Type checking helps sometimes, so i like to have it

fresh vapor
#

it's closer to C#...

shell fog
#

Most of the other features have been adopted by javascript in newer versions

#

Besides enums

light yoke
#

huh

fresh vapor
#

js does not have enums?

#

even c has them

light yoke
#

no

shell fog
#

The closest to enums is just indexing an object

fresh vapor
#

aha, interesting

light yoke
#
const AB = Object.freeze({
  aa: 0,
  bb: 1,
  cc: 2
})```
#

thats enum in js

#

xd

fresh vapor
#

gotta go, see you and ty for the chat xd

shell fog
#

👋

analog copper
light yoke
#

in code its using system but did not import it

fresh vapor
#

where are pack folders located for the Preview?

#

nvm, found it in the appdata

light yoke
#

ye

fresh vapor
#

oh many of these classes are there?

light yoke
#

?modules

light yoke
#

se server doc

light yoke
fresh vapor
light yoke
#

Uh?

#

thats api ref

fresh vapor
#

Mhmm, thanks!

#

So, there are just 2 objects. xd

light yoke
#

ye

#

that 2 objects covers everything

foggy arrow
#

?manifest