#running a command in random cords

1 messages · Page 1 of 1 (latest)

gusty narwhal
#

im creating something for me and my friends to play in and we are trying to make it spawn 1 random block somewhere in the world the command i was gonna use was
execute as @s run setblock $(random_x_recipe) $(random_y_recipe) $(random_z_recipe) Crafting_table
or something like that any potential ways to do so?

fiery rootBOT
#

<@&1201956957406109788>

Someone will come and help soon!

💬 While you wait, take this time to provide more context and details.

✅ Once your question has been resolved (or you no longer need it), please click Resolve Question or run /resolve

#
⚠️ You already have a question open!

Don't forget to close or resolve your old questions once you're done with them. It makes our lives much easier! :D

Open question: #1274022322394890310

tiny skiff
#

Is that not working?

gusty narwhal
#

no

tiny skiff
#

Do you have it marked as a macro line in the function?

gusty narwhal
#

?

tiny skiff
#

Yeah, don't think you're using macros correctly

#

I'm not super well versed in them so may need to wait for a helper who is, but I do know enough to recognize this isn't correct

gusty narwhal
#

thank you

civic canyon
#

You need to put them all on a storage, then have the macro line in its own function, run the function with the storage, and also prefix the macro line with $

gusty narwhal
#

what do you mean?

#

may i have an example?

fiery rootBOT
# fiery root <@&1201956957406109788>

<@&1166082198152159386> <@&1202694677766348840>

🙇 Helpers Arise!

Please note that you still might not immediately get a response since all helpers are human beings and volunteers (and also might be sleeping right now)

shadow thunder
#

this defines a macro line and accepts macro variables

#

you need to run that command in a seperate function with storage

#

which means you need to store inside storage, not score

gusty narwhal
#

may i have an example?

#

please

hollow silo
#

instead of store result @s x run ...
use store result storage infinitygames:temp Macro.x run ...
and then run a separate function with your macro command with
function other_function with storage infinitygames:temp Macro

#

that I'm storing the macro compound in a tag called Macro is just an arbitrary choice btw

shadow thunder
# gusty narwhal may i have an example?

-# init.mcfunction

execute store result storage foo:bar value int 1 run random value 1..100
function foo:say with storage foo:bar

-# say.mcfunction

$say $(value)
gusty narwhal
#

i know how to read

gusty narwhal
shadow thunder
#

youre not supposed to copy

gusty narwhal
#

ik

gleaming solstice
#

you can’t set blocks out of render distance though, i should warn

gusty narwhal
#

ik

#

i found a fix

shadow thunder
#

you can forceload and unload again

gleaming solstice
#

cool

#

yeah there are ways around it i just wanted to make sure you were aware of that

gusty narwhal
#

i still cant seem to make it work is there any other way of inserting a value?

shadow thunder
#

macros are your only option

#

can you send your functions

gusty narwhal
#

sure

gusty narwhal
gleaming solstice
shadow thunder
#

my spelling is not on point todsy

gleaming solstice
#

lol

#

screenshot

shadow thunder
#

a screenshot of both functions

gleaming solstice
#

i can also help w macros if necessary

gusty narwhal
#

then how do i run it?

shadow thunder
#

the 4th line has to be ran inside a seperate function

gleaming solstice
#

uhh not necessarily

shadow thunder
gleaming solstice
#

if its already inside of a function run from elsewhere

#

u could just run that function with storage

shadow thunder
#
  • values change again
gusty narwhal
#

what if insted i will just /spreadplayers an interaction entity then spawn a block under it?

gleaming solstice
gleaming solstice
shadow thunder
gusty narwhal
#

tho wich one would be more tps efficient?

shadow thunder
#

unless you make unecessary scoreboard/storage checks

shadow thunder
# gusty narwhal

lets go over some basics:

  1. macro variables can only contain valurs from storage/entities/blocks
  2. your macro variable $(...) needs to have the same.name as your value inside storage ( a: "hello" = $(a) )
  3. macro lines are lines that start with $, thus allows macro variables
  4. macro variables are only defined through storage/entities/blocks, a function can be ran with one of these to define your macro variables ( /function foo:bar with storage ... )
#

save your randomized values into a storage instead of a score instead

#

execute store result score ... -> execute store result storage ...

gusty narwhal
#

alr ty

#

i got it to work