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

Method makeObjectCallbacks

source/game/StarObject.cpp:899–1083  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

897}
898
899LuaCallbacks Object::makeObjectCallbacks() {
900 LuaCallbacks callbacks;
901
902 callbacks.registerCallback("name", [this]() {
903 return name();
904 });
905
906 callbacks.registerCallback("direction", [this]() {
907 return numericalDirection(direction());
908 });
909
910 callbacks.registerCallback("position", [this]() {
911 return position();
912 });
913
914 callbacks.registerCallback("setInteractive", [this](bool interactive) {
915 m_interactive.set(interactive);
916 });
917
918 callbacks.registerCallbackWithSignature<Maybe<String>>("uniqueId", bind(&Object::uniqueId, this));
919 callbacks.registerCallbackWithSignature<void, Maybe<String>>("setUniqueId", bind(&Object::setUniqueId, this, _1));
920
921 callbacks.registerCallback("boundBox", [this]() {
922 return metaBoundBox().translated(position());
923 });
924
925 callbacks.registerCallback("spaces", [this]() {
926 return spaces();
927 });
928
929 callbacks.registerCallback("setProcessingDirectives", [this](String const& directives) {
930 m_networkedAnimator->setProcessingDirectives(directives);
931 });
932
933 callbacks.registerCallback("setSoundEffectEnabled", [this](bool soundEffectEnabled) {
934 m_soundEffectEnabled.set(soundEffectEnabled);
935 });
936
937 callbacks.registerCallback("smash", [this](Maybe<bool> smash) {
938 breakObject(smash.value(false));
939 });
940
941 callbacks.registerCallback("level", [this]() {
942 return configValue("level", this->world()->threatLevel());
943 });
944
945 callbacks.registerCallback("toAbsolutePosition", [this](Vec2F const& p) {
946 return p + position();
947 });
948
949 callbacks.registerCallback("say", [this](String line, Maybe<StringMap<String>> const& tags, Json const& config) {
950 if (tags)
951 line = line.replaceTags(*tags, false);
952
953 if (!line.empty()) {
954 addChatMessage(line, config);
955 return true;
956 }

Callers

nothing calls this directly

Calls 15

nameFunction · 0.85
numericalDirectionFunction · 0.85
singletonClass · 0.85
jsonToVec2IFunction · 0.85
overlapMethod · 0.80
entityIdMethod · 0.80
materialDatabaseMethod · 0.80
createTableMethod · 0.60
registerCallbackMethod · 0.45
setMethod · 0.45
translatedMethod · 0.45

Tested by

no test coverage detected