TransWikia.com

How do I execute multiple function within another function?

Arqade Asked by Milche Patern on July 11, 2021

In Minecraft 1.13.2 Java

Previous title of this question was : What is console command to fly in creative mode? supposing an issue with ‘flying’.

I want to execute multiple functions (from function files).

To be executed is a series of circle ploting in order to create a circular tower.

The code for the circle:05 function file is working as expected ingame. It clones the block from underneath the executer to plot a circle around @s then teleport @s 1 block over.

circle:05

clone ~ ~-1 ~ ~ ~-1 ~ ~-5 ~ ~0
clone ~ ~-1 ~ ~ ~-1 ~ ~-4 ~ ~-3
clone ~ ~-1 ~ ~ ~-1 ~ ~-4 ~ ~-2
clone ~ ~-1 ~ ~ ~-1 ~ ~-4 ~ ~-1
clone ~ ~-1 ~ ~ ~-1 ~ ~-4 ~ ~1
clone ~ ~-1 ~ ~ ~-1 ~ ~-4 ~ ~2
clone ~ ~-1 ~ ~ ~-1 ~ ~-4 ~ ~3
clone ~ ~-1 ~ ~ ~-1 ~ ~-3 ~ ~-4
clone ~ ~-1 ~ ~ ~-1 ~ ~-3 ~ ~-3
clone ~ ~-1 ~ ~ ~-1 ~ ~-3 ~ ~3
clone ~ ~-1 ~ ~ ~-1 ~ ~-3 ~ ~4
clone ~ ~-1 ~ ~ ~-1 ~ ~-2 ~ ~-4
clone ~ ~-1 ~ ~ ~-1 ~ ~-2 ~ ~4
clone ~ ~-1 ~ ~ ~-1 ~ ~-1 ~ ~-4
clone ~ ~-1 ~ ~ ~-1 ~ ~-1 ~ ~4
clone ~ ~-1 ~ ~ ~-1 ~ ~0 ~ ~-5
clone ~ ~-1 ~ ~ ~-1 ~ ~0 ~ ~5
clone ~ ~-1 ~ ~ ~-1 ~ ~1 ~ ~-4
clone ~ ~-1 ~ ~ ~-1 ~ ~1 ~ ~4
clone ~ ~-1 ~ ~ ~-1 ~ ~2 ~ ~-4
clone ~ ~-1 ~ ~ ~-1 ~ ~2 ~ ~4
clone ~ ~-1 ~ ~ ~-1 ~ ~3 ~ ~-4
clone ~ ~-1 ~ ~ ~-1 ~ ~3 ~ ~-3
clone ~ ~-1 ~ ~ ~-1 ~ ~3 ~ ~3
clone ~ ~-1 ~ ~ ~-1 ~ ~3 ~ ~4
clone ~ ~-1 ~ ~ ~-1 ~ ~4 ~ ~-3
clone ~ ~-1 ~ ~ ~-1 ~ ~4 ~ ~-2
clone ~ ~-1 ~ ~ ~-1 ~ ~4 ~ ~-1
clone ~ ~-1 ~ ~ ~-1 ~ ~4 ~ ~1
clone ~ ~-1 ~ ~ ~-1 ~ ~4 ~ ~2
clone ~ ~-1 ~ ~ ~-1 ~ ~4 ~ ~3
clone ~ ~-1 ~ ~ ~-1 ~ ~5 ~ ~0
clone ~ ~-1 ~ ~ ~-1 ~ ~ ~ ~
tp ~ ~1 ~

My problem is to execute multiple times this function (circles:05)

I tried with basic code line writing function circles:05, then execute as @s ~ ~ ~ run function circles:05 but nothing works.

maketower

execute as @s run function circles:05
execute as @s run function circles:05
execute as @s run function circles:05
execute as @s run function circles:05

Both files are in the correct folder, available within the ingame command-line but the result is not working because @s seems to falls down on previous block after /tp.

Any clue on how to make this work / the console command to fly?

ps. Can someone with 300 reputation create tags 1.13, ability for me?

2 Answers

I don't have a clue on why this isn't working. It should, and I've tried all the tricks I know. My suggestion? Get rid of that function and copy the entire set of commands four times, but with one addition - use

execute as @a[tag=tower] at @s run clone <x> <y> <z>

When you just want that circle, use the function. If you want the tower, tag yourself with "tower" and run the same function.

Sorry, that's all I got. This could be a bug or a removed feature to use the function command within other functions (which I doubt). I'll tell you if I find the real answer later.

Answered by SpiceWeasel on July 11, 2021

I may be late, but you can't expect the player to teleport as soon as you execute the tp command. Minecraft runs on a tick system, where everything is done inside of a single game-tick (1/20 seconds).

The player's position is only updated at the end of every game-tick, so executing the tp command only queues the teleport until all the next commands are done. You can see this by writing some say blocks in the function, since this proves that circles:05 is indeed being executed 5 times, but the player's location is only being updated once every command for that game tick is done.

That's all well and good but how could you fix this? We need create a for loop using a function with the tick tag (more info here). This tag will cause a command to be executed in quick succession. Next we need to create a scoreboard that will work as our increment variable, call it circles_i for example.

Now edit circles:05 so that before every clone command, there's an execute if score @s circles_i matches 0..5 run. For example:

execute if score @s circles_i matches 0..5 run clone ~ ~-1 ~ ~ ~-1 ~ ~-5 ~ ~0

Finally, at the end of the function, add a new command:

scoreboard players remove @s circles_i 1

to decrement the scoreboard

Now, in the maketower function, set the score for circles_i to be 5 (or however tall you want it to be):

scoreboard players set @s circles_i 5

This should execute the circles:05 function 5 times, once each game tick, elapsing a quarter of a second total. Unfortunately this is the fastest way to do this with predictable results

Answered by Ben on July 11, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP