MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / entityHandItem

Method entityHandItem

source/game/scripting/StarWorldLuaBindings.cpp:1498–1515  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1496 }
1497
1498 Maybe<String> WorldEntityCallbacks::entityHandItem(World* world, EntityId entityId, String const& handName) {
1499 ToolHand toolHand;
1500 if (handName == "primary") {
1501 toolHand = ToolHand::Primary;
1502 } else if (handName == "alt") {
1503 toolHand = ToolHand::Alt;
1504 } else {
1505 throw StarException(strf("Unknown tool hand {}", handName));
1506 }
1507
1508 if (auto entity = world->get<ToolUserEntity>(entityId)) {
1509 if (auto item = entity->handItem(toolHand)) {
1510 return item->name();
1511 }
1512 }
1513
1514 return {};
1515 }
1516
1517 Json WorldEntityCallbacks::entityHandItemDescriptor(World* world, EntityId entityId, String const& handName) {
1518 ToolHand toolHand;

Callers

nothing calls this directly

Calls 4

StarExceptionClass · 0.85
strfFunction · 0.85
handItemMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected