| 845 | }; |
| 846 | |
| 847 | static ProjectilePath decode_path(lua_State *L, int idx, df::coord origin) |
| 848 | { |
| 849 | idx = lua_absindex(L, idx); |
| 850 | |
| 851 | Lua::StackUnwinder frame(L); |
| 852 | df::coord goal; |
| 853 | |
| 854 | lua_getfield(L, idx, "target"); |
| 855 | Lua::CheckDFAssign(L, &goal, frame[1]); |
| 856 | |
| 857 | lua_getfield(L, idx, "delta"); |
| 858 | |
| 859 | if (!lua_isnil(L, frame[2])) |
| 860 | { |
| 861 | lua_getfield(L, idx, "factor"); |
| 862 | int factor = luaL_optnumber(L, frame[3], ProjectilePath::DEFAULT_FUDGE); |
| 863 | |
| 864 | if (lua_isnumber(L, frame[2])) |
| 865 | return ProjectilePath(origin, goal, lua_tonumber(L, frame[2]), factor); |
| 866 | |
| 867 | df::coord delta; |
| 868 | Lua::CheckDFAssign(L, &delta, frame[2]); |
| 869 | |
| 870 | return ProjectilePath(origin, goal, delta, factor); |
| 871 | } |
| 872 | |
| 873 | return ProjectilePath(origin, goal); |
| 874 | } |
| 875 | |
| 876 | static int projPosAtStep(lua_State *L) |
| 877 | { |
no test coverage detected