#I would like to know or see what it would look like
50 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
The XY problem is when you really want to do X, and you think that Y can achieve X. However, you can't get Y to work, and so ask for help exclusively about Y.
This can lead to a lot of confusion from the people trying to help you, as Y can seem like a very random thing to want to do, and a lot of the time isn't the best way to achieve X anyway.
Its fine to ask about Y, just always include some context about X so you can be put on the right track if Y won't do X well, or there is an easier way to do X.
are you trying to say you want the player to run a command when they die?
I want to make it so that after killing a mob on the server, a command is written to change the player's parameter
after the boss died
Wdym player's parameter?
then get the skill with the help of the command: /tensura edit @s ability grant random skill unique
There's probably an api you can use instead of calling a command
I don't know, but is it possible to do it with a command somehow?
yes
at mercy, how?
you can do server.runCommandSilent
and how to make it activate after killing 🤔
you could use entity js
EntityJS is an addon that allows you to create custom entities with KubeJS.
I wrote something, but it doesn't work
EntityJSEvents.modifyEntity(event => {
event.modify("minecraft:zombie", modifyBuilder => {
modifyBuilder.onDeath(entity => {
entity.server.runCommandSilent('/tensura edit @a ability grant random skill unique')
})
})
})
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)
})
and what to do if you need ServerEvents (as in the server script), but for the full Entityjs command (noDeath)
??
when using the script that is on the site, it says that ServerEvent is needed
Error:Tried to register event handler
’EntityJSEvents.modifyEntity’ for invalid script type SERVER!
Valid script types: [STARTUP]
EntityJSEvents.modifyEntity(event => {
event.modify("minecraft:zombie", modifyBuilder => {
modifyBuilder.onRemovedFromWorld(entity =>
})
})
})
please don't ignore this
I understood what it is, but how to fix it if you use it
what is this mistake?
Unterminated string literal
gives an error: missing ; before statement
ServerEvent.recape (event => {
event.onDeath("minecraft:zombie") event => {
event.player.runCommandSilent('/tensura edit @a ability grant random skill unique')
})
})
modification event is startup script, also where did you get "ServerEvent.recape" from? you had it right the first time
I noticed it and fixed it, but I still couldn't get what I wanted.
try this instead ```js
EntityJSEvents.modifyEntity(event => {
event.modify("minecraft:zombie",modifyBuilder => {
modifyBuilder.onDeath(ctx => global.onDeath(ctx))
})
})
/**
*
- @param {Internal.ContextUtils$DeathContext} ctx
- @returns
*/
global.onDeath = ctx => {
const { entity, damageSource } = ctx
let attacker = damageSource.actual
if ((!attacker || !attacker.player)) return
entity.server.runCommandSilent(execute as ${attacker.username} run tensura edit @s ability grant random skill unique)
}
onDeath method takes a "context" which gives you the entity & damageSource, cant use entity right off the bat
i just modified it so that you can run /kubejs reload startup_scripts command to reload instead of restarting the game every time you make an edit, it will refresh anything inside the global.onDeath function for you, will make things a lot easier to live-edit
also what awesome meant by putting your code in the colorful code block
using the `
it turns out that for server.runCommandSilent to work, serve_script is needed, but for this script to work, it must start with ServerEvents?
thats not true, as long as the server is available off the entity, even if its inside a startup script it should work
if it still isnt working for you then send the code as well as startup logs again
🗒️ Send the code! 🗒️
You may have an issue with a KubeJS script and you explain it to the best of your ability yet without the actual code in question we have very little to go off of in trying to assist you.
Please send your KubeJS startup log. It can be found at /minecraft/logs/kubejs/startup.log.
If you are on 1.18 or 1.16 it will be called startup.txt.
Please send the file directly, without links or snippets.