Fix issues with sets and 1.14 functions

This commit is contained in:
Misode
2019-12-29 14:28:38 +01:00
parent 2309d256eb
commit 45e2227a59
4 changed files with 8 additions and 2 deletions

View File

@@ -219,7 +219,10 @@ function addToSet(el, array) {
function removeFromSet(el, array) {
let parent = getParent(el);
console.warn(parent[array]);
console.log($(el).attr('value'));
let index = parent[array].indexOf($(el).attr('value'));
console.log(parent, index);
if (index > -1) {
parent[array].splice(index, 1);
invalidated();

View File

@@ -159,6 +159,7 @@
{
"id": "function",
"type": "enum",
"filter": true,
"translate": "function.type",
"translateValue": "function.type",
"default": "minecraft:set_count",

View File

@@ -168,7 +168,8 @@
{
"id": "rolls",
"type": "random",
"translate": "pool.rolls"
"translate": "pool.rolls",
"help": true
},
{
"id": "bonus_rolls",

View File

@@ -246,6 +246,7 @@ function generateSet(data, struct) {
collection = collections[struct.values];
}
for (let value of collection) {
if (data && (data.includes(value))) continue;
let $item = $('<a class="dropdown-item" onclick="addToSet(this, \'' + struct.id + '\')" />');
setValueAndName($item, value, struct.translateValue);
$el.find('.dropdown-menu').append($item);
@@ -254,7 +255,7 @@ function generateSet(data, struct) {
let $setContainer = $('<div/>');
for (let option of data) {
let $item = $('<button type="button" onclick="removeFromSet(this, \'' + struct.id + '\')" />').addClass('btn btn-outline-danger bg-light btn-sm mr-2 mt-2');
setValueAndName($item, correctNamespace(option), struct.translateValue);
setValueAndName($item, option, struct.translateValue);
$setContainer.append($item);
}
$el.append($setContainer);