#I would like to know or see what it would look like

50 messages · Page 1 of 1 (latest)

rugged lance
#

I need a script so that after a kill, a command is assigned to the player. Is it possible to do this?

stark snowBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

small stream
#

What do you mean

#

And why do you need this

sharp zodiacBOT
#

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.

gloomy bison
#

are you trying to say you want the player to run a command when they die?

rugged lance
rugged lance
#

then get the skill with the help of the command: /tensura edit @s ability grant random skill unique

small stream
#

There's probably an api you can use instead of calling a command

rugged lance
small stream
#

yes

rugged lance
#

at mercy, how?

small stream
#

you can do server.runCommandSilent

rugged lance
#

and how to make it activate after killing 🤔

small stream
#

you could use entity js

sharp zodiacBOT
#

EntityJS is an addon that allows you to create custom entities with KubeJS.

small stream
#

you could make something run in the onDeath method

rugged lance
#

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')
})
})
})

sharp zodiacBOT
#

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)
})
small stream
#

please use indents properly

#

it's so hard to read without proper indentation

rugged lance
small stream
#

??

rugged lance
#

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 =>
})
})
})

sharp zodiacBOT
rugged lance
sharp zodiacBOT
rugged lance
#

what is this mistake?
Unterminated string literal

rugged lance
#

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')
})
})

small stream
#

You forgot the comma before event

#

And you shouldn't really use event twice

vital gull
rugged lance
vital gull
#

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

vital gull
#

also what awesome meant by putting your code in the colorful code block

#

using the `

rugged lance
vital gull
#

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

sharp zodiacBOT
#

🗒️ 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.