#Molang General

1 messages · Page 4 of 1

manic sandal
#

is there a query for detecting when the entity was hit?

proud token
manic sandal
#

I had to do some workarounds, but I got working what I was trying to do

worthy fable
#

Hey guys I have a question, why the ```
geometry.humanoid.customSlim

Changes when the player selects a custom skin? On my project the player uses the slim model, but when I select a custom skin for some reason the item position changes, it's like custom skin uses another model
#

If that's the case, is there a way to change the other model?

humble lantern
#

where should i put the semicolon for this?

inner jasper
humble lantern
round wyvern
round wyvern
cinder ridge
#

Is it possible to change the inflation animation of the Creeper or TNT?

rugged basin
#

Hello, I'm trying to create animations not affect by vanilla ones, I'm using -this on them but they see like they are just changing the values of the whole animation? is there some page/documentation/info about this and how to use it to "cancel" vanilla animations? Like bob or running ones. Thanks

sour quail
#
"t.prop_y = query.property('c:y');",
"t.changed_y = math.abs(t.prop_y - v.target_y) > 0.01;",
"t.changed_y ? { v.prev_y = v.current_y; v.target_y = t.prop_y; v.progress_y = 0; };",
"v.progress_y = math.min(v.progress_y + q.delta_time * 2.5, 1);",
"t.diff_y = v.target_y - v.prev_y;",
"t.diff_y = t.diff_y + (t.diff_y > 180 ? -360 : 0);",
"t.diff_y = t.diff_y + (t.diff_y < -180 ? 360 : 0);",
"v.current_y = v.prev_y + t.diff_y * v.progress_y;",

I’m trying to create interpolation using this feature, but when it goes from 0 to 360 or from 360 to 0, it makes a full rotation, which causes a problem. How can I fix this?

jolly echo
#

what accuracy do integers in molang have?

#

ah single precision floats

#

welp fuck

shrewd badge
jolly echo
#

ig my best thing rn is just a ton of variables

lilac flame
#

Why does molang exist

torpid vault
#

Hey Molang is neat

lilac flame
#

That's what THEY want you to think

river grotto
sullen citrus
#

Is there any way to pass a value for a toggle into molang in a resource pack?

#

something like a tag or scoreboard or something. Ideally I can set it with scripts
also, something that sets a variable on the player would also work

sullen citrus
#

nvm, I solved it. run /playanimation "some_animation" none 0 "v.variable = 1;"

sage bronze
#

so im getting an "unrecognized token" error with the molang string in this file (great job Mojang, not explaining CRAP about whats wrong) and i dont know why, anyone else know?

iron hedge
sage bronze
#

...

#

o h

#

lemme see if that fixes it

#

well that issue is gone

#

but one still remains

#

the variable isnt getting registered

#

probably because its in the feature rules file?

worthy raven
#

what is the best molang for animation controllers for walking cause my animation controller on walking keeps jittering im using a smooth keyframes in my animations combined with linear keyframes i dont why it keeps jittering

#

query.ground_speed >= 1.0 for when walking
query.ground_speed < 0.05 for when idle

spark spade
river grotto
#

Is there a bug with the camera rotation query that makes it not work on attachables

#

I've attempted using it and it rotated kind of weirdly
Nvm, figured out my problem

inland forum
spark spade
#

Perhaps do both conditions?

inland forum
inland forum
river grotto
inland forum
river grotto
#

Lol

proud token
#

@atomic rover
query.movement_direction

#
query.movement_direction(0)
query.movement_direction(1)
query.movement_direction(2)
atomic rover
atomic rover
proud token
#

its for checking moving forward, backward, left or right.

atomic rover
#

then how can i use the cardinal direction one?

inner jasper
#

Can't you just check for Body Rotation then?

atomic rover
inner jasper
#

Now I'm confused.

#

Why are you asking an xy problem question.

atomic rover
#

cuz i want to play the animations that will make some fake physics depending on the direction u are moving into

inner jasper
#

So what does this have to do with attachables?

atomic rover
#

bec the item i am animating is an attachable,

inner jasper
#

Are you trying to query the entity or the attachable. If the attachable why did you ask how to get the entity's rotation.

atomic rover
#

just didnt know that attachables can detect the holder entity rotation/stuff,
-# im kinda new to molang/animations btw

proud token
#

maybe he means the entity that is holding/wearing the item

#

yeah

inner jasper
#

That's irrelevant really. Just get the entity's rotation, didn't need to bring up attachables.

atomic rover
#

i believe i just have to detect the cardinal direction, so when u try moving forwards, the forward animation will play,
what should i use for that?

proud token
#

maybe he just wanted to know if it was possible to pass the data over to attachables.

inner jasper
inner jasper
#

Not cardinal stuff.

atomic rover
#

ig ill deal with it tomorrow,

#

its more like holding a lantern, moving forwards the lantern to rotate backwards, im trying to recreate that type of physics

proud token
atomic rover
#

i see

atomic rover
#

lemme show u what i am using/the results

proud token
#

I believe

#

or are you going for side aswell

atomic rover
atomic rover
#

north south east west, they all got the rotation animation

#

its more like this:
north-east = the vines are going south-west, both animations will play at the same time making the item moving towards south-west

#

and i believe in the rotation stuff, i can add some math or something to make the rotation goes further depending on the player movement, so the physics looks right

#

i think i only need two controllers, one for north-south and one for west-east for smoother transitions or whatever

proud token
#

you dont need multiple controllers

#

just multiple transitions

atomic rover
#

yeah,

#

ill use two controllers, since u cant run two states in one controller at the same time (bec i dont want to add more animations for more states in one controller)

proud token
#

i think you are going about it wrong.

atomic rover
#

ig u can help me with the v.movement_x thing,

proud token
#

only 1 controller is needed

atomic rover
#

mhm,

#

with only 4 states for each direction?
or i have to add an extra 4 states for the diagonal directions?

proud token
#

yeah, 8 states.

atomic rover
#

wait, i see it now, 8 states, the diagonal ones can be achieved by adding more animations to the "animations" things

proud token
#

just make 4 diagonal animations

atomic rover
#

ill make the animations later on, for now ill just rotate the vines depending on the direction with no diagonals

#

can u help me with that?
like just the query/variable thing

proud token
#

im currently working on something rn, im sure someone else can assist

atomic rover
#

alright, gl with ur work!

proud token
#

you too

atomic rover
# proud token you too

ay, the only issue i am facing with the movement_direction is that it detects a whole direction (like from north to east, the whole side is considered north in my system)

#

so thats why the wrong animation is keep getting played, its bec the north animation is being played with the other directions like east or west

#

can i at least debug the variable? so i can make some transition conditions better or somethin

proud token
atomic rover
#

seems like alot of work

proud token
#

and then in scripts, get the property's value and output in console.warn() or something to see the value

proud token
atomic rover
#

d u know how much is the output can reach?
like from 0 to 120 or something?

#

i just have no idea where it stop or reaches the maximum

proud token
#

well the query's value wont surpass 1 or below -1 for each axis I believe.

#

so that's not a problem at all

#

the limit is also pretty high iirc

atomic rover
#

ill just deal with it tomorrow,

#

by debugging the axis

#

or maybe downloading some animation packs that might have some fake physics animations and see how they made it,

proud token
atomic rover
atomic rover
atomic rover
#

so if u are facing south and moving towards north, it will play the south animations

#

apparently the fake physics animations are harder than i expected lol

atomic rover
#

look at the hanging vines near the handle,

#

the way they move is great if u move while looking at the right direction

#

heres the code:

    "controller.animation.xfallenwarriors.ancient.sword.vines.direction0":{
      "initial_state":"null",
      "states":{
        "null":{
          "blend_via_shortest_path":true,
          "blend_transition":0.15,
          "transitions":[{"is_north":"(v.movement_x > 35)"},{"is_south":"(v.movement_x < -35)"},{"is_east":"(v.movement_z > 35)"},{"is_west":"(v.movement_z < -35)"}]
        },
        "is_north":{
          "blend_via_shortest_path":true,
          "blend_transition":0.25,
          "animations":["vines.movement.north"],
          "transitions":[{"null":"(v.movement_x <= 0)"}]
        },
        "is_south":{
          "blend_via_shortest_path":true,
          "blend_transition":0.25,
          "animations":["vines.movement.south"],
          "transitions":[{"null":"(v.movement_x >= 0)"}]
        },
        "is_east":{
          "blend_via_shortest_path":true,
          "blend_transition":0.25,
          "animations":["vines.movement.east"],
          "transitions":[{"null":"(v.movement_z <= 0)"}]
        },
        "is_west":{
          "blend_via_shortest_path":true,
          "blend_transition":0.25,
          "animations":["vines.movement.west"],
          "transitions":[{"null":"(v.movement_z >= 0)"}]
        }
      }
    }```
#

currently, i just want to get the animation to work properly, ill add the diagonal ones later on

atomic rover
# inner jasper Not cardinal stuff.

q.cardinal_facing_2d == 2 doesnt work?
i tried adding it as variable and having it inside "per_animation" similar to movement_direction stuff, it doesnt really work
i even tried adding c.owning_entity -> and still it doesnt work, my animations isnt playing while facing the 'north' cardinal

atomic rover
#

do i need to detect the body y rotation or something?

proud token
#

im not knowledgeable enough in this area

#

honestly

atomic rover
#

i see,

#

thats why i was trying to use cardinal direction, so i can detect where u are looking to play the correct animation

proud token
#

I still think cardinal direction is not what you need for this.

atomic rover
# proud token honestly

what about detecting when i rotate my head (left/right)? bec the q.camera_rotation didnt seem to work on the attachable, do i have to use owning entity or something?

proud token
#

again, not knowledgeable man, I dont work with molang that much

atomic rover
#

i see,

proud token
#

I'm going to be working with the movement direction query myself soon, so maybe when I do I can help out after

atomic rover
#

understood, ig gl with ur other works,
for me, ill just keep on trying other queries or even using some BP typa variables

#

to like control the animation controller using scripts instead of queries

#

i believe i have to use player.json for that, right?

proud token
#

by scripts you mean js right

#

or scripts inside the entity.json file

atomic rover
#

yeah, to control the player movement direction

#

to detect*

proud token
#

since you are using scripts

#

you can use playAnimation

atomic rover
#

playAnimation doesnt work on attachables afaik

proud token
#

but like I said, fully client side would be way better

atomic rover
#

not in FP i believe

proud token
atomic rover
#

i see, ill deal with it later on,

proud token
#

Minato has the code for that.

atomic rover
#

like all i really want to do with the queries is to detect when u move forward, backwards or to the sides,

proud token
#

which that query should be for

atomic rover
# atomic rover well,

i mean, as u can see in the vid, the movement_direction works based on the workd directions not the player movements

#

i mean, it will play the south animations whenever u move towards south, no matter if u were moving forwards or backwards or even sideways

proud token
#

i havent worked with this query before so ill report back when I get around to using it

polar steeple
atomic rover
polar steeple
#

read bellow the post

atomic rover
# polar steeple read bellow the post
export function setTempVars(player, data) {
    const random_1 = (Math.random() * 1e3) << 0;
    const dataEntries = Object.entries(data)
        .map(([key, value]) => `v.movement_${key}=${JSON.stringify(value)};`)
        .join("");
    const stopExpression = 
        dataEntries +
        `return 0;`;
    player.playAnimation("animation.xfallenwarriors.direction", {
        controller: "animation_controller_set_"+random_1,
        stopExpression,
    });
}

system.runInterval(() => {
    for (const player of world.getAllPlayers()) {
        const input = player?.inputInfo;

        const {x, y} = input.getMovementVector();

        if (y > 0) setTempVars(player, {x:2})
    }
})```is there anything wrong?
#

"animation.xfallenwarriors.direction":{"animation_length":0.05},

#

attachable

            "parent_setup":"temp.attack_dur = v.attack_time ?? 0; t.movement_x = v.movement_x ?? 0.0; t.movement_y = v.movement_y ?? 0;",
            "initialize":["v.rmovement_x = 0.0;","v.rmovement_y = 0;"],
            "pre_animation":["v.rmovement_x = v.movement_x ?? 0.0; v.rmovement_y = v.movement_y ?? 0;"]```
#

oh, t.movement not v

#

fixed,

atomic rover
#

it works pretty damn well

#

now i can start working on polishing the animations

atomic rover
sour quail
#

I think Actions & Stuff also had physics like that, but it was only a resource pack—how did they make that?

cedar willow
#

Hi

#
"scripts": {
    "pre_animation": ["variable.smoothed_speed = 0;"],
    "initialize": [
        "variable.smoothed_speed = math.lerp(v.smoothed_speed, q.property('bs_mb:speed'), 0.1);"
    ],
    "animate": ["idle"]
}
#

I created a variable in pre_animation but not sure why the game said unknown variable?

sour quail
atomic rover
#

is there any way to prevent this from showing up a log when the holder entity doesnt have that property?
"pre_animation":["t.movement_x = q.property('xcore:direction.x'); t.movement_y = q.property('xcore:direction.y'); t.rotation_x = q.property('xcore:head.rotation.x'); t.rotation_y = q.property('xcore:head.rotation.y');"]

#

adding ?? 0 doesnt fix it + it has a log (unsupported)

reef oak
ionic kestrel
#

For a system like oxygen mechanics, is it better to use tags and scoreboards, or should I move to scripting for better performance and scalability?

shrewd badge
#

does anyone know what could cause this very cryptic error? it's happening inside a feature

#

there's quite a few things going on in the expression which gets assigned, but the only thing that stands out is math.ease_out_circ(), maybe that's causing it?

swift rivet
#

Usually means something like a division by 0 or sqrt or log of a negative number, watch out for things like that

#

Regarding the easing function, if it is truly the source of the error, maybe it doesn't handle values of 0, 1, something close to either of the two or -0

atomic rover
#

is there any way to change the temp value the second u switch items?
currently the system i am using to add a custom pull/draw animation, requires holding an attachable to work

#

for example, if u hold nothing or hodl another item (without attachables) and then switching back to my item, it wont play the pull/draw animations,

#

t.pull = q.is_item_name_any('slot.weapon.mainhand', 0, 'xfallenwarriors:ancient.sword.v1') inside "pre_animation" inside my attachable

atomic rover
river grotto
atomic rover
#
    "controller.animation.xfallenwarriors.ancient.sword.pull":{
      "initial_state":"not_pulling",
      "states":{
        "not_pulling":{
          "transitions":[{"is_pulling":"(t.pull == 1 && c.is_first_person)"}]
        },
        "is_pulling":{
          "blend_via_shortest_path":true,
          "blend_transition":0.25,
          "animations":["pull"],
          "transitions":[{"not_pulling":"(t.pull == 0)"}]
        }
      }
    }```
river grotto
#

Is t.pull always true currently?

atomic rover
atomic rover
river grotto
#

Ok that was a terribly stupid way to ask my question 🤦‍♂️

atomic rover
#

so, is there like a query that will detect when u stop holding the attachable? so the value can go back to 0

#

i could use scripts or BP player animation controller/player properties

#

but it has a delay or could be heavy unlike the client side ones

#

like high ping can cause some visual bugs in the animations

river grotto
#

I get it, just trying to figure out any more convenient solutions
Plus, that's a waste of a property

atomic rover
#

indeed

reef oak
atomic rover
tight scroll
#

how do i query if the player is in first person in an animation played using playanimation?

river grotto
river grotto
#

No problem 👍

cedar wyvern
# atomic rover nope, still doesnt work

This is not 100% consistent when quickly switching but it does work.

{
  "format_version": "1.19.0",
  "animation_controllers": {
    "controller.animation.AAAAAAAAA": {
      "initial_state": "default",
      "states": {
        "default": {
          "animations": [
            "draw"
          ],
          "transitions": [
            {
              "idle": "q.all_animations_finished && (t.current_time = query.time_stamp; t.result = t.current_time - v.last_time <= 1? 0 : 1;v.last_time = t.current_time;return t.result);"
            }
          ],
          "blend_transition": 0.2
        },
        "idle": {
          "animations": [
            "idle"
          ],
          "transitions": [
            {
              "default": "t.current_time = query.time_stamp; t.result = t.current_time - v.last_time <= 1? 0 : 1;v.last_time = t.current_time;return t.result;"
            }
          ],
          "blend_transition": 0.2
        }
      }
    }
  }
}
atomic rover
cedar wyvern
#

Took me 2 days to figure it out lol

atomic rover
#

damn, i was about to change the whole system into JS

#

like having to interact to pull the sword instead of switching to it instantly

cedar wyvern
#

100% in the attachable, also should initialize the v.last_time = query.time_stamp; in the "initialize" : [] part of the attachable

atomic rover
#

i could use that q.movement_direction

#

but it just doesn't really work that well

cedar wyvern
#

Yeah. You can fake it with molang. There's a couple of properties, queries and variables you can use to do it. You'll probably need to do some advanced stuff though

atomic rover
#

like it did work, but only when u walk into some directions while looking at a specific direction

atomic rover
#

even though it has a 1 tick delay, it is working better than the system i made with molang

cedar wyvern
#

Elytra animation uses query.movement_direction(1); which is probably the Y axis

atomic rover
#

i did manage to achieve that using scripts, idk if i can with molang

cedar wyvern
#

Probably need to use a combination of cardinal facing and movement speed

atomic rover
#

cardinal queries doesn't work

#

at all

#

i tried everything, nothing works, they've buggedbao_icon_entities

cedar wyvern
#

Cardinal in MC is stupid. It's completely reversed

#

You can also just get the entity rotation

atomic rover
#

i could,

#

but idrk if my brain can handle this much math

#

also,

#

is there a specific molang for interacting/attacking?

#

currently, the v.attack_time is returning every single hand rotation

cedar wyvern
#

you'll have to combine all the attacking queries then

atomic rover
cedar wyvern
#

There is q.modified_swing_duration but that might be it.

#

I'll figure it out later. I've only really started messing with molang a week ago

atomic rover
#

maybe bec I'm not really dealing with that many molang, like the last time i touched it is when i wanted to make my goatfur armor dyeable

#

tho, my next addon will use alot, aLot of molang for some advanced client player nonsense

honest flint
#

is there a query for the current lifetime of an active animation controller state?

honest flint
#

nice, thanks

ruby tinsel
#

is it possible to early return in a molang script?

swift rivet
ruby tinsel
swift rivet
#

So, not for the whole molang expression but from local scope?

ruby tinsel
#

for example i tried

(v.worldx > 64) ? {return false;}

return v.worldx > -64;
#

it's just an example, I know that in this case I could combine the experssions but I want to somehow have the option to run a lot of early returns like that to save on needless computation

swift rivet
#

You can either just avoid early returns and structure the code using conditional logic, or you can use loop(1, {}) with break, to achieve similar functionality. These are the only 2 options, as molang doesn't support returning from local contexts

ruby tinsel
#

I'm using it in the iteration fields of a scatter feature, is that considered local?

swift rivet
#

By local I mean anything more granular than the entire molang string

ruby tinsel
#

so for the loop thing it'll be something like

loop(1, {
  (v.worldx > 64) ? {break;}
  return v.worldx > -64;
})
return false;

swift rivet
#

But you can't use return to simulate functions within molang, so something like this won't work

v.sqrt = {v.foo < 0 ? {return 0;}; return math.sqrt(v.foo); }; // This will return either 0 or sqrt(v.foo) for the whole molang string
return 2*v.sqrt; // This code never runs
swift rivet
swift rivet
ruby tinsel
#

I'm having a hard time understanding it
how would you write this logic?

v.a = 1;
v.b = 1;
v.c = 1;

if (v.a != 1) return false;
if (v.b != 1) return false;
if (v.c != 1) return false;

return true;
swift rivet
#

If this is the entire molang string, then way you wrote it is correct

abstract nacelle
humble lantern
#

"query.variant==2 ? Geometry.captain : Geometry.default" this would set the geometry to the captian geometery if variant evaluated to 2 right? Also this is in a render controller.

humble lantern
atomic rover
#

yao, what should i use to play an animation specifically for the attack whole playing a different animation with the normal hand rotation?

atomic rover
# atomic rover yao, what should i use to play an animation specifically for the attack whole pl...

currently,

    "controller.animation.e.attack":{
      "initial_state":"not_attacking",
      "states":{
        "not_attacking":{
          "blend_via_shortest_path":true,
          "blend_transition":0.15,
          "transitions":[{"is_attacking":"(c.owning_entity -> v.attack_time > 0 && c.is_first_person)"}]
        },
        "is_attacking":{
          "blend_via_shortest_path":true,
          "blend_transition":0.25,
          "animations":["attack"],
          "transitions":[{"not_attacking":"(q.all_animations_finished && c.owning_entity -> v.attack_time == 0)"}]
        }
      }
    },```is playing the attack animation each time i swing my arm, which looks off when interacting or doing anything else that can rotate ur arm
abstract nacelle
#

you can using scripting only

#

so detect it with scripting and use temp leaking

atomic rover
fluid whale
#

Is there any way to detect the texture of entity and turn them into scores using molang like texture1 = 1 scores texture2= 2 scores and so on

atomic rover
abstract nacelle
abstract nacelle
honest flint
#

Small question: you can use double exclamation points in molang to check for truthy values, right?