Fix blank animqueues, and add facing=math.auto to animate

This commit is contained in:
2024-03-12 11:46:48 -04:00
parent 044bb89edf
commit 357e3766fb
9 changed files with 147 additions and 42 deletions

View File

@@ -130,7 +130,7 @@ LuaDefine(tangible_animinit, "tan,config",
World *w = World::fetch_global_pointer(L);
Tangible *tan = w->tangible_get(LS, tanobj, false);
AnimState state;
eng::string error = state.apply_lua(LS, config, true);
eng::string error = state.from_lua(LS, config, true, false);
if (!error.empty()) {
luaL_error(L, "%s", error.c_str());
}
@@ -185,18 +185,25 @@ LuaDefine(tangible_animate, "tan,options,config",
if (kp.parse(option, "replace")) {
replace = LS.ckboolean(option);
}
kp.final_check_throw();
}
World *w = World::fetch_global_pointer(L);
Tangible *tan = w->tangible_get(LS, tanobj, false);
AnimState state = tan->anim_queue_.get_final_persistent();
eng::string error = state.apply_lua(LS, steptab, false);
AnimState previous = tan->anim_queue_.get_final_persistent();
AnimState update;
eng::string error = update.from_lua(LS, steptab, false, true);
if (!error.empty()) {
luaL_error(L, "%s", error.c_str());
}
AnimState merge;
error = merge.merge(previous, update);
if (!error.empty()) {
luaL_error(L, "%s", error.c_str());
}
if (replace) {
tan->anim_queue_.replace(state);
tan->anim_queue_.replace(merge);
} else {
tan->anim_queue_.add(state);
tan->anim_queue_.add(merge);
}
tan->update_plane_item();
return LS.result();
@@ -289,7 +296,7 @@ LuaDefine(tangible_build, "config",
// Calculate the initial animation state.
AnimState state;
err = state.apply_lua(LS, animstate, true);
err = state.from_lua(LS, animstate, true, false);
if (err != "") {
luaL_error(L, "%s", err.c_str());
}