#Is there a way to detect when the player attacked in a query?

1 messages · Page 1 of 1 (latest)

harsh tusk
#

Im making an attachable and want to make it that when the player interacts it plays an animations then when it attacks plays another one

harsh tusk
#
                    "transitions": [
                        {
                            "default": "variable.attack_time > 0"
                        }
                    ]
#

like this doesnt work

#
                "pre_animation": [
                    "variable.attack_time = variable.attack_time;"
                ],
#

and this doesnt work also

#

it tells me ```[Molang][error]-minecraft:player.0.6820b755-329b-45dc-a671-621db3960d2d.Santi | | Error: unhandled request for unknown variable 'variable.attack_time'

#

My format version of the attachable is "format_version": "1.20.70",

#

tried with a bunch of different onces but no luck

jade estuary
harsh tusk
harsh tusk
#

is it because im not using it in the player or an entity?

#
{
    "format_version": "1.10.0",
    "animation_controllers": {
        "controller.animation.santi.book": {
            "initial_state": "closed",
            "states": {
                "closed": {
                    "animations": [
                        "close_book_static"
                    ],
                    "transitions": [
                        {
                            "open": "query.is_item_name_any('slot.weapon.mainhand', 'santi:book') && query.is_using_item == true"
                        }
                    ]
                },
                "open": {
                    "animations": [
                        "open_book"
                    ],
                    "transitions": [
                        {
                            "page_1": "query.is_item_name_any('slot.weapon.mainhand', 'santi:book') && query.any_animation_finished && query.is_using_item == true"
                        }
                    ]
                },
                "page_1": {
                    "animations": [
                        "page_1"
                    ],
                    "transitions": [
                        {
                            "page_2": "query.is_item_name_any('slot.weapon.mainhand', 'santi:book') && query.any_animation_finished && query.is_using_item == true"
                        }
                    ]
                },
                "page_2": {
                    "animations": [
                        "page_2"
                    ],
                    "transitions": [
                        {
                            "page_1": "v.attack_time > 0"
                        }
                    ]
                }
            }
        }
    }
}
#

this is the whole anim contorller

#
{
    "format_version": "1.10.0",
    "minecraft:attachable": {
        "description": {
            "identifier": "santi:book",
            "materials": {
                "default": "skeleton"
            },
            "textures": {
                "default": "textures/book/book"
            },
            "geometry": {
                "default": "geometry.santi.book"
            },
            "animations": {
                "book": "controller.animation.santi.book",
                "hold_first_person": "animation.book.hold_first_person",
                "hold_third_person": "animation.book.hold_third_person",
                "close_book_static": "animation.book.close_book_static",
                "open_book": "animation.book.open_book",
                "page_1": "animation.book.page_1",
                "page_2": "animation.book.page_2"
            },
            "scripts": {
                "pre_animation": [
                    "variable.attack_time = variable.attack_time;"
                ],
                "animate": [
                    "book",
                    {
                        "hold_first_person": "context.is_first_person == 1.0"
                    },
                    {
                        "hold_third_person": "context.is_first_person == 0.0"
                    }
                ]
            },
            "render_controllers": [
                "controller.render.skeleton"
            ]
        }
    }
}

this is the attachable

jade estuary
#

just that

harsh tusk
#

thats not the problem

#

will try

#

but the problem is the variant

#

[Molang][error]-minecraft:player.0.Customa0eb86a3-4c47-39af-b236-933bd88d7757 | | Error: unhandled request for unknown variable 'variable.attack_time'