#Non-experimental parts of Script API
1 messages · Page 1 of 1 (latest)
Thank you, Jayly! I'm starting to learn Script API, again... I mean I've done some things in Scripting API if that counts. The naming scheme is such a mess tho. xd I wanted to ask, would it be possible to implement a game logic like chess or tic-tac-toe with Script API?
non-beta apis? No. With beta apis it really depends how you make it
Damn, I mean with Scripting API these things were completely possible...
What are Beta APIs? Btw, I want to write the game logic in JavaScript, not with commands.
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.
its possible
we have beta apis and stable apis beta api need exp toggle in settings turned on while stable apis are part of normal game does not require extra world settings
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
Perfect, that's what I needed to know.
I just wish there was more information about the the actual API...
I followed the documentation on how to setup Script API in VS Code (https://learn.microsoft.com/en-us/minecraft/creator/documents/scriptdevelopertools), but I can't do /script debugger connect localhost 19144 it says failed to start debugger, any ideas what the issue is? The modules are installed and the VS Code plugin is in as well. Appreciate your answers.
just get addon working first
the addon is working and is inside of the development behaviors folder
okay well i never used debugger as i do things manually so wait for someone :/
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
}
]
}```
The debugger is supposed to create a local server for me that I will be able to test the scripts on, correct?
I mean in this case... Otherwise, of course that debugger does not do that.
I mean the VS Code plugin takes care of this...
uh it helps u debug code im realtime
BDS is a bedrock server software
its nothing to with scripts
uh
ur local game is a server in itself
when we say server we mean host of the world not a BDS or such
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?
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
So, BDS is something like Spigot on Java?
🤔
gametests are small unit testing scripts used to automate game mechanics testing
its not usefull for creators
aha, that's what I also figured from the docs
it's useful for gameplay devs and testers
creators uses generic sctipt api for content
understood, lesson learned, getting an error
import { world, system } from "@minecraft/server"
is the documentation incorrect then?
also is there a command to reload the scripts in the game?
which doc u saw
yes /reload
the mc plugin does it automatically
as soon u make changes its reloaded
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
aha, I see xd

ur on stable mc ?
yes, but with experiments
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
world.sendMessage() is also not a thing in this version?
And these things in stable will get replaced by the new ones that are in docs?
yes
Yeah, i recommend doing stuff in preview while using beta apis
the guide seems to be using latest preview as base
You'll run into breaking changes more often by using preview, but you also get the most up to date features
finally 
will do
i suggest dont use stable for now atleast as .70 has huge changes
u will have hard time
just use latest preview mc
Fyi, you don't need a server folder for the new script api, but you can obviously keep it if you prefer that
yea
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
understood, there used to be a folder for client and server back in the days of Scripting API, so I'm kind of used to it.
Yeah, i getcha, atm there are no client scripts, maybe those will come eventually.
I see, I have 1 year to write it.
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
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
For something like chess, you'll mostly be relying on javascript more than the api, so you should come into minimal issues
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.
Fyi, if you'd prefer to use typescript over javascript, there are tools to do so as well
yup, that's right, the mimimax, alpha beta prunning and other algos will be the main thing
read the docs about it, but I'd prefer to stay on pure js
I hope that Mojang won't write docs in TS only. xd
yeah auto complete is enough ig
You can still use the types in js anyway by using npm
umm, what do you mean?
you mean like static typed variables?
why would I do that?
dynamically typed vars should be just fine, no?
a the thing where u type a world and it suggest u stuff
npm i @minecraft/[email protected]
using type definations u can get api suggestions
so no need to check doc again amd again
Hopefully i typed that version format correctly
ye that
the plugin does that for me
why not minecraft/server@beta
oh, that's what it was
I tried @preview the other day and confused myself
Yeah, i just dont use the debugger because my setup doesn't allow for it
gotta go otherwise I will be late, thanks!
why? 👀
u don't use vs code or something?
I use ts and store my files in different directories than com.mojang
how do you sync them to mc then?
Not sure if it depends on com.mojang, but the ts part def breaks it
A tool called regolith
Yeah, i use regolith and run a filter to convert my ts to a js file
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
Type checking helps sometimes, so i like to have it
it's closer to C#...
Most of the other features have been adopted by javascript in newer versions
Besides enums
huh
no
The closest to enums is just indexing an object
aha, interesting
gotta go, see you and ty for the chat xd
👋
what do I fix
in code its using system but did not import it
ye
oh many of these classes are there?
?modules
Gameplay
@minecraft/server
https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server/minecraft-server
@minecraft/server-ui
https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server-ui/minecraft-server-ui
Bedrock Dedicated Server
@minecraft/server-net
https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server-net/minecraft-server-net
@minecraft/server-admin
https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server-admin/minecraft-server-admin
Testing
@minecraft/server-gametest
https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server-gametest/minecraft-server-gametest
se server doc
those are instance objects exported by game but we also have classes
I mean I was talking about world, system... not about modules.
Uh?
u can find everything that u can import at https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server/minecraft-server
thats api ref
?manifest