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

Method placeObject

source/game/scripting/StarWorldLuaBindings.cpp:850–876  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

848 }
849
850 bool WorldCallbacks::placeObject(World* world,
851 String const& objectType,
852 Vec2I const& worldPosition,
853 Maybe<int> const& objectDirection,
854 Json const& objectParameters) {
855 auto objectDatabase = Root::singleton().objectDatabase();
856
857 try {
858 Direction direction = Direction::Right;
859 if (objectDirection && *objectDirection < 0)
860 direction = Direction::Left;
861
862 Json parameters = objectParameters ? objectParameters : JsonObject();
863
864 auto placedObject = objectDatabase->createForPlacement(world, objectType, worldPosition, direction, parameters);
865 if (placedObject) {
866 world->addEntity(placedObject);
867 return true;
868 }
869 } catch (StarException const& exception) {
870 Logger::warn("Could not create placable object of kind '{}', exception caught: {}",
871 objectType,
872 outputException(exception, false));
873 }
874
875 return false;
876 }
877
878 Maybe<EntityId> WorldCallbacks::spawnItem(World* world,
879 Json const& itemType,

Callers

nothing calls this directly

Calls 5

singletonClass · 0.85
objectDatabaseMethod · 0.80
createForPlacementMethod · 0.80
outputExceptionFunction · 0.50
addEntityMethod · 0.45

Tested by

no test coverage detected