#Pass Animation Controller Variable to Entity Variable

1 messages · Page 1 of 1 (latest)

fresh lily
#

Veka... I am trying to get a working example for this. Is either of the locations correct? And per a previous post you made, I assume I can use v.player_id in the entity filter in the BP file?

{
    "format_version": "1.10.0",
    "animation_controllers": {
        "controller.animation.new_player_query": {
            "initial_state": "default",
            "states": {
                "default": {
                    "transitions": [{"is_new": "!(q.scoreboard('player_ids')>0)"}],                    
                    "on_exit": [
                        "/scoreboard objectives add player_ids dummy",
                        "/scoreboard players add counter player_ids 0",
                        "/scoreboard players add @a player_ids 0"
                    ]
                },
                /*
                    Should only do this ONCE ever
                */
                "is_new": {                    
                    "on_entry": [
                        "/scoreboard players add counter player_ids 1",
                        "/scoreboard players operation @s player_ids = counter player_ids"
                    ],
                    //Do I do the variable here
                    "transitions": [{"default": "v.player_id = q.scoreboard('player_ids'); return v.player_id>0"}],
                    
                    "on_exit": [
                        "/titleraw @s title {\"rawtext\":[{\"text\":\"§aYour Player ID is \"},{\"score\":{\"name\":\"@s\",\"objective\":\"player_ids\"}}]}",

                    //Or here?    
                        "v.player_id = q.scoreboard('player_ids');"
                    ]
                }
            }
        }
    }
}
#

I have what you posted before... and I am just now getting back to it. I cannot find any example that actually does what you said, so I need to ask

What you need to do is to add int properties with client sync, add events to set those properties to variables (you can't use any queries besides q.property when setting a property, but can use a variable), then you'd need a way to constantly set variable to scoreboard value, which can be done in any molang field that runs every tick, like animation condition, or even in the looping always running animation itself. So every tick variables would be set to q.scoreboard, and whenever you'd trigger events to set property values, it'd save those variables in properties and they will be accessible on the client.

As I said, when setting properties you can't use any queries, except q.property and q.had_component_group, but you can use variables, so you just need to set variable to q.scoreboard every tick and set porperty to that variable

Most straightforward way to do that is via BP animation that always runs and triggers molang every tick. It can also run event for updating properties, if you need that running every tick as well
late moss
#

Ok, what are you trying to do? Set a property to a score and read it in resource pack?

fresh lily
#

behavior pack

#

I want to save it there so I can do stuff with it, since I know blocks can read an entity variable

late moss
#

So save score in entity and read it from a block?

#

Have are you going to read it, q.get_nearby_entities?

fresh lily
#

Well, 1st step, get it saved into the enity variable

#

I did a test with on_interact, it can read player variables

#

I did that part already based on what majestik posted.. #1089640424295108799 message

#

This close to being able to create a player specific lock.... without scripts

late moss
#

That controller will run on lock entity, right?

fresh lily
#

no, the player to get his ID

#

I added the ID creation into the AC, usually it is outside in a function file, was economizing

#

but basically, it they have no score or it is zero, then it will add 1 to the count and give them that as the ID

#

I need to grab the ID on the way out of the transition

#

The lock entity is reqardless... point is to get the player Id from the scoreboard into his variable

late moss
#

Does the id creation part work?

fresh lily
#

it works when I have a function doing it.. that does not matter, I can assign the score manually for the testing

#

I just added the code for convenience

late moss
#

So it's broken?

fresh lily
#

no

late moss
#

Alright

fresh lily
#

okay, let's just take that out for now. then ...

late moss
#

I was asking cuz there's a questionable part of using q.scoreboard before the score was created, it'd probably return 0 if it doesn't exist, but might also throw errors or break stuff. Ig if your logic works, then 0 it is

fresh lily
#

that is why I put ! ( >0)

#

It will create it on the exit

#

I can play with all that... but there are 2 places I put the variable capture.... is either correct?

late moss
#
{
    "format_version": "1.10.0",
    "animation_controllers": {
        "controller.animation.new_player_query": {
            "states": {
                "default": {
                    "transitions": [{"is_new": "!q.scoreboard('player_ids')"}],
                    "on_exit": [
                        "/scoreboard objectives add player_ids dummy",
                        "/scoreboard players add @s player_ids 0"
                    ]
                },
                /*
                    Should only do this ONCE ever
                */
                "is_new": {                    
                    "on_entry": [
                        "/scoreboard players add counter player_ids 1",
                        "/scoreboard players operation @s player_ids = counter player_ids"
                    ],
                    "transitions": [{"default": "v.player_id = q.scoreboard('player_ids'); return !v.player_id"}],
                    
                    "on_exit": [,
                        "@s set_id_property", // sets property to v.player_id
                        "/titleraw @s title {\"rawtext\":[{\"text\":\"§aYour Player ID is \"},{\"score\":{\"name\":\"@s\",\"objective\":\"player_ids\"}}]}"
                    ]
                }
            }
        }
    }
}```
fresh lily
#

That "@s set_id_property" would apply to any variables I created?

late moss
#

@s event_name is a syntax for triggering an event from animations and ACs, and in that event you'd set a property to v.player_id

fresh lily
#

This is the property "id:player": {"type":"int","range":[0,1000],"default":0,"client_sync":true}

#

okay... and I can use v.player_id just like I can use q.property('blahblah')

late moss
#

If you mean when setting a property then yeah, you can just do that "set_property": { "blahblah": "v.player_id" }

fresh lily
#

which would be
"ev:player_id_get":{"set_property":{"id:player":"v.player_id"}}

late moss
#

You can also have any other molang in set_property field, just can't use any queries except one or two

fresh lily
#

After I have this solid, I will post in #1072983602821861426 because a lot of people ask about this type of stuff and there is not one solid example of it anywhere findable.

#

Thank you very much..