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

Method itemConfig

source/game/StarItemDatabase.cpp:194–214  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

192}
193
194ItemDatabase::ItemConfig ItemDatabase::itemConfig(String const& itemName, Json parameters, Maybe<float> level, Maybe<uint64_t> seed) const {
195 auto const& data = itemData(itemName);
196
197 ItemConfig itemConfig;
198 if (data.assetsConfig)
199 itemConfig.config = Root::singleton().assets()->json(*data.assetsConfig);
200 itemConfig.directory = data.directory;
201 itemConfig.config = jsonMerge(itemConfig.config, data.customConfig);
202 itemConfig.parameters = parameters;
203
204 if (auto builder = itemConfig.config.optString("builder")) {
205 RecursiveMutexLocker locker(m_luaMutex);
206 auto context = m_luaRoot->createContext(*builder);
207 context.setCallbacks("root", LuaBindings::makeRootCallbacks());
208 context.setCallbacks("sb", LuaBindings::makeUtilityCallbacks());
209 luaTie(itemConfig.config, itemConfig.parameters) = context.invokePath<LuaTupleReturn<Json, Json>>(
210 "build", itemConfig.directory, itemConfig.config, itemConfig.parameters, level, seed);
211 }
212
213 return itemConfig;
214}
215
216Maybe<String> ItemDatabase::itemFile(String const& itemName) const {
217 if (!hasItem(itemName)) {

Callers 1

addCodexesMethod · 0.45

Calls 8

singletonClass · 0.85
luaTieFunction · 0.85
jsonMethod · 0.80
assetsMethod · 0.80
optStringMethod · 0.80
setCallbacksMethod · 0.80
jsonMergeFunction · 0.50
createContextMethod · 0.45

Tested by

no test coverage detected