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

Function tiletypes_setTile

plugins/tiletypes.cpp:1470–1514  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1468}
1469
1470static int tiletypes_setTile(lua_State *L) {
1471 color_ostream *out = Lua::GetOutput(L);
1472 if (!out)
1473 out = &Core::getInstance().getConsole();
1474
1475 TileType target = TileType();
1476
1477 df::coord pos;
1478 Lua::CheckDFAssign(L, &pos, 1);
1479 if (lua_istable(L, 2)) {
1480 auto lua_getintfield = [L](const char* fieldName, int defaultValue) -> int {
1481 lua_getfield(L, 2, fieldName);
1482 int output = defaultValue;
1483 if (!lua_isnil(L, -1)) {
1484 output = lua_tointeger(L, -1);
1485 }
1486 lua_pop(L, 1);
1487 return output;
1488 };
1489
1490 target.shape = (df::tiletype_shape)lua_getintfield("shape", target.shape);
1491 target.material = (df::tiletype_material)lua_getintfield("material", target.material);
1492 target.special = (df::tiletype_special)lua_getintfield("special", target.special);
1493 target.variant = (df::tiletype_variant)lua_getintfield("variant", target.variant);
1494 target.hidden = lua_getintfield("hidden", target.hidden);
1495 target.light = lua_getintfield("light", target.light);
1496 target.subterranean = lua_getintfield("subterranean", target.subterranean);
1497 target.skyview = lua_getintfield("skyview", target.skyview);
1498 target.aquifer = lua_getintfield("aquifer", target.aquifer);
1499 target.autocorrect = lua_getintfield("autocorrect", target.autocorrect);
1500 if (target.material == df::tiletype_material::STONE) {
1501 target.stone_material = lua_getintfield("stone_material", target.stone_material);
1502 target.vein_type = (df::inclusion_type)lua_getintfield("vein_type", target.vein_type);
1503 }
1504 }
1505 else {
1506 target.shape = (df::tiletype_shape)lua_tointeger(L, 2);
1507 target.material = (df::tiletype_material)lua_tointeger(L, 3);
1508 target.special = (df::tiletype_special)lua_tointeger(L, 4);
1509 target.variant = (df::tiletype_variant)lua_tointeger(L, 5);
1510 }
1511
1512 Lua::Push(L, setTile(*out, pos, target));
1513 return 1;
1514}
1515
1516DFHACK_PLUGIN_LUA_COMMANDS {
1517 DFHACK_LUA_COMMAND(tiletypes_setTile),

Callers

nothing calls this directly

Calls 5

TileTypeClass · 0.85
CheckDFAssignFunction · 0.85
lua_getfieldFunction · 0.85
PushFunction · 0.85
setTileFunction · 0.85

Tested by

no test coverage detected