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

Method applyAugment

source/game/StarItemDatabase.cpp:399–421  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

397}
398
399ItemPtr ItemDatabase::applyAugment(ItemPtr const item, AugmentItem* augment) const {
400 if (item) {
401 RecursiveMutexLocker locker(m_luaMutex);
402 LuaBaseComponent script;
403 script.setLuaRoot(m_luaRoot);
404 script.setScripts(augment->augmentScripts());
405 script.addCallbacks("item", LuaBindings::makeItemCallbacks(augment));
406 script.addCallbacks("config", LuaBindings::makeConfigCallbacks(bind(&Item::instanceValue, augment, _1, _2)));
407 script.init();
408 auto luaResult = script.invoke<LuaTupleReturn<Json, Maybe<uint64_t>>>("apply", item->descriptor().toJson());
409 script.uninit();
410 locker.unlock();
411
412 if (luaResult) {
413 if (!get<0>(*luaResult).isNull()) {
414 augment->take(get<1>(*luaResult).value(1));
415 return ItemDatabase::item(ItemDescriptor(get<0>(*luaResult)));
416 }
417 }
418 }
419
420 return item;
421}
422
423bool ItemDatabase::ageItem(ItemPtr& item, double aging) const {
424 if (!item)

Callers 1

Calls 13

ItemDescriptorClass · 0.85
setLuaRootMethod · 0.80
setScriptsMethod · 0.80
augmentScriptsMethod · 0.80
addCallbacksMethod · 0.45
initMethod · 0.45
toJsonMethod · 0.45
descriptorMethod · 0.45
uninitMethod · 0.45
unlockMethod · 0.45
isNullMethod · 0.45
takeMethod · 0.45

Tested by

no test coverage detected