Add lower limit argument to device_random (#990)
* Add lower limit argument to device_random * Better checking
This commit is contained in:
parent
64a25f5f61
commit
8dff9e3d09
@ -593,6 +593,29 @@ namespace pxt.editor {
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
// device_random now refers to randomRange() so we need to add the missing lower bound argument
|
||||
U.toArray(dom.querySelectorAll("block[type=device_random]"))
|
||||
.forEach(node => {
|
||||
for (let i = 0; i < node.children.length; i++) {
|
||||
const child = node.children.item(i);
|
||||
if (child.tagName === "value" && child.getAttribute("name") === "min") {
|
||||
return;
|
||||
}
|
||||
}
|
||||
const v = node.ownerDocument.createElement("value");
|
||||
const s = node.ownerDocument.createElement("shadow");
|
||||
const f = node.ownerDocument.createElement("field");
|
||||
|
||||
v.setAttribute("name", "min");
|
||||
v.appendChild(s);
|
||||
s.setAttribute("type", "math_number");
|
||||
s.appendChild(f);
|
||||
f.setAttribute("name", "NUM");
|
||||
f.textContent = "0";
|
||||
node.appendChild(v);
|
||||
});
|
||||
}
|
||||
|
||||
initExtensionsAsync = function (opts: pxt.editor.ExtensionOptions): Promise<pxt.editor.ExtensionResult> {
|
||||
|
Loading…
Reference in New Issue
Block a user