I'm new to mcfunctions and have already done some simple ones.
but this one has got me:
I want the function to summon an armor stand with certain name bellow me, then tp me forward and then place another, and then tp.
But it's tp-ing me to the end but all the armor stands get placed only under the block where i executed the function
This is the function:
summon armor_stand ~ ~-1 ~ {Invisible:1b,NoBasePlate:1b,Small:1b,CustomName:"{\"text\":\"x30\"}"}
execute at ElTodoFull run tp @p ~1 ~ ~
...
(it's copied 61 times with a different name for the armor stand)
...
I generated the function with python, but since it's executing the tp and the summoning correctly, it's not a python problem, but it seems like it doesn't execute them in order.
Python code:
for i in range(30,-31,-1):
| print(r"summon armor_stand ~ ~-1 ~ {Invisible:1b,NoBasePlate:1b,Small:1b,CustomName:%s%s%s}"%(com,a,com))
| print("execute at ElTodoFull run tp @p ~1 ~ ~")
How can i make the function so it executes them in order? It's too many different names to do it by hand, command by command.
Edit I still want to know why the commands are not executed in order, but I "found" a workaround by hardcoding the coordinates where they are spawned
When you run a function, all the commands in it will be executed from where and by who the function was executed.
For example, if you run a function using /execute as @p positioned 0 4 0 run function [function], then all the commands will be executed as @p, at coords 0 4 0.
Your function can be seen like this :
[executed at initial position] : summon armor_stand ~ ~-1 ~ {}
[executed at initial position] : execute at ElTodoFull run tp @p ~1 ~ ~
etc.
And so, here's what happen :
-tp command :
The "at" is specified each time the command is ran, which means even if player had moved since the beginning of the function, the tp will be ran from the actual player's position
-summon command :
Here, you didn't specified "at", which means every time you run the command, it always get executed from the initial position.
So the solution is to add "execute at @p" before your armor stand command.
------
Maybe you could take a bit of time to become familiar with functions mechanics, but if you're ready for the next step, there's a way to make a "for" loop using functions.
Here's a bit how it would look :
one-time
create dummy objective ("Times" for this example)
set Times to zero for a dummy player ("$Times" for this example)
FOR loop function
-Increase $Times' Time score by 1
-Summon new armor stand under player
-Copy $Times' Time score into [new armor stand]'s Time score
-Teleport player 1 block forward
-If $Times' Times score < 61 then run function again
-Set $Times' Time score to 0 (reset)
This can all be done using commands, and the result will be a line of armor stands having a score from 1 to 60, in order.
Using scores will also avoid harcoding each different entity. If you are not happy with scores, you can even store the values into armor stand's data
I got into chiptune music composition.
You can listen to them on my Youtube channel : https://www.youtube.com/channel/UCjWYbJGk7nvNDbnCvMlZGkw
Descriptions are in french, you'd just need some google translation copy-paste...
Also made some more or less complicated datapacks, shared here (planetminecraft).
ould take a bit of time to become familiar with functions mechanics, but if you're ready for the next step, there's a way to make a "for" loop using functions.
Here's a bit how it would look :one-time FOR loop function-Increase $Times' Time score by 1-Summon new armor stand under player-Copy $Times' Time score into [new armor stand]'s Time score-Teleport player 1 block forward-If $Times' Times score < 61 then run function again-Set $Times' Time score to 0 (reset)
This can all be done using commands, and the result will be a line of armor stands having a score from 1 to 60, in order.
Using scores will also avoid harcoding each different entity. If you are not happy with scores, you can even store the values into armor stand's data
Now that's awesome! But some things require names. Actually, probably not, but since one of the functions has 1800 commands that will be executed in a single, probably longer, tick, I think running them with set names will be easier on the TPS
Rollback Post to RevisionRollBack
Psst!, If I have grammar or spelling errors, correct me. You will help improve my English.
Actually, probably not, but since one of the functions has 1800 commands that will be executed in a single, probably longer, tick, I think running them with set names will be easier on the TPS
......................
"I'm a beginner but I am already on a 1800-commands function"
I got into chiptune music composition.
You can listen to them on my Youtube channel : https://www.youtube.com/channel/UCjWYbJGk7nvNDbnCvMlZGkw
Descriptions are in french, you'd just need some google translation copy-paste...
Also made some more or less complicated datapacks, shared here (planetminecraft).
I'm new to mcfunctions and have already done some simple ones.
but this one has got me:
I want the function to summon an armor stand with certain name bellow me, then tp me forward and then place another, and then tp.
But it's tp-ing me to the end but all the armor stands get placed only under the block where i executed the function
This is the function:
summon armor_stand ~ ~-1 ~ {Invisible:1b,NoBasePlate:1b,Small:1b,CustomName:"{\"text\":\"x30\"}"}
execute at ElTodoFull run tp @p ~1 ~ ~
...
(it's copied 61 times with a different name for the armor stand)
...
I generated the function with python, but since it's executing the tp and the summoning correctly, it's not a python problem, but it seems like it doesn't execute them in order.
Python code:
| print(r"summon armor_stand ~ ~-1 ~ {Invisible:1b,NoBasePlate:1b,Small:1b,CustomName:%s%s%s}"%(com,a,com))
| print("execute at ElTodoFull run tp @p ~1 ~ ~")
How can i make the function so it executes them in order? It's too many different names to do it by hand, command by command.
Edit I still want to know why the commands are not executed in order, but I "found" a workaround by hardcoding the coordinates where they are spawned
Psst!, If I have grammar or spelling errors, correct me. You will help improve my English.
When you run a function, all the commands in it will be executed from where and by who the function was executed.
For example, if you run a function using /execute as @p positioned 0 4 0 run function [function], then all the commands will be executed as @p, at coords 0 4 0.
Your function can be seen like this :
And so, here's what happen :
-tp command :
-summon command :
So the solution is to add "execute at @p" before your armor stand command.
------
Maybe you could take a bit of time to become familiar with functions mechanics, but if you're ready for the next step, there's a way to make a "for" loop using functions.
Here's a bit how it would look :
one-time
FOR loop function
-Increase $Times' Time score by 1
-Summon new armor stand under player
-Copy $Times' Time score into [new armor stand]'s Time score
-Teleport player 1 block forward
-If $Times' Times score < 61 then run function again
-Set $Times' Time score to 0 (reset)
This can all be done using commands, and the result will be a line of armor stands having a score from 1 to 60, in order.
Using scores will also avoid harcoding each different entity. If you are not happy with scores, you can even store the values into armor stand's data
I got into chiptune music composition.
You can listen to them on my Youtube channel :
https://www.youtube.com/channel/UCjWYbJGk7nvNDbnCvMlZGkw
Descriptions are in french, you'd just need some google translation copy-paste...
Also made some more or less complicated datapacks, shared here (planetminecraft).
Now that's awesome! But some things require names. Actually, probably not, but since one of the functions has 1800 commands that will be executed in a single, probably longer, tick, I think running them with set names will be easier on the TPS
Psst!, If I have grammar or spelling errors, correct me. You will help improve my English.
Well for targetting purposes, names can always be remplaced by numerical values, but of course, it entirely depends on what you need.
......................
"I'm a beginner but I am already on a 1800-commands function"
Am I even talking to the same person?
I got into chiptune music composition.
You can listen to them on my Youtube channel :
https://www.youtube.com/channel/UCjWYbJGk7nvNDbnCvMlZGkw
Descriptions are in french, you'd just need some google translation copy-paste...
Also made some more or less complicated datapacks, shared here (planetminecraft).