#How could I make this code more efficient?

18 messages · Page 1 of 1 (latest)

coarse flame
#

I've made a script to change the ore processing recipes in my pack, but I feel like I've written too much code, as this took a lot of copy and pasting with switching minor details. Script attached in next message.

torn forumBOT
#

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

coarse flame
small pewterBOT
#

Paste version of message.txt from @coarse flame

plain reef
#

for loops

coarse flame
#

how to do that 🤔

#

wait lemme read the documentation on this one...

#

Huh, so loops in this are kinda similar to functions in Python? I'm learning that rn and this kinda reminds me of that

plain reef
#

A for loop is a programming construct that executes a block of code repeatedly until a condition is met. They are used to iterate over a sequence, such as a list, array, or collection, and perform a certain action a set number of times.

coarse flame
#

ty for pointing me in the right direction

coarse flame
#

hm, this doesn't seem to be working

ServerEvents.recipes(event => {
    let oreCrushing = (output, crushedInput) => {
        event.recipes.create.crushing([Item.of('create:experience_nugget').withChance(0.75), Item.of(output * 3)], crushedInput)
    }

    oreCrushing('create:crushed_raw_copper', '#forge:ores/copper')
})```
#

it seems like it doesn't like it when I try to make multiple outputs in the helper function

plain reef
#

you're trying to multiply a string by tree, not setting the output to tree

#

It should be something like this iirc

Item.of(output, 3)
coarse flame
#

OHH okay ty, I'll try that when I get back

#

that makes sense

coarse flame
#

figured this out, tysm !

small pewterBOT
#

Please close your ticket (with </ticket close:1054771505520717835> or the button atop this thread) once you resolved your issue! This also helps others that would like to help out, as they don't have to look into this thread to check if it has been resolved by now.

Do you have any other questions regarding your issue? Feel free to ask!
Note: You should generally create a new post for unrelated issues.