#This little script of mine doesn't work at all... πŸ˜”Does anyone out there know how to fix it?

1 messages Β· Page 1 of 1 (latest)

tulip cradle
#
import { system, world } from '@minecraft/server'
import * as lib from '../template'

system.runInterval(() => {
  for (const player of world.getPlayers()) {
    current(player)
  }
}, 5)  

export function current(player) {
  player.getComponent("minecraft:health").current > lib.scoreboard.get(player, `hp`) && lib.scoreboard.get(player, `hp`) > 0 ? player.getComponent("minecraft:health").setCurrent(lib.scoreboard.get(player, `hp`)): null
  
} 
tulip cradle
#

This system identified any type of damage

autumn mesa
#

do u have typings installed?

tulip cradle
autumn mesa
tulip cradle
#

What is that for?

autumn mesa
tulip cradle
tulip cradle
#

I'll check if that's the problem

tulip cradle
#

Nothing makes this system work

#

Does not make sense

#

it worked before

#

@autumn mesa

autumn mesa
#

hb this

function current(player) {
    player.getComponent("minecraft:health").currentValue > lib.scoreboard.get(player, `hp`) && lib.scoreboard.get(player, `hp`) > 0 ? player.getComponent("minecraft:health").setCurrentValue(lib.scoreboard.get(player, `hp`)) : null
} 
tulip cradle
autumn mesa
#

;-;

tulip cradle
#

It's like the command doesn't exist

autumn mesa
#

whats in ur lib

tulip cradle
#

I've been trying to fix it since yesterday, but nothing seems to make sense.

tulip cradle
#

I know this because I have other systems that use lib.score

tulip cradle
#

Calm

tulip cradle
autumn mesa
#

try putting a console.warn(243) in that file

#

then /reload

tulip cradle
#

But I'll see what happens

autumn mesa
#

the its using a different pack...

tulip cradle
#

It's the same pack

autumn mesa
#

how come that consolewarn not work then

#

even spamming the world.sendMessage...

tulip cradle
#

Calm

#

I put a runInterval in the file

#

Maybe it wasn't showing up before because the runinterval was in another file

#

Give me one second

#

@autumn mesa

#
function current(player) {
  console.warn(player.getComponent("minecraft:health").currentValue > lib.scoreboard.get(player, `hp`) && lib.scoreboard.get(player, `hp`) > 0 ? player.getComponent("minecraft:health").setCurrentValue(lib.scoreboard.get(player, `hp`)) : null)
} 
autumn mesa
#

ok

#

now split them into variables

#

before doing setCurrent

#

console.warn those variables

tulip cradle
#

πŸ˜…

autumn mesa
#
function current(player) {
    const health = player.getComponent("minecraft:health").currentValue
    const hp = lib.scoreboard.get(player, `hp`)
    console.warn(health, hp);
} 
autumn mesa
#

we doin that first

#

what does it show

tulip cradle
#

I will put

#

Eeeeh

tulip cradle
autumn mesa
#

is ur score 0?

tulip cradle
#

Yea

#

Hp is set to 0

autumn mesa
#

does it work when u set it to 1+

tulip cradle
tulip cradle
tulip cradle
#

@autumn mesa

autumn mesa
#

do u want that hp 0 to kill the player?

tulip cradle
#

Current health cannot be greater than the "hp" score or less than 0...

#

This system used to work perfectly but suddenly it stopped working and I can't understand the reason 😭😭😭😭

autumn mesa
#

now try this

#
function current(player) {
    const health = player.getComponent("minecraft:health")
    const hp = lib.scoreboard.get(player, `hp`);
    health.currentValue > hp && hp >= 0 && health.setCurrentValue(hp);
} 
tulip cradle
#

It looks like it worked

#

I will test some more

autumn mesa
#

it was the hp >= 0

#

needed the =

tulip cradle
#

ZEA HAHAHAHA

#

ZEA HAHAHAHAHA

tulip cradle
#

You don't know how happy I am

#

😭😭😭😭😭

autumn mesa
tulip cradle
#

I became your fan

#

Thank you for real

autumn mesa
#

thx

#

now when things dont work, split those into variables, and console.warn them

tulip cradle
tulip cradle
#

There's nothing inside it

#

Ooooh, I understand

#

Did you turn it into a code without the "?:"

autumn mesa
#

u can also do ```js
console.warn(health.currentValue > hp && hp >= 0)

autumn mesa
#
true && console.log('logged1')
false && console.log('logged2')