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

Method from

source/game/scripting/StarLuaGameConverters.cpp:5–19  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3namespace Star {
4
5LuaValue LuaConverter<InventorySlot>::from(LuaEngine& engine, InventorySlot k) {
6 if (auto equipment = k.ptr<EquipmentSlot>())
7 return engine.createString(EquipmentSlotNames.getRight(*equipment));
8 else if (auto bag = k.ptr<BagSlot>()) {
9 auto table = engine.createTable(2, 0);
10 table.set(1, bag->first);
11 table.set(2, bag->second);
12 return table;
13 }
14 else if (k.is<SwapSlot>())
15 return engine.createString("swap");
16 else if (k.is<TrashSlot>())
17 return engine.createString("trash");
18 else return {}; // avoid UB if every accounted-for case fails
19}
20
21Maybe<InventorySlot> LuaConverter<InventorySlot>::to(LuaEngine&, LuaValue const& v) {
22 if (auto str = v.ptr<LuaString>()) {

Callers

nothing calls this directly

Calls 7

jsonFromStatModifierFunction · 0.85
createStringMethod · 0.80
luaFromMethod · 0.80
createTableMethod · 0.60
joinFunction · 0.50
setMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected