MCPcopy Create free account
hub / github.com/DFHack/dfhack / decode_path

Function decode_path

plugins/siege-engine.cpp:847–874  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

845};
846
847static 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
876static int projPosAtStep(lua_State *L)
877{

Callers 3

projPosAtStepFunction · 0.85
projPathMetricsFunction · 0.85
safeAimProjectileMethod · 0.85

Calls 6

lua_absindexFunction · 0.85
lua_getfieldFunction · 0.85
CheckDFAssignFunction · 0.85
luaL_optnumberFunction · 0.85
lua_isnumberFunction · 0.85
ProjectilePathClass · 0.85

Tested by

no test coverage detected