| 3 | namespace Star { |
| 4 | |
| 5 | LuaValue 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 | |
| 21 | Maybe<InventorySlot> LuaConverter<InventorySlot>::to(LuaEngine&, LuaValue const& v) { |
| 22 | if (auto str = v.ptr<LuaString>()) { |
nothing calls this directly
no test coverage detected