#Tick intervals
184 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
no that would break the game lol
youre probably overcomplicating whatever youre trying to do
I'm trying to make it so the effectTick will tick once in a couple ticks instead
you can add something like this in the body
if (Utils.server.tickCount % 5) return
and that will run everything after once every 5 ticks, as an example
everything as in EVERY thing?
well yeah, its a guard clause
it doesn't recognize "server" as a method or anything
i mean i believe you meant to put it in a different script?
whats your script?
Or did you mean in the effect
you put that in the effect tick
_> i put it inside the effect but not the tick
I thought u meant the body as in the registry event
no---
well according to probeJS it still doesn't recognize it
but i will try >_>
Wait so you just wing it?
You dont use probe at all?
dam
built different
no ive never used probe 
let me check, a lot of things changed in 1.21
huh... getServer was removed from utils

i wonder why
show me your code
well i manged to do it >_>
I knew it was a thing i just didn't know how to apply it
what thing 
i think your effect tick callback has the entity
if (entity.hasEffect("betterasfour:nature_gigante")) return;
if (entity.tickCount % 20) return
entity.attack("minecraft:arrow", 0.001)
}
)```
O i see
thats exactly what i wanted
What u mean
xD
Ye finally ;-;

close it, people can use the search to find it :P
How do you personally go around checking for that stuff?
If u dont have files compiled specifically for that info by probe?
uh
i either know how most of them work, or use the source code and my website
which is also good for when you want something but dont know how to get there, you search what you want and work your way backwards
which is what i did in this case when i saw Utils didnt get the server anymore
oh thats your website >_>
well ty for doing that either
Btw if i already have your attention do you know how to get rid of these log messages ```! cantinscript.js#140: Error in 'EntityEvents.beforeHurt': dev.latvian.mods.rhino.EcmaError: TypeError: Cannot read property "stages" from null
[17:14:45] [ERROR] ! cantinscript.js#181: Error in 'EntityEvents.beforeHurt': dev.latvian.mods.rhino.EcmaError: TypeError: Cannot read property "stages" from null
The value is supposed to return null because it doesn't exist but why does it have to spam my logs >_>

const { source : { player } } = event;
if ((player.stages.has("gauntlets1")) && event.getSource().getWeaponItem().hasTag("c:tools/gauntlets"))
{
player.runCommandSilent("/puffish_skills category unlock @s puffish_skills:gauntlets")
player.stages.add("gauntlets")
} else return```
this is a snippet of the script
you should add a js after the 3 ` to get syntax highlighting
makes it easier to read the code
o
lemme do it
[17:14:45] [ERROR] ! cantinscript.js#181: Error in 'EntityEvents.beforeHurt': dev.latvian.mods.rhino.EcmaError: TypeError: Cannot read property "stages" from null```js
i did it wrong
You can write your code in a codeblock by typing it between the codeblock delimiters:
Note that these are backticks, not apostrophes
```js :arrow_left:
ServerEvents.recipes(event => {
event.smelting('minecraft:glass', '#forge:sand').xp(.1)
})
``` :arrow_left:
This example will look like this:
ServerEvents.recipes(event => {
event.smelting('minecraft:glass', '#forge:sand').xp(.1)
})
[17:14:45] [ERROR] ! cantinscript.js#181: Error in 'EntityEvents.beforeHurt': dev.latvian.mods.rhino.EcmaError: TypeError: Cannot read property "stages" from null```
huh
const { source : { player } } = event;
if ((player.stages.has("gauntlets1")) && event.getSource().getWeaponItem().hasTag("c:tools/gauntlets"))
{
player.runCommandSilent("/puffish_skills category unlock @s puffish_skills:gauntlets")
player.stages.add("gauntlets")
} else return```
EntityEvents.beforeHurt(event => {
const { source : { player } } = event
if (player.stages?.has("gauntlets1") && event.source.weaponItem.hasTag("c:tools/gauntlets")) {
player.runCommandSilent("/puffish_skills category unlock @s puffish_skills:gauntlets")
player.stages?.add("gauntlets")
} else return
// is there more here?
try this
there is a lot more xD
o.o
o u added the ? if
since im new to this i made this code in such a whacky way xD
if i were to show you the code you'd be stunned
oh god
one tip i can give you for much better code is learn to use guard clauses everywhere
how so?
reduces the complexity and indentation of your code by exiting early
well it didn't work with the "?"
Good god if i were to show you this monstrousity after you tell me that
for instance this, would be this with guard clauses:
EntityEvents.beforeHurt(event => {
const { source : { player } } = event
if (!player.stages?.has("gauntlets1")) return
if (!event.source.weaponItem.hasTag("c:tools/gauntlets") return
player.runCommandSilent("/puffish_skills category unlock @s puffish_skills:gauntlets")
player.stages?.add("gauntlets")
or you could even add a guard clause to check the stages
EntityEvents.beforeHurt(event => {
const { source : { player } } = event
if (!player.stages) return
if (!player.stages.has("gauntlets1")) return
if (!event.source.weaponItem.hasTag("c:tools/gauntlets") return
player.runCommandSilent("/puffish_skills category unlock @s puffish_skills:gauntlets")
player.stages.add("gauntlets")
where is it in the last example?
at the top
Im sorry i just dont notice what you mean this seems like a regular script i would make >_>?

EntityEvents.beforeHurt(event => {
const { source : { player } } = event
if (!player.stages) return
o u meant
i see
My bad xD
Ye i used to do that like that
but then idk wtf was going through my head
Well if u were to see the code you will know or maybe not know what went through my head >_<
Lemme change it around according to that
but it gave me null log messages anyways when i did have the guard clauses early
What i sent you previously was after trial and error with various ways
then maybe its somewhere else 
But wait it's important to point out that for some reason it returns null when i get attacked
oh wait
And thats weird
stages from null
Ye stages
_<?
whatever is before stages is null
O
so in your example, player is null
EntityEvents.beforeHurt(event => {
const { source : { player } } = event
if (!player) return
Ok but it tell me specifically in the logs that the stages returns null is that now how it works?
that happens because its not a player doing damage to you
so the damage source doesnt have a player source
Ok so i need to make an exit for non players?
yeyeye
source.player only exists when the player deals damage
most damage sources arent from the player
How do i counter that?
Do i need to return both conditions?
Would that even do anything
I mean it's already like that
just this
Ok i feel like i should reveal the monstrousity so you can help me better
HOW do i make it into a js ;-;
const { source : { player } } = event;
if (!player) return;
if ((player.stages?.has("gauntlets1")) && event.getSource().getWeaponItem().hasTag("c:tools/gauntlets"))
{
player.runCommandSilent("/puffish_skills category unlock @s puffish_skills:gauntlets")
player.stages.add("gauntlets")
}
if (player.stages.has("spears") && event.getSource().getWeaponItem().hasTag("c:tools/gauntlets")) {
player.stages.remove("spears")
player.runCommandSilent("/puffish_skills category lock @s puffish_skills:spears")
}
if (player.stages.has("swords") && event.getSource().getWeaponItem().hasTag("c:tools/gauntlets")) {
player.stages.remove("swords")
player.runCommandSilent("/puffish_skills category lock @s puffish_skills:swords")
}
if (player.stages.has("hammers") && event.getSource().getWeaponItem().hasTag("c:tools/gauntlets")) {
player.stages.remove("hammers")
player.runCommandSilent("/puffish_skills category lock @s puffish_skills:hammers")
}
if (player.stages.has("chakrams") && event.getSource().getWeaponItem().hasTag("c:tools/gauntlets")) {
player.stages.remove("chakrams")
player.runCommandSilent("/puffish_skills category lock @s puffish_skills:chakrams")
}
if (player.stages.has("dual_blades") && event.getSource().getWeaponItem().hasTag("c:tools/gauntlets")) {
player.stages.remove("dual_blades")
player.runCommandSilent("/puffish_skills category lock @s puffish_skills:dual_blades")
}
if (player.stages.has("scythes") && event.getSource().getWeaponItem().hasTag("c:tools/gauntlets")) {
player.stages.remove("scythes")
player.runCommandSilent("/puffish_skills category lock @s puffish_skills:scythes")
}
}
)js```
look at the example in the codeblock command, you need to write exactly that nothing more nothing less
but i still dont know the exact like
i just need the one line
o ye my bad lemme show u
wait nevermind
it works maybe?
gimme like 2 mins
Ok so i had my conditions all messed up
On basically all my scripts
Almost all
Apparently i cant do
if (!event.source.player && ...) return;
it has to be alone without any additional conditions
no it can work but you need to be careful what you write
Well specifically for this event probably cant
when you invert the if statement, you need to invert the && into ||
Ye >_>
I see
also i just crashed my world by dying with my effect
to my effect*
i hope that's a fluke
lol
oh no
what you just helped me with
fixed the initial problem
but CREATED ANOTHER ;-;

Paste version of message.txt from @quartz sleet
this might be worse than before
idk what i did
o it's the "?"
Ok IM good now phw
phew
what an emotional rollercoaster lol
