#recipe that gives random item?
21 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
This is possible, but it won't Show all output items but just one instead.
It can be done with modifyResult
event.shaped(...).modifyResult((grid, result) => {
return random
})
Where random is an Itemstack
You Just need to use Math.random and selct a random element in an array
awesome, tysm <3
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.
Ticket re-opened!
I keep getting this error
this is the script im using
//priority: 2
const dust =['Item.of("primalmagick:essence_dust_earth")','Item.of("primalmagick:essence_dust_sky")','Item.of("primalmagick:essence_dust_sea")','Item.of("primalmagick:essence_dust_moon")','Item.of("primalmagick:essence_dust_sun")', 'Item.of("primalmagick:essence_dust_blood")'];
const item = dust[Math.floor(Math.random() * 6)];
ServerEvents.recipes(e => {
//blood scroll -> essence
e.recipes.shapeless(Item.of('primalmagick:essence_dust_earth'), 'primalmagick:blood_notes'
).modifyResult((grid, result => { return item;}))
})```
wait why do i have an extra .recipes...
ok removing the extra .recipes didnt change anything lol
Your brackets are wrong
Give me a min, I'm not at the pc
const dust = [Item.of("primalmagick:essence_dust_earth"), Item.of("primalmagick:essence_dust_sky"), Item.of("primalmagick:essence_dust_sea"), Item.of("primalmagick:essence_dust_moon"), Item.of("primalmagick:essence_dust_sun"), Item.of("primalmagick:essence_dust_blood")]
const item = dust[Math.floor(Math.random() * 6)]
ServerEvents.recipes(e => {
//blood scroll -> essence
e.recipes.shapeless('primalmagick:essence_dust_earth', 'primalmagick:blood_notes')
.modifyResult((grid, result) => item)
})
Ticket re-opened!
So I got the script to work how i wanted it to by removing the item variable and making it read the array directly each craft, and after reloading the script it works flawlessly the first time, but after closing the crafting table trying to reuse the recipe will result in no output half the time. I don't think it's giving a missing output, because the Math.calc should only give 0-6 which is the right indicators for the array, is there anything y'all can think of that I could look into to try and resolve it?
The current script is here :) ```js
const dust = [Item.of("primalmagick:essence_dust_earth"), Item.of("primalmagick:essence_dust_sky"), Item.of("primalmagick:essence_dust_sea"), Item.of("primalmagick:essence_dust_moon"), Item.of("primalmagick:essence_dust_sun"), Item.of("primalmagick:essence_dust_blood")]
let item = dust[Math.floor(Math.random() * 6)]
ServerEvents.recipes(e => {
//blood scroll -> essence
e.recipes.shapeless('primalmagick:essence_dust_earth', 'primalmagick:blood_notes')
.modifyResult((grid, result) => dust[Math.floor(Math.random() * 6)])
})```