inventory convert fix (items count)
This commit is contained in:
parent
bad871b0a2
commit
2a77c24414
@ -6,9 +6,10 @@ add_packs = {}
|
|||||||
rem_packs = {}
|
rem_packs = {}
|
||||||
|
|
||||||
function apply()
|
function apply()
|
||||||
core.reconfig_packs(add_packs, rem_packs)
|
if not core.reconfig_packs(add_packs, rem_packs) then
|
||||||
menu:back()
|
menu:back()
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function refresh_changes()
|
function refresh_changes()
|
||||||
document.apply_btn.enabled = (#add_packs>0) or (#rem_packs>0)
|
document.apply_btn.enabled = (#add_packs>0) or (#rem_packs>0)
|
||||||
|
|||||||
@ -335,6 +335,10 @@ Map& Map::put(std::string key, std::unique_ptr<Value> value) {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Map::remove(const std::string& key) {
|
||||||
|
values.erase(key);
|
||||||
|
}
|
||||||
|
|
||||||
List& Map::putList(std::string key) {
|
List& Map::putList(std::string key) {
|
||||||
List* arr = new List();
|
List* arr = new List();
|
||||||
put(key, arr);
|
put(key, arr);
|
||||||
|
|||||||
@ -118,6 +118,8 @@ namespace dynamic {
|
|||||||
Map& put(std::string key, bool value);
|
Map& put(std::string key, bool value);
|
||||||
Map& put(std::string key, std::unique_ptr<Value> value);
|
Map& put(std::string key, std::unique_ptr<Value> value);
|
||||||
|
|
||||||
|
void remove(const std::string& key);
|
||||||
|
|
||||||
List& putList(std::string key);
|
List& putList(std::string key);
|
||||||
Map& putMap(std::string key);
|
Map& putMap(std::string key);
|
||||||
|
|
||||||
|
|||||||
@ -88,7 +88,11 @@ void Inventory::convert(dynamic::Map* data, const ContentLUT* lut) {
|
|||||||
for (size_t i = 0; i < slotsarr->size(); i++) {
|
for (size_t i = 0; i < slotsarr->size(); i++) {
|
||||||
auto item = slotsarr->map(i);
|
auto item = slotsarr->map(i);
|
||||||
itemid_t id = item->getInt("id", ITEM_EMPTY);
|
itemid_t id = item->getInt("id", ITEM_EMPTY);
|
||||||
item->put("id", lut->getItemId(id));
|
itemid_t replacement = lut->getItemId(id);
|
||||||
|
item->put("id", replacement);
|
||||||
|
if (replacement == 0 && item->has("count")) {
|
||||||
|
item->remove("count");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -91,7 +91,8 @@ static int l_reconfig_packs(lua_State* L) {
|
|||||||
}
|
}
|
||||||
auto controller = scripting::engine->getController();
|
auto controller = scripting::engine->getController();
|
||||||
controller->reconfigPacks(scripting::controller, addPacks, remPacks);
|
controller->reconfigPacks(scripting::controller, addPacks, remPacks);
|
||||||
return 0;
|
lua_pushboolean(L, scripting::controller != nullptr);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int l_get_bindings(lua_State* L) {
|
static int l_get_bindings(lua_State* L) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user