#Script API General

1 messages ยท Page 20 of 1

distant tulip
#

yeah
btw no one use var

valid ice
#

Each element in an array can be whatever you want

glacial widget
scarlet sable
#

var as abbreviation for variable not the global function

#

I use let

distant tulip
#

alr

scarlet sable
#

var was useful when I was coding arduino

glacial widget
scarlet sable
glacial widget
#

yh true but objects is so good for saving data

valid ice
#

Both have their use cases

glacial widget
#

yeah the same goes for switch and if statments

valid ice
#

The code is only as powerful as the creator makes it

distant tulip
#

using array with objects bao_icon_particles

scarlet sable
#

I still don't completely understand objects

#

it's a var with 2 values?

#

or more

valid ice
#

As many as you want

scarlet sable
#

how to I use each value?

distant tulip
#

and each variable have a key

scarlet sable
#

oh

#

that's what key is for

distant tulip
#

const obj = {
key: "test1"
}

console.log(obj.key)

valid ice
scarlet sable
#

that's actually quite simple

#

I still can't believe I made this much progress in 2 days lol

glacial widget
distant tulip
distant tulip
#

world.getPlayers()

#

that is one

glacial widget
distant tulip
valid ice
#

If the creator writes bad code, that ain't the programs fault

distant tulip
#

unless it is python

#

jk

glacial widget
distant tulip
glacial widget
#

python has a easy entry but have you not seen the about of def = functions you need just for a checker

scarlet sable
#

i wonder

distant tulip
#

huh

#

: not =

scarlet sable
#

oh ye

valid ice
#

Can just do pos1 = getPlayerLocation()

distant tulip
#

also remove ;

glacial widget
distant tulip
#

getPlayerLocation return an obj

glacial widget
scarlet sable
#

it gives a weird error

#

object ; object

valid ice
#

Error?

distant tulip
scarlet sable
#

yep in mc

#

well not really an error

valid ice
#

Do you have that function defined in your code anywhere

scarlet sable
glacial widget
scarlet sable
valid ice
distant tulip
scarlet sable
distant tulip
#

use JSON.stringify(obj)

glacial widget
#

i gotta start adding console logs at the start of a event to check if its working or not

valid ice
#

Can do JSON.stringify(objectData) to get it as a string

scarlet sable
#

silence so loud fr

#

๐Ÿ’€

#

so there's a mistake?

#

the = sign

#

?

distant tulip
#

let cameraPoint = []

scarlet sable
#

nvm

distant tulip
#

and push to it

scarlet sable
#

it was the =

#

btw what does that mean? @valid ice

shy leaf
#

1 day until Full Satisfaction

valid ice
#

Satisfactory, a game which has been in early access since 2018, is releasing tomorrow at 8:00 am PST

scarlet sable
#

oh wow

#

btw how do i check if a var has a value?

valid ice
#

Can check if it equals null

#

value == null

scarlet sable
#

oh that's smart

valid ice
#

Also pls refer to variables as values so ppl don't confuse it with actual var ๐Ÿ˜›

scarlet sable
scarlet sable
pulsar musk
#

Can someone help me, I need to take the armor from the eslots from a chest and put them on a mob, I tried this but it doesn't work :C

The variable cofre and chest should be chest but I forgot haha, but that is not the error.

valid ice
#

Equippable component only works on players atm

scarlet sable
scarlet sable
#

ok I found it

pulsar musk
valid ice
#

There sure ain't

pulsar musk
chilly fractal
#

Yeah like to get where a block is facing and to set where a block is facing, I will get the direction from an old block and set the new block's direction to it.

scarlet sable
#

this doesn't appear as an error in vs

#

I'm a bit confused

valid ice
#

Are you using stable or beta apis?

#

What manifest script version

scarlet sable
#

chatSend is beta?

valid ice
#

Yep

scarlet sable
#

no way

#

that sucks

chilly fractal
scarlet sable
#

/reload reloads the manifest too?

valid ice
#

Nop

distant tulip
#

scripts and functions files only

scarlet sable
#

okie

chilly fractal
distant tulip
chilly fractal
#

??

#

Lemme get u a Clearer picture

#

I'm making a block picking up

scarlet sable
#

isn't 1.14.0-beta the latest?

thorn flicker
chilly fractal
#

Basically I copy a block by blah blah, structure block, and eventually I'm placing it, I get the old block and the structure block

scarlet sable
#

still

#

undefined

chilly fractal
#

I wanna set the structure block's direction to the old block (one placed from item)

shy leaf
chilly fractal
#

Also I gtg rn cuz im really tired

scarlet sable
shy leaf
#

odd

chilly fractal
#

It's 1:40am for me so ya

valid ice
scarlet sable
#

oh

#

let's go it works

#

ok this coming coming together very nicely

neat hound
# scarlet sable

Are you using VSCode?
If so, you may want to...

  • add //@ts-check at the top of your js files.
  • make sure to install the latest npm files so it can intellicode correctly
  • use jdoc notation above functions do define what the types are

This will keep you out of a lot of typos. There is one more, it is to see the TS annotations. It helps a lot to catch ahead of time..... I am not sure how I did it though...

..and as some on here will say... or just use Typescript.... I don't though... the above keeps me locked in.

scarlet sable
scarlet sable
neat hound
#

Provided your array is valid, I guess. Looks fine to me.

#

You do know that chatSend is still beta, right

scarlet sable
#

how do i check if the array still has info in it?

scarlet sable
neat hound
#

so, just make sure latest beta or preview beta

scarlet sable
#

yep it's working so far

neat hound
#

I saw an earlier post

scarlet sable
#

yep

scarlet sable
neat hound
#

you can use filter

#

You are nulling entries in the array.... maybe slice them out if unwanted

scarlet sable
#

lemme check

neat hound
#

then when .length=0...

valid ice
#

Can also just set the array to [] again

scarlet sable
neat hound
#

but he did not mention [0]

valid ice
#

Oh yeh

scarlet sable
#

i started from 1

neat hound
#

you did 1 and 2, waht baout 0

valid ice
#

Arrays index from zero, BTW

scarlet sable
#

ye

#

0 for losers lmao

#

i just didn't feel like using the 0

valid ice
#

Bro thinks we in Matlab ๐Ÿ”ฅ

neat hound
scarlet sable
#

why tho?

#

ohhh

valid ice
#

0 is love, 0 is life (for more than just array indexing)

scarlet sable
#

bruh i understand now

#

so 2 is just 1

neat hound
#

Because it is at the core of way many more programming languages... so you are calling all of them losers.. and that is not good

scarlet sable
#

and 1 is 0

valid ice
#

The first element is at an index of 0

scarlet sable
#

yep i see now

#

but i didn't get an error code

nocturne berry
#

Does anyone know why it doesn't work? It gives these two errors

[Scripting][error]-TypeError: not a function at <anonymous> (blocks.js:29)

[Scripting][warning]-Script reload did not re-register 'fm:interact' custom block component


world.beforeEvents.worldInitialize.subscribe((eventData) => { eventData.registerCustomComponent("fm:interact", {
        onPlayerInteract(event) {
            const player = event.player;
            const block = event.block;
            const inventoryComponent = player.getComponent("inventory");
            if (!block || !inventoryComponent) return;
            const container = inventoryComponent.container;
            const selectedSlot = player.selectedSlot;

            if (typeof selectedSlot !== "number" || selectedSlot < 0 || selectedSlot >= container.size) return;

            const heldItem = container.getItem(selectedSlot);

            if (heldItem?.typeId === "fm:evil_amulet") {
            if (block.typeId === "fm:mana_generator") {
                    world.getDimension("overworld").runCommandAsync(`summon mob:c_eye ~ ~-0.3 ~`);
                }
            }
        }
    });
});```
valid ice
#

Well you're using it correctly, nothing wrong with what you have

#

You're just skipping an element altogether

scarlet sable
#

fair

valid ice
#

It may give unintentional results in the future, however... but you will run into that when you need to

scarlet sable
#

mhm

#

do i put the event.cancel under the first if?

neat hound
#

What is registerCustomComponent

scarlet sable
#

it gets confusing

valid ice
neat hound
#

I know.. that is why we tell you guys to make a post when you need help that requires a lot of back and forth

scarlet sable
neat hound
#

Shit gets lost in here...

scarlet sable
#

thought shit was banned

neat hound
#

It's lost, so we cannot ban it

valid ice
#

People are mature here

#

And yes, you really should open a post

scarlet sable
#

lets go

scarlet sable
valid ice
#

Posts are for anything, from random one line questions to involved projects

scarlet sable
#

I kinda can't

#

I need a tag

valid ice
#

And as always, I recommend learning basic js syntax & methods before jumping in, and reading the docs to see available methods

untold magnet
#

sup

valid ice
untold magnet
#

is it possible to change entity scale by scripts? i think it is possible

#

hmm

#

entity.getComponent('entityScaleComponent')?

neat hound
neat hound
#

But can you change it or just get the info?

untold magnet
#

but how can i change the entity group using scripts?

neat hound
#

yes

#

and you can call an event in script

#

the event sets the cg

untold magnet
#

entity events right?

#

hmmmmm

untold magnet
#

entity events filters, when the entity got a specific tag, it will change the component group of it, and if the entity doesn't have any tag it will remove it from the component group

shy leaf
#

the only components you can change are in attribute components

#

well, for most of them

untold magnet
#

i know

shy leaf
#

via Entity.triggerEvent()

umbral scarab
#

Would anyone know how I would go about preventing fall damage from specific players?

shy leaf
untold magnet
#

this is what im trying to do;
interacting with the block will scale up the entity inside it ( changing the components group ), hitting the entity will scale it down ( will turn the entity back to norml

untold magnet
shy leaf
#

yeah

umbral scarab
shy leaf
#

player.json

untold magnet
neat hound
untold magnet
umbral scarab
# shy leaf player.json

do you have some example code? I have seen the wiki team damage demo but not sure how to change it

untold magnet
neat hound
untold magnet
#

u don't have to look at a specific place that is out of the entity hitbox to mine the block

untold magnet
neat hound
#

or a property

untold magnet
umbral scarab
#

tyty

neat hound
#

Not saying this is the solution, but I would not rule it out

untold magnet
#

i dont know that much about entities,

shy leaf
#

question

neat hound
shy leaf
#

does firing entity events affect after a tick

neat hound
#

at end of I believe... which is why it is called queue command now

shy leaf
#

no not the commands

#

entity events linked to component groups

neat hound
#

if you want next tick, call a timer that calls the event

neat hound
#

I'm having a nightmare with them now as I make my tree spiders

#

Thing is, sometimes you do not want same tick because change of info cannot be read until next tick... so build in timer delays to call in next tick... if you need that

shy leaf
#

using Entity.triggerEvent()

neat hound
#

You will have to run a conclusive test.....

#

that is what I do... cause I need to know what is happening when

#

if you have a scoreboad with the ticks.. you can have the event tell raw a message with the tick score... and compare to...??

shy leaf
#

ok i dont like this school wifi

#

it died for 5 minutes

shy leaf
shy leaf
#

so that i can change attack component value from negative to positive while falling

#

but sometimes it just doesnt work

#

could be related with Entity.isFalling being weird though

neat hound
#

custom entity?

shy leaf
#

nope, player

neat hound
#

player?

shy leaf
#

yeap

#

for mace

neat hound
#

1.5 block fall had to catch with the eyes...

#

test with having the action bar say when falling... you need debug logging you can turn on and off

shy leaf
#

well yeah ive already done that

#

lol im strict with timing

neat hound
#

while falling...

shy leaf
#

while falling

shy leaf
#

and when the player falls for more than 1.5 blocks, it triggers a component group that removes the old attack component and add the new attack component with value of 1 so that the mace can do damage
if the player did not fall for 1.5 blocks, it uses the combat system i made

#

but apparently the mace just refuses to do damage sometimes lol

neat hound
#

Is it that the mace does not change, or the code did not make it there?

shy leaf
#

not sure

#

also i just realized i was using fall check inside the runInterval

distant tulip
#

do you relay need scripting for that?

shy leaf
#

well i want to minimize the usage of player.json

#

for compatibility

distant tulip
#

do you use it

#

if so compatibility is domed already

shy leaf
#

ik but im making it easy to edit

#

man, only if we had beforeEvents entityHurt or entity attribute component for attack

valid ice
#

Real

distant tulip
shy leaf
#

events

distant tulip
#

events triggered with script?

shy leaf
#

yep

distant tulip
#

try triggering component group directly

shy leaf
#

not sure how to do fall check with that though

tardy wraith
#

is there a way to create a system that executes a command like a command block in repeat?

distant tulip
shy leaf
#

apparently it was the Entity.isFalling

#

i used player.getVelocity().y < 0 instead and its working fine now lol

#

or... not?

abstract cave
#

how do i get all players in the world and run code for each of them

shy leaf
#

or

for (const player of world.getAllPlayers()) {
    //code
};
abstract cave
#

Thanks
forEach
why dont i see this in the jayly docs

shy leaf
#

its a JavaScripts thing

abstract cave
#

oh

neat hound
abstract cave
#

a lot of the shortcuts really confused me in the beginning

neat hound
#

yeah, if everyone did things the long way, or the way that resembles English, the beginners would have a much easier time... but the cool way is to lamda it all up into the shortest code possible so that others have to really know their stuff to decipher.... Some programmer's do not realize that this is the part that trips people up...

#

but then again,... taking the basics class would clear it up

sharp elbow
#

There's simply too many ways to do the same thing. JavaScript somehow supports a functional, object-oriented, and imperative design at the same time

#

A lot of it (arrow functions) are used somewhat harmfully IMO. People should really be naming their functions

neat hound
#

If you think about writing it so that the interns have to maintain it.. then you wirte it better and clearer and documented.. so they do not ask you quiestions.. if they can read english

valid ice
#

A lot of beginner questions can be answered with "whatever you want" which is a pretty drastic change coming from the strict rules of json lol

sharp elbow
#

Arrow functions exist to circumvent oddities with the this keyword. People treat them like "short functions;" when you go to debug that code, you will see a lot of "at <anonymous>" in the stack trace.

#

You can benefit from named functions and arrow functions by assigning it to a variable and using that variable like a function

#

... Or just used name functions

oak hatch
abstract cave
#
import { world, Player, system } from "@minecraft/server";

let mana = 100;
let maxMana = 100;
let manaRegenerate = 1;
let isDisplayingMana = false;

world.getAllPlayers().forEach(player => {
    system?.runInterval(() => {
        if (!player) return;

        const equippable = player.getComponent("minecraft:equippable");
        const equippedItem = equippable?.getEquipmentSlot("Mainhand");

        if (equippedItem && equippedItem?.typeId === "wands:wand") {
            player?.runCommand(`title @s actionbar Mana: ${mana}/${maxMana}`);
        }
    }, 25);

});

i tried fixing this error, but nothing seems to work

[Scripting][error]-InvalidContainerSlotError: The container slot is either empty or is no longer loaded.    at <anonymous> (main.js:12)```
wary edge
abstract cave
#

hmm, what the difference

sharp elbow
#

One returns an ItemStack, one returns an ItemSlot(?)

#

ItemSlots are like containers for ItemStacks; they have a property pointing to the ItemStack

neat hound
abstract cave
neat hound
neat hound
#

Oh don't look all innocent

abstract cave
neat hound
#

The details are where the loopholes are, where the lawyers get you, where you find a new way, how the hackers get in. Programmers, imo, are detailed oriented.. or lousy programmers.

wary edge
#

As Nikki says, I recommend reading the docs

neat hound
#

I read them for fun.. but then again I am special that way...

neat hound
#

look at the classes, see what the properties and methods are, open up the examples and get all kinds of glorious ideas... I intend to be a scripting master...

remote oyster
neat hazel
#

How can I detect if there is a specific block underneath another and do something?
Example: if there is a stone block underneath an obsidian block, the stone block becomes a block

slow walrus
#

mainly just the block.below() part

shut citrus
#

no mob vote mean no new ai goals ?

wary edge
shut citrus
wary edge
shut citrus
#

nope

wary edge
#

Well now you know

slow walrus
#

๐Ÿ˜ฑ

sudden nest
#

to store data (database)

oblique heath
#

is BlockCustomComponent onPlace called only when the player places the block or even in other situations like /setblock?

oblique heath
#

ok

glacial widget
shrewd wedge
#
world.beforeEvents.worldInitialize.subscribe((e) => {
    e.itemComponentRegistry.registerCustomComponent("evo:voids_edge", {
    onUse(e) {
    	const player = e.source;
        const xyz = player.location;
        const dimension = player.dimension;
            
        player.startItemCooldown("custom", 20);
        player.playSound("mob.enderdragon.flap");
        player.runCommandAsync("particle evo:voids_edge_particle ~~~");
        
        durability(player, e.itemStack, 10); 
        
        let nearbyEntities = dimension.getEntities({
            location: player.location,
            maxDistance: 10,
            excludeTypes: ["minecraft:item", "minecraft:xp_orb"]
        });

        nearbyEntities.forEach((entity) => {
            if (entity == player) return;
            if (entity.isValid()) {
            const dx = xyz.x - entity.location.x;
            const dz = xyz.z - entity.location.z;

            const length = Math.sqrt(dx ** 2 + dz ** 2);
            const dx2 = dx / length;
            const dz2 = dz / length;

            entity.applyKnockback(-dx2, -dz2, 3, 0);
            entity.runCommandAsync("particle evo:voids_edge_particle ~~~");
            }
        });
    }
});
#

How to fix this

#

Entity pull away not closer

#

How to make entity pull closer ?

warm drum
#

how can i change an itemstack amoutn?

random flint
#

itemstack.amount = 1

flint barn
#

Question, please: how to avoid using experimental api entity.target to get entity's target? i can't find of a good solutionbao_foxxo_crying

scarlet sable
#

good morning

#

is doing CameraPoint[0]=null; enough to give that let a null value?

shy leaf
#

should be

scarlet sable
#

I'm having an issue with that

shy leaf
#

show code

scarlet sable
#

import { world, system } from "@minecraft/server"; function getPlayer() { const allPlayers = world.getAllPlayers(); if (allPlayers.length === 0) { return undefined; } return allPlayers[0] } function getPlayerLocation() { const player = getPlayer(); if(player === undefined) { return undefined; } return player.location; } function getPlayerRotation() { const player = getPlayer(); if(player === undefined) { return undefined; } return player.getRotation(); } world.beforeEvents.chatSend.subscribe((event) => { const player = event.sender; const message = event.message; let CameraPoint=[1,2]; if(message === "CameraPoint1"){ event.cancel = true; //the first point save if(CameraPoint[1] !== null){ //the point is already full world.sendMessage("ยงcCamera point is already full"); } else if(CameraPoint[1] == null){ CameraPoint[1]= { pos:getPlayerLocation(), rot:getPlayerRotation() } world.sendMessage("ยงqCamera point is set"); } } else if(message === "CameraPoint2"){ event.cancel = true; //the seconde code save if(CameraPoint[2] !== null){ //the point is already full world.sendMessage("ยงcCamera point is already full"); } else if(CameraPoint[2] == null){ CameraPoint[2]= { pos:getPlayerLocation(), rot:getPlayerRotation()} world.sendMessage("ยงqCamera point is set"); } } if(message === "Clear"){ event.cancel = true; if(CameraPoint[1] !== null && CameraPoint[2] !== null){ CameraPoint[1]=null; CameraPoint[2]=null; world.sendMessage("ยงqPoints have been cleared successfully") } else { world.sendMessage("ยงqThe points are already cleared") } } } )

shy leaf
#

for the love of god wrap it with ```js

scarlet sable
#

lmao didn't know that was a thing

scarlet sable
#

map?

shy leaf
#
const cameraPointMap = new Map();

cameraPointMap.set(key, value);
const value = cameraPointMap.get(key);
cameraPointMap.delete(key);
scarlet sable
#

ehh

shy leaf
#

you can put player id into the key

#

its better that way

shy leaf
#

it also remembers the insertion order like how the embed description says

scarlet sable
#

interesting

shy leaf
# scarlet sable interesting

this is how i used it

const playerStatus = new Map();

function initializePlayerStatus(player) {
    const status = {
        sprintKnockbackHit: false,
        sprintKnockbackValid: false,
        critSweepValid: true,
        shieldValid: false,
        mace: false,
        lastSelectedItem: undefined,
        lastSelectedSlot: undefined,
        cooldown: 0,
        lastAttackTime: 0,
        shieldDelay: 0,
        fallDistance: 0,
    };
    playerStatus.set(player.id, status);
}

export function getPlayerStatus(player) {
    if (!playerStatus.has(player.id)) {
        initializePlayerStatus(player);
    }
    return playerStatus.get(player.id);
}```

```js
for (const player of world.getAllPlayers()) {
    const status = getPlayerStatus(player);
    status.lastAttackTime = Date.now();
}```
scarlet sable
#

my brain hurts lol

shy leaf
#

its worth knowing it

scarlet sable
#

yep ig

shy leaf
#

you can also ask GPT about this (no dont ask it about minecraft API, ask em Javascript)

scarlet sable
#

chat gpt and coding ain't on the same line lol

shy leaf
#

im saying it can teach you about it

#

not make the code for you

scarlet sable
#

fair

shy leaf
#

its surprisingly a good teacher

scarlet sable
scarlet sable
#

sweeping edge?

shy leaf
#

the entire java combat

#

not just sweeping edge

scarlet sable
#

that's crazy

#

you make mcpedl packs?

shy leaf
#

no

#

i dont use mcpedl to begin with

scarlet sable
#

you also work for free?

shy leaf
#

maybe? if im willing

#

but mostly i dont accept commission or job offers

#

its just a hobby

scarlet sable
#

oh so just projects for fun?

shy leaf
#

yeah

scarlet sable
scarlet sable
shy leaf
#

does Entity.getRotation() vector2 return the degree of the entity's head yaw and pitch?

shy leaf
#

ig my math was just horribly wrong lol

#

ty for the answer

umbral scarab
umbral scarab
#

After more testing I feel like it's not even checking the players tag and is just acting on whether deals_damage is true or false

rose light
#

Could someone help me remove 1 item from 1 chest? For example, I want to remove 1 coal from the chest every 5 seconds.

#

I have no idea how to do it

remote oyster
untold magnet
#

well well well, i had some issues

rose light
#

it will sit on top of a custom block I made

untold magnet
#

i had to make a script that will spawn an entity at the block location when it has been placed ( already )
and when the entity is out of the block range it will teleport back to the same block, like saving the block location,

#

if the block disappeared, the script will trigger an event

#

lemme explain

remote oyster
#

I can do it in a little bit.

rose light
untold magnet
# untold magnet lemme explain

when u place the block, the entity will spawn and save the block location, when the entity somehow moved out of the block or the block has been pushed by a piston, it will teleport back to the last saved location,
if it teleported back and the block was different it will trigger an event

umbral scarab
#

slotId is a variable that I have to select specific slots

#

but you can loop through the container based on the number of slots the container has and check for coal and remove 1 from the itemStack

#

this is your loop:

for(let i = 0; i < chestInvComp.container.size; i++)
scarlet sable
rose light
scarlet sable
#

atm addon?

rose light
#

I don't know what "ATM" is, but it is an addon.

scarlet sable
#

bruh

#

bro the atm machine that gives cash

#

bro lives in Antarctica or smtg

#
 const map1 = new Map();

map1.set('a', 1);
map1.set('b', 2);
map1.set('c', 3);
#

can i make the value 1 for exemple an object?

sharp elbow
#

Yea, you can put any value in a Map.

scarlet sable
#

let's go

sharp elbow
#

map1.set('a', {prop: 'hi'});

#

Maps are cool in that you can put objects as keys too

scarlet sable
#

what about a array?

sharp elbow
#

Yup, those too

scarlet sable
#

how will it work tho?

sharp elbow
#

Put an array in place of 1. So something like [1, 2, 3]

scarlet sable
#

no like how will I summon it?

#

since when you use maps you only call the name so like the a

sharp elbow
#

Are you wanting to get the value of a key in a Map? That would be map1.get(<your key>), with <your key> being, well, a key

rose light
#

I did it guys, thanks for the help

scarlet sable
#

ok for example

const Player = new map();

map1.set('a',PlayerCount=[1,2,3,4]);
#

don't mind the mistake

#

set is after map

#

but ye

#

if i call a what will happened here

sharp elbow
#

Well, it's invalid syntax. PlayerCount[1,2,3,4] will confuse JavaScript

scarlet sable
#

yep

sharp elbow
#

What is PlayerCount? Is that an array you have defined before? Like: const PlayerCount = [1,2,3,4];?

scarlet sable
#

yep

#

I'm just trying to fast write so it's really an abomination lol

sharp elbow
#

OK, then your example would look more like this:

const PlayerCount = [1,2,3,4];
const Player = new Map();

Player.set('a', PlayerCount);

In which case, calling Player.get('a'); will return the array PlayerCount is assigned to, whose contents are currently [1,2,3,4]

scarlet sable
#

oh nice

#

and by adding a [] you can specify

#

maps are cool af

untold magnet
#

hmm

scarlet sable
untold magnet
#

how to save last location?
i mean when the entity spawn on a specific location, it will save the exact location and teleport the entity back to that location in some cases

untold magnet
scarlet sable
#

entity.location

#

wait i think I'm wrong

#

for a player at least it's player.location

random flint
random flint
#

entitySpawn is stable

#

the rest is JavaScript stuff

scarlet sable
#

ehh

untold magnet
#

wait, thats not exactly what im trying to do

random flint
#

Well, thanks for the helpful info on what you are trying to do

untold magnet
#

inside of runInverval, the script will detect an entiry and checks the entity if it inside of a specific block or not

valid ice
valid ice
#

It's but short ech

scarlet sable
#

mhm

random flint
#

The point is, that the player class can use most of the methods and properties the entity class has to offer

scarlet sable
valid ice
#

Yep

scarlet sable
scarlet sable
untold magnet
#

i hope i explained it right tho

random flint
scarlet sable
#

i wonder if i can re with just addon knowledge

#

like re the mc code

untold magnet
random flint
untold magnet
#

the only problem is idk how to save the location

random flint
#

dynamicProperty can stores Vector3

untold magnet
#

entity.setDynamicProperty right?

random flint
#

yes

untold magnet
#

hmm, I'll check it

scarlet sable
#

mhm

random flint
#

Like the literal object. You don't even need to stringify it

valid ice
scarlet sable
valid ice
#

Oh

#

Uhhhhhhhh good luck with that

scarlet sable
#

does it use js?

remote oyster
scarlet sable
random flint
#

And the API is in QuickJS

untold magnet
scarlet sable
#

ok my head hurts

random flint
untold magnet
random flint
#

Just think of dynamicProperty like Map objects

#

...with restrictive values

remote oyster
#

Was gonna say that lol

#

You beat me to it.

untold magnet
#

||i saved the last entity location, but how can i used :/||

#

โ†‘ Stupid

random flint
#

Retrieve it somewhere? When your entity need to teleport?

remote oyster
#
let location = entity.getDynamicProperty("loc1");

console.log(location.y);
untold magnet
random flint
#
let location = entity.getDynamicProperty("loc1");
entity.teleport(location);
umbral scarab
#

I've made this after following up from a question and conversation I had yesterday but this semi works. I feel like it's not even checking the players tag and is just acting on whether deals_damage is true or false

#

any solutions?

random flint
#

That's... is that json?

untold magnet
#

?

#

i think setDyn not getDyn

random flint
random flint
#

I mean, they say it canceled the damage. The filter thingy just doesn't work on their end.

untold magnet
#

hmm

umbral scarab
prisma shard
#

HELO

untold magnet
distant tulip
# umbral scarab how so?
      "minecraft:damage_sensor": {
        "triggers": [
          {
            "on_damage": {
              "filters": {
                "all_of": [
                  {
                    "test": "has_tag",
                    "subject": "self",
                    "operator": "==",
                    "value": "noFall"
                  },
                  {
                    "test": "has_damage",
                    "subject": "self",
                    "operator": "==",
                    "value": "fall"
                  }
                ]
              }
            },
            "deals_damage": false
          }
        ]
      }
random flint
#

It doesn't feel like it belongs to script API tbh

distant tulip
umbral scarab
prisma shard
#

i just logged in discord after a whole month

untold magnet
# untold magnet hmm

should i use system.runTimeout to run a command after the entity teleports back to the last loc to detect the block?

random flint
prisma shard
distant tulip
#

lol

prisma shard
#

but i'm not active every day, that's for sure

#

i just logged in maybe after a week

#

for sure

untold magnet
#

entity.teleport(loc);
system.runTimeout(() => { ,,, }, 2)?

remote oyster
prisma shard
untold magnet
prisma shard
remote oyster
#

๐Ÿค”

distant tulip
#

skipped tow days ๐Ÿ˜ฑ

random flint
#

I mean, I'll acknowledge it if you only send 1-5 messages each day lol

prisma shard
# distant tulip skipped tow days ๐Ÿ˜ฑ

Listen, let me describe what i want to say.
I've been doing a lots of homeworks nowadays and i've been being busy for all day long, which could've make me think that a week like a month. I had half-time school before days, so i used to do actively chatting, but then my full time schools started, and that feels like a big change to me. So you might understood

#

@remote oyster

#

And, no. i didn't take your "skiped tow days" as a serious thing

#

i know that was a joke

#

sorry for the inconvenience

distant tulip
#

you took that a little too seriously

wanton ocean
#

๐Ÿ˜ญ

#

Never skip tow days

prisma shard
#

lel

subtle cove
wanton ocean
#

How does one think a week is a month though

#

Just say it was hyperbole

prisma shard
#

hyperbole

#

ok then

distant tulip
wanton ocean
#

True

untold magnet
#

const entity = world.getEntity('entityId') returns a log, why?

distant tulip
wanton ocean
#

How do add scoreboard to killer of specific mobs

#

Trust

untold magnet
#

so i have to do getDim().getEntities thing?

distant tulip
#

yeah

distant tulip
wanton ocean
distant tulip
#

huh

subtle cove
#

*tow awurs

umbral scarab
spare sentinel
#

or all

#

I don't remember

distant tulip
umbral scarab
shut citrus
#

why?

crude bridge
#

Yooo

#

vote for the addon i created?(chat ranks)

crude bridge
valid ice
#

Neat

wanton ocean
#

Member

crude bridge
untold magnet
#

block.center will detect if the entity is inside the block?

#

if (block.center.typeId === 'myBlock') ///
if (block.center.typeId !== 'myBlock') \\

#

?

untold magnet
#

i mean the entity should detect if it was inside the block or not

wary edge
#

Or edit the entoty json

untold magnet
#

nvm im so stupid

distant tulip
#

how to add something to items via script that animations can read

wary edge
distant tulip
# wary edge Wdym animations can read?

i want to hide part of attachable when player is performing a task
query functions don't seem to have anything
maybe scoreboard but then i have to set the score display

wary edge
distant tulip
#

All roads lead to Rome player.json

#

that break compatibility

untold magnet
#

entity.triggerEvent('exe:despawn')

#

the entity is getting that event trigger, but with this log

distant tulip
#

double check the event name

untold magnet
#

the event is triggering, but with that log

distant tulip
#

stop the trigger if the entity is not valid

untold magnet
sharp elbow
#

isValid is a method; invoke it. entity.isValid()

distant tulip
#

also valid not vaild

scarlet sable
#

I want to learn message editing too

untold magnet
#

i think, the best way to do that is by making the entity moving with the block, like when u push it up it will go up with the block

#

using is_pushable_by_piston

crude bridge
#

If you want i can send you a example

#

@scarlet sable

oblique heath
#

All fun and games until you kill your fake block entity by accident with /kill @e

#

๐Ÿ˜†

glacial widget
untold magnet
untold magnet
oblique heath
#

๐Ÿ˜ญ

unreal cove
untold magnet
#

i might done it wrong

untold magnet
#

gosh i had to make a script that will make the block entity is moving with the block, like when u push the block up it will move with it, when u push back the block it will keep inside the block

#

i think that can be done using onTick components inside the block

scarlet sable
#

btw how do I copyright my work?

crude bridge
meager pulsar
#

What's a job and what does "run job" does?

lyric kestrel
#

Is playerPlaceBlock, beta?

import {world, Block} from "@minecraft/server";

world.beforeEvents.playerPlaceBlock.subscribe((e) => {
    const block = e.block;
    const player = e.player;
    let location = {
        x: block.x,
        y: block.y,
        z: block.z
    }
    console.warn(block.location)
})```
valid ice
lyric kestrel
#

ah

#

interesting

#

Thought both would be stable at the same time

valid ice
#

That would make sense lol

lyric kestrel
#

So, if I activate beta and use playerPlaceBlock, it will be added to stable later or so?

#

Since it's already being used with afterEvent?

#

Sorry, that doesn't seem like I'm talking sense.
I mean is it possible that it gets removed from beforeEvents at some point?

wary edge
lyric kestrel
#

I guess I'll risk it. There doesn't seem to be another option

distant tulip
scarlet sable
fallow rivet
#

Is it possible to prevent a blog from being pushed with a piston?

scarlet sable
#
world.beforeEvents.chatSend.subscribe((event) => {
  const player = event.sender;
  const message = event.message;
  let CameraPoints = [0,1];
  if (message === "SetCameraPoint") {
    if(CameraPoints[0] === null){
      event.cancel = true;
      CameraPoints[0]={pos:getPlayerLocation,rot:getPlayerRotation};
      world.sendMessage("ยงqFirst camera point was set successfuly");
    }
    else{
       event.cancel = true;
       world.sendMessage("ยงcThe first camera point is already full");
    }
  }
  if (message === "clear"){
    event.cancel = true;
    CameraPoints[0]=null;
    world.sendMessage("ยงqAll the camera points were cleared sucessfuly");
  }
}
#

it seems that CameraPoints[0] is never null

abstract cave
#

Is it possible to make an animation, like that of the "use_animation" component in item components run when you use an Item with onUse

shy leaf
scarlet sable
shy leaf
#

tell me what youre exactly trying

#

ill try to make it

scarlet sable
#

fair

#

if a player sends SetCameraPoint the scripts checks if the CameraPoint1 has a value of null if it does it gives it a new value (CameraPoint1 is an object btw) so pos gets the valus of the function getplayerposition and rot gets getplayerrotation

#

camera point 1 has 2 characteristics as an object which are pos and rot

#

idk how update that stuff if CameraPoint1 is in a map

shy leaf
#

ill make it after breakfast

scarlet sable
#

breakfast?

#

oh american

#

(it's midnight here)

shy leaf
scarlet sable
#

cool country

meager pulsar
#

And what is yield!

#

Yield?*

valid ice
neat hound
#

Scripting-Gods... I am having a brain-fart... wasn't there something that was like an enum of the dimension types... such that you could dimentionType.overworld which is overworld string or dimensionType['overworld']. DimensionType is a class with a typeId... I am a bit confused.

shy leaf
neat hound
scarlet sable
#

if I assign a value to a map element how do I change it later?

shy leaf
neat hound
scarlet sable
#

.set?

neat hound
shy leaf
#

yeppers

scarlet sable
#

and get to check the value?

neat hound
shy leaf
#

though if you have array inside map you can just do map.get(key).value = yeet

scarlet sable
#

nice

sharp elbow
#

Depends. If the map value is an object, assigning a variable to that value lets you modify it without needing to explicitly call .set

shy leaf
scarlet sable
#

ig maps are cool after all

scarlet sable
#

I'm using an object

shy leaf
neat hound
shy leaf
#

oh

scarlet sable
neat hound
#

even thou I am the only user, I like to idiot proof it

#

and if they add a new dimension, that means I have to go update.. which is not future proofed

sharp elbow
#
const MyMap = new Map([
  ['a', {foo: "hi"}]
]);

let obj = MyMap.get('a');
console.warn(obj);            // {foo: "hi"}

obj.bar = "there"
console.warn(obj);            // {foo: "hi", bar: "there"}
console.warn(MyMap.get('a')); // {foo: "hi", bar: "there"}
neat hound
neat hound
#

I don't think the warn in MC does the object.... right?

#

node yes

sharp elbow
#

No, you'll get [object Object]โ€”but putting JSON.stringify(blahblah) would have bloated the example

neat hound
neat hound
scarlet sable
neat hound
#

the language is the language

scarlet sable
neat hound
#

the classes and props are the api

sharp elbow
#

API-agnostic features like Map are going to be found in any (practical) implementation of JS

wary edge
#

I presume youre talking about the API and not the actual language

neat hound
#

map is language

scarlet sable
#

anyways I'll take a try and comeback

neat hound
sharp elbow
#

MDN is my go-to for reference

neat hound
#

I like geeks.. they give all the ways to do something, I love that

#

I use mdn too

sharp elbow
#

I think MDN goes more in-depth, and tends to mention easy pitfalls for novice programmers (which I have nearly fallen into before)

scarlet sable
#

been checking out that topic for at least an hour

sharp elbow
#

If you want one that will hurt your head, check out Array.prototype.reduce

scarlet sable
#

I believe asking the dumbest questions gives the best info

scarlet sable
#

and split

#

it's not hard tbh

#

but i don't see a use for it

neat hound
#

I believe asking after you cannot figure it out produces a great self-sufficient thiinker... the only type of programmer I trust with my stuff at work... everyone else.. is just a user.. push buttons

sharp elbow
#

If you understand the idea of reducer functions, kudos to you ๐Ÿ˜

neat hound
#

If you want JS practice... do codewars dot com..... people do get ridiculous with refactoring imo

scarlet sable
#

this one seems quite simple

neat hound
#

some solutions are mind boggling

sharp elbow
#

Usually there are clearer ways to do the same thing, but not always. I can't quite wrap my head around it intuitively, and it takes me a good few minutes to write a good Array.reduce

scarlet sable
#

well understanding a code and write one is not the same

#

I 100% can't write a reduce code

sharp elbow
#

Here is a vector.add function I put together using array.reduce

static add(...vecs: Vector3[]): Vector3 {
    return vecs.reduce((old, anew) => {
        const out = {...old};
        out.x += anew.x;
        out.y += anew.y;
        out.z += anew.z;
        return out;
    });
}
scarlet sable
#

welp idk how static works

#

Vector 3 is a point with 3 axis right?

sharp elbow
#

It's about classes, don't worry too much about thatโ€”read that as "function" for the moment

scarlet sable
#

what was that?

sharp elbow
#

epic fail

scarlet sable
#

lol

sharp elbow
#

As part of a broader Vector class, it would be used like this:

let a = {x: 1, y: 1, z: 0};
let b = {x: 1, y: 0, z: 2};
let c = {x: 0, y: 3, z: 3};

const sum = Vector.add(a, b, c);
consle.warn(sum);  // {x: 2, y: 4, z: 5}
neat hound
#

Here is an example of why GeeksForGeeks is good for concepts... not many list it out like this so you can look one by one...

scarlet sable
neat hound
remote oyster
#

That's a spreader

scarlet sable
#

oh ye

sharp elbow
#

The notable figure there is the spread operator: ... In a function declaration, it lets the function know it should accept any number of arguments

remote oyster
scarlet sable
#

like this one?

sharp elbow
#

The resulting value gets passed as a single parameter (named vecs here), and it's an array

neat hound
#

vector is just an object with 3 properties... x,y,z

scarlet sable
#

a victor is just coords

neat hound
#

what do you mean by points

scarlet sable
#

vector*

#

dots

#

...

neat hound
#

yes coords....

#

x y z

sharp elbow
#

Yes, otherwise known as a single point in space!

neat hound
#

what is the trouble you are having

scarlet sable
scarlet sable
sharp elbow
#

Probably doesn't help that "point" and "dot" could both refer to a period

#

And that "point" can refer to both a period and a Vector3

scarlet sable
#

lol

#

true

#

I need to work on my orthograph ig

sharp elbow
#

But yes, spread syntax is handy, in functions and beyond

remote oyster
scarlet sable
sharp elbow
#

I did just paste that from a larger file without any context, so that's all right

scarlet sable
#

ye context is important

sharp elbow
#

Technically a static method must be part of a class declaration, so a proper, fully usable snippet of that code would be like:

class Vector {
  static add(...vecs) {/* ... */}
}
neat hound
sharp elbow
#

You can get pretty far without knowing class syntax

neat hound
#

I mean class-class

shy leaf
#

class & static feels like zip files or executable shortcuts for me lol

#

ok i made a bad spelling mistake but my wifi wont let me edit it

neat hound
#

bad wifi.. bad wifi

shy leaf
#

there we go

sharp elbow
#

class log { static zip() {}} be hitting you with that log.zip()

scarlet sable
#

Just a reminder of casual stuff

#

Didn't find the time for a full 20h course tbh

neat hound
#

sometimes I use a file as a class... import * as thisClass.... then use everything like a class member

scarlet sable
#

Also i find the api really fun so I'm trying to memorize as much stuff as possible for the moment

neat hound
#

well, as long as you are happy

scarlet sable
sharp elbow
#

I always keep the scripting API documentation open every time I work with the API

scarlet sable
#

Oh really?

shy leaf
#

jayly docs my beloved

scarlet sable
#

I thought it's a muscle memory ngl

#

Like when you're writing a logical equation and the symbols just get written without thinking

sharp elbow
#

Some of it is. You learn that world.getPlayers() returns a Player array, and you remember all the properties on the Player class you want through repetition. But some stuff is wildly niche and I have to go looking for what classes are capable of which things

valid ice
#

That comes with time & practice, really

#

The more you use something the more adept you become with it (goes for anything in life)

scarlet sable
#

I always wonder if people working with companies on add-ons are allowed to use Google for such stuff

#

In the marketplace

sharp elbow
#

Of course, they're people like us too, and liable to make mistakes. Not everyone knows everything off-hand

scarlet sable
#

Fair point

sharp elbow
#

Now if you were to ask me about command wizardry, I might be able to do that without a reference, though I'm kinda rusty

scarlet sable
#

Is anyone a member of a marketplace company?

scarlet sable
#

Oh

neat hound
#

I am not

scarlet sable
#

Interesting

shy leaf
#

not me

sharp elbow
#

I consider myself a hobbyist first before a Marketplace company employee though

wary edge
#

Like wise

shy leaf
scarlet sable
#

Is like each member assigned for a specific task? Or just the code kinda flies from one person to another?

neat hound
#

I plan to undercut the market place and do great things for free.... after I become an add-on genius

scarlet sable
#

I want to create a mod client

sharp elbow
#

Really depends on the company structure. Most of them will be like what you've described; and the team will (should) use some version-control software to identify who did what and when

neat hound
#

then get serious about your language learning... and maybe do typescript...

valid ice
#

GitHub is good ๐Ÿ‘

#

(Other stuff exists as well lol)

scarlet sable
shy leaf
sharp elbow
#

me using microsoft's github to store code written in microsoft's vscode for microsoft's game

scarlet sable
#

And i want to get good grades on my finals so i can choose maybe a tech relatable uni

valid ice
#

Ironicโ€ฆ schools are used to learn xD

scarlet sable
#

Fr

neat hound
#

if you are not fund-strapped, I suggest Mosh Hamedani All Access Pass... take a year and learn a lot of languages.. well not a lot but a few key... beginner to advanced...

scarlet sable
#

Idk why or When i will use a random french poem tbh but ok

scarlet sable
#

I'm broke af

#

If not get a job in the next 5 years might become borderline homeless lol

neat hound
#

well, there is a lot free on YouTUbe.. like alot... and if you really into it.. then you are already devouring it

scarlet sable
#

What is the stuff i need to focus on when it comes to js?

neat hound
#

Even take the FREE famous Harvard class that teaches a lot of basics

valid ice
#

Depends- just script API stuff? Or web dev stuff as well?

distant tulip
#

depend on your goal

scarlet sable
#

Api atm

valid ice
#

Because a decent chunk of JavaScript can be cut out if youโ€™re just interested in script API

scarlet sable
#

I want to start making add-ons nothing else

sharp elbow
#

Really just knowing the primitive language features, and being familiar with both an object-oriented design (you're doing this already with methods like Array.sort()) and a functional design (writing functions to re-use code)

scarlet sable
#

Btw has anyone use a matrix in a code before?

sharp elbow
#

Mm, I haven't but I have meant to

distant tulip
#

tbh i find my self a lot making scripts outside the api to help in the addons development it self

valid ice
#

2D array?

scarlet sable
sharp elbow
#

JS lets you make arbitrarily deep arrays by nesting them together, but there are not any native matrix libraries (that I know of)

scarlet sable
sharp elbow
#

I also possess an extremely poor understanding of linear algebra so I probably will not be working with matrices anytime soon lol

scarlet sable
#

Using math in a code could be a cool way for me to train my coding skills and prepare for my actual classes

neat hound
scarlet sable
#

But i wonder if i Ill get the chance to do that

distant tulip
sharp elbow
#

Oh absolutely. In my Calc III class we are working with vectors a lot, and I already have some practice from writing a small Vector library

scarlet sable
#

Oh ye vectors

#

We have lots of stuff about it this year inchallah

sharp elbow
#

Goes both ways. What I learn also helps me understand what vectors are doing better (cross products were so confusing)

scarlet sable
#

That'll be fun

valid ice
#

Vectors are very fun :3

scarlet sable
#

๐Ÿ’€

neat hound
#

there is an other format if you want to store the dimension in there too...

scarlet sable
#

I thought at first it was a physics vector

#

I would've probably never self guessed it was just x y z coords

valid ice
#

At least to Minecraft

scarlet sable
#

In school it's identified with intensity and direction

#

But ig you can get these info using coords

valid ice
#

In Minecraft it can be both stored in the same format

distant tulip
#

locations are not vectors in physics

valid ice
#

E.g. block location, or view direction

neat hound
#

I KNEW THERE was... a dimension enum.... MinecraftDimensionTypes

abstract cave
#

Idk why it gives me this error, im clearly geting the tags from the equippableItem variiable

    at forEach (native)
    at <anonymous> (custom_components/wand.js:45)```

Here my code
```js
system.runInterval(() => {
    world.getAllPlayers().forEach(player => {

        if (!player) return;

        const equippable = player.getComponent("minecraft:equippable");
        const equippedItem = equippable?.getEquipment("Mainhand");
        const itemTag = equippedItem.getTags();

        if (equippedItem && equippedItem?.typeId === "wands:wand" || itemTag === "wands") {
            player?.runCommand(`title @s actionbar ยงb:: Mana: ${mana}/${maxMana} ::`);
        }
    });
}, 20);
scarlet sable
#

What's a minecraftcooldowncathegory?

neat hound
#

I grabbed the wrong one

scarlet sable
#

Oh fair

neat hound
#

its in the vanilla data

distant tulip
scarlet sable
#

Like the pearl hotbar cooldown?

distant tulip
#

the type that make other items in the same category start a cooldown

scarlet sable
#

Oh that's so cool

neat hound
#
var MinecraftCooldownCategoryTypes = (MinecraftCooldownCategoryTypes2 => {
   MinecraftCooldownCategoryTypes2["Chorusfruit"] = "minecraft:chorusfruit";
   MinecraftCooldownCategoryTypes2["EnderPearl"] = "minecraft:ender_pearl";
   MinecraftCooldownCategoryTypes2["GoatHorn"] = "minecraft:goat_horn";
   MinecraftCooldownCategoryTypes2["Shield"] = "minecraft:shield";
   MinecraftCooldownCategoryTypes2["WindCharge"] = "minecraft:wind_charge";
   return MinecraftCooldownCategoryTypes2```
scarlet sable
#

You can use that in combat system

#

Anyways it's quite late

scarlet sable
#

I need to go

neat hound
#
var MinecraftDimensionTypes = (MinecraftDimensionTypes2 => {
   MinecraftDimensionTypes2["Nether"] = "minecraft:nether";
   MinecraftDimensionTypes2["Overworld"] = "minecraft:overworld";
   MinecraftDimensionTypes2["TheEnd"] = "minecraft:the_end";
   return MinecraftDimensionTypes2```
scarlet sable
#

Oh ye one more thing

#

Is it possible to add a dimension?

distant tulip
#

no

scarlet sable
#

Expected

#

Java on top ig

neat hound
#

I will never use wrong

#

but we all have brain farts

distant tulip
#

true

neat hound
#

It is from mricosoft's file from one of the npms

scarlet sable
#

My brain has 70% brain farts instead of cells

neat hound
#

but I think I better use getAll() and map it

scarlet sable
wary edge
scarlet sable
#

Damn bro don't roast me like that xD

neat hound
#

what he said

#

not a bro

distant tulip
#

lol

scarlet sable
#

Bro is not gendered in my context bao_ext_toldyouso

#

Anyways time to go sleep before i get cooked

neat hound
#

when you are a woman being called one... it FEELS like it

scarlet sable
neat hound
#

I know.. I know.. I got a son and even he says it sometimes ( when I bug him too much)

scarlet sable
#

I'll be careful next time

neat hound
#

It is not that serious

distant tulip
neat hound
#

LOL.... I am a bonafide smart-ass

#

but the auto-pilot thing is key.... to function in the real world, using filters is important

#

call your lady boss that.. and see what happens

distant tulip
#

yeah
some time it is needed
you get used to things that it just feel right

neat hound
#

you get used to that because the new generation is not slapped upside the head for mistakes like that... LOL

distant tulip
#

just not used in speaking in a community tbh
big change from facebook to discord

neat hound
#

Scripting Gods... in your opinion an arrow function good for the dimension list?

neat hound
#

I need a string array of the valid dimensions... to use whereever... so const dimeList = ... world...getAll().map( x -> x.typeId) without being exact

#

cause i did not do it in vscode yet

wary edge
#

Why not use the vanilla enums?

neat hound
#

cause it is hardcoded and if another is added and I did not do the npm and copy the file to my library...

wary edge
#

Thats...a concern sure

neat hound
#

so if a new one added, me screwed

wary edge
#

Not for a long time

neat hound
#

I know, but I do not want to update an add-on for THAT

#

I think I will make a vanillaListClass.. and just pull most that are avail in the API... so I have the code ready...

wary edge
#

Im just confused really on when you would need to use what you suggested unless ots to execute in all dimension

neat hound
#

I do not want to do that each time..... seems like I should make function that I can use over and over and in diff places.. .like a library

distant tulip
#

won't that get outdated when the new api comes out (alpha or idk)

neat hound
#

no.. si I can do if (dimes.includes(dimParm))

distant tulip
#

ok?

wary edge
#

Its like BlockTypes which take into account addons as well

distant tulip
#

oh yeah

neat hound
#

Yeah, I found that and was stokked, that I can get that list to validate blocks... even has user blocks

wary edge
neat hound
#

I need to verify the param```js
/**
*

  • @param {string} command
  • @param {string} [dimension='overworld']
  • @param {number} tickDelay

*/
export function worldRun (command, dimension = 'overworld', tickDelay = 0) {
if (command && DimensionType[ dimension ])
if (tickDelay < 1)
system.run(() => {
world.getDimension(dimension).runCommand(command);
});
else if (tickDelay >= 1)
system.runTimeout(() => {
world.getDimension(dimension).runCommand(command);
}, tickDelay);
}```without using hard-coded data

#

but I've been a programmer toooooo long to just keep writing the same code over and over, so I am building my own libraries

wary edge
#

If undefined...return

sharp elbow
#

if undefined, throw!

neat hound
#

yeah, I figure I used it wrong up there.. and I did not get an error

neat hound
simple zodiac
neat hound
#

not in a game.. just get nothing, programmer should be testinging

wary edge
#

Yeah im not really seeing an issue here nikki

sharp elbow
#

But actually, throwing an error means you leave it up to the end user to decide what to do if the dimension does not exist. Which is better than it silently failing, if they were waiting on it do something

#

And when (if) we get data-driven dimensions, it makes this more useful

buoyant canopy
#

throw is the most useless keyword for general scripting, why would you generate an error if you aren't making a library or a class?

simple zodiac
#

the question is