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

Function traceUnitPath

plugins/siege-engine.cpp:1294–1323  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1292}
1293
1294static int traceUnitPath(lua_State *L)
1295{
1296 auto unit = Lua::CheckDFObject<df::unit>(L, 1);
1297
1298 CHECK_NULL_POINTER(unit);
1299
1300 size_t idx = 1;
1301 auto info = UnitPath::get(unit);
1302 lua_createtable(L, info->path.size(), 0);
1303
1304 float last_time = 0.0f;
1305 for (auto it = info->path.begin(); it != info->path.end(); ++it)
1306 {
1307 Lua::Push(L, it->second);
1308 if (idx > 1)
1309 {
1310 lua_pushnumber(L, last_time);
1311 lua_setfield(L, -2, "from");
1312 }
1313 if (idx < info->path.size())
1314 {
1315 lua_pushnumber(L, it->first);
1316 lua_setfield(L, -2, "to");
1317 }
1318 lua_rawseti(L, -2, idx++);
1319 last_time = it->first;
1320 }
1321
1322 return 1;
1323}
1324
1325static int unitPosAtTime(lua_State *L)
1326{

Callers

nothing calls this directly

Calls 9

lua_createtableFunction · 0.85
PushFunction · 0.85
lua_pushnumberFunction · 0.85
lua_setfieldFunction · 0.85
lua_rawsetiFunction · 0.85
getFunction · 0.70
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected