#Help! my function isnt running when it is supposed to

1 messages · Page 1 of 1 (latest)

eager parcel
#

Basically, this is being run every tick:

scoreboard players add @a[tag=travelling,tag=teleported] grounded_for 1
execute as @a[tag=travelling,tag=teleported] if score @s grounded_for >= .const groundedconst run function testing:priv/teleport/landed```

this checks for how long the player has been grounded for. once this score reached above "groundedconst"  which is an arbitrary value, it is meant to run the function "landed" 

title @a title "GROUNDED"
$title @a[tag=travelling,tag=teleported] title ["",{"text":"$(title)","color":"dark_red"}]

scoreboard players set @a[tag=travelling,tag=teleported] grounded_for 0
tag @a[tag=travelling,tag=teleported] remove teleported
tag @a[tag=travelling] remove travelling```

which looks like this. however, the function landed is never run, why is this?

odd auroraBOT
#

<@&1201956957406109788>

Someone will come and help soon!

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

🙇 If nobody has answered you by <t:1738388979:t>, feel free to use the Summon Helpers button to ping our helper team.

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

vestal storm
#

Can you use code blocks please? ``` before and after

eager parcel
#

the score increases but it doesn't actually run the function

vestal storm
#

I'm not super experienced with macros, but I'm assuming it's not running because you have a macro line, but aren't running the function with any additional data for the macro to use

eager parcel
#

the macro is inherited from a previous function where I set that data

vestal storm
#

I don't think that's how macros work

#

But you can check the logs when you load the data pack and see if you get any errors

eager parcel
#

well I set my macro values in one function and use their values in multiple other functions and it's fine

jovial tigerBOT
#
Logs

When making or debugging Minecraft datapacks, it is useful to have the Minecraft logs open in order to view errors quickly.

To open the logs:

  1. Enable the logs in the Minecraft Launcher (see image)
  2. Start Minecraft

The logs should open in a separate window. Datapack errors are shown in the when you /reload and are almost always in red text or yellow text.

eager parcel
#

ok so it was the macro line

#

but why, I have another function in the same folder that says this:

$tellraw @p[tag=this] {"text":"[$(title)]\n$(description)"}

and uses the title macro seperate from where it's value was set

queen agate
#

the macro function always needs to be called either as function ... with ... or as function ... {foo:bar} in order to have its value keys set. so how are you calling the function in that case?

eager parcel
#

the values are set here:

$summon interaction ~ ~ ~ {Tags:["travel"],Passengers:[{id:marker,data:{x:$(x),y:$(y),z:$(z),time:$(time),title:"$(title)",description:"$(description)",display:$(display),custom_model_data:$(custom_model_data)}}]}
$summon minecraft:item_display ~ ~.75 ~ {item:{id:"minecraft:$(display)",count:1,components:{"minecraft:custom_model_data":{strings:['$(custom_model_data)']}}},Tags:["travel_display"]}

this is all that is in this function

#
execute as @a[tag=travelling] at @s if predicate testing:looking_at run return run function testing:priv/look/who_look

# Reset timer if player is not looking
scoreboard players reset @a tp_timer
execute positioned as @e[tag=travel,limit=1] run effect clear @p[tag=travelling] minecraft:slowness
execute positioned as @e[tag=travel,limit=1] run effect clear @e[type=item_display,tag=travel_display] glowing
tellraw @p[tag=travelling] {"text":"    \n    \n    \n    \n    \n    \n    \n    \n    \n    "}
execute as @a[tag=travelling,tag=teleported] at @s if predicate testing:is_falling run effect give @s resistance 3 255 true
execute as @a[tag=travelling,tag=teleported] at @s if predicate testing:is_grounded if score @s grounded_for < .const groundedconst2 run function testing:priv/teleport/landed_detection

this function runs constantly

#

if im looking at the entity, then it calls the

$tellraw @p[tag=this] {"text":"[$(title)]\n$(description)"}
#

so it's not like the setter function calls the tellraw command

#

OH

#

you said use "with:

#

i didnt do that, my bad

#

well it still wont run that line

#

im not sure

#

in the case here:

execute unless score @p[tag=this] tp_timer matches 1.. on passengers \
    run function testing:priv/teleport/description_macro with entity @s data
``` @s refers to the interact entity carrying the data
eager parcel
#
scoreboard players add @a[tag=travelling,tag=teleported] grounded_for 1
execute if score @a[tag=travelling,tag=teleported,limit=1,sort=arbitrary] grounded_for >= .const groundedconst on passengers \
    run function testing:priv/teleport/landed with entity @e[type=interaction,tag=filter,limit=1,sort=arbitrary] data

I attempted to retrieve the data from the entity

#

and there is still an issue

queen agate
#

well that one won't work because interaction entities don't have a data field. the entity with your data is a marker

eager parcel
#

oh right, i see

eager parcel
#

execute positioned as the interaction object the player is looking at with the data from the closest market which should be the marker with the correct data

#

it doesn't work still however

queen agate
#

i'd recommend trying that function command directly in chat to see if it returns any errors

eager parcel
#

im using a modrinth profile and cant seem to find how to enable logs for datapacks

queen agate
#

when you click on your instancce profile there should be a pair of tabs right at the top

eager parcel
#

then there are no errors

queen agate
#

my recommendation would just send an error in chat, however.

eager parcel
#

I was looking at those logs

queen agate
#

if you run just /function testing:priv/teleport/landed with entity @e[type=marker,limit=1,sort=nearest] data from chat what happens (getting close to the marker, obviously)

eager parcel
#

let me try

#

I get nothing

#

if I run data get, the market has the data there

#

$title @a[tag=travelling,tag=teleported] title ["",{"text":"$(title)","color":"dark_red"}]
am I just calling the title command wrong?

#

I cant be because when I run it seperately it is fine

queen agate
#

the title command itself should be fine. i'd say verify the tags in the selector but i can't see how that could be the issue either.

eager parcel
#

the marker has the required data when i check

#

so that shouldnt be a concern

#

I think it is an issue with the title command because I replaced it with tellraw and it works fine

#

ok i just uncommented the original title command, ZERO CHANGES

#

and suddenly it is working

queen agate
#

well, you'll have that sometimes. but if it's working now then that's the important part

eager parcel
#

thanks foir your helkp, sorry that was difficult, so confused haha