so, i have so problem with my extensions but you choose what problem to help me with.
problem #1
So, i need help with my extension because when i put the variable in these blocks i won’t allow it so, here’s the code for the blocks:
//% block="On game update every $ms do if $tru"
//% draggableParameters
//% subcategory="Logic"
export function GameUpdateEveryIf(ms: number, tru: Boolean, handler: () => void) {
game.onUpdateInterval(ms, function() {
if (tru) {
handler();
}
})
}
//% block="On game update if $tru"
//% draggableParameters
//% subcategory="Logic"
export function GameUpdateIf(tru: Boolean, handler: () => void) {
game.onUpdate(function() {
if (tru) {
handler();
}
})
}
//% block="forever if $tru"
//% subcategory="Logic"
export function onEventAsStatement(tru: Boolean, handler: () => void) {
forever(function() {
if (tru) {
handler();
}
})
}
problem #2
So how to you add a “+” button to the “false is -1 or 0: $toggle” ? heres the code:
//% block="Convert $n|to number|false is -1 or 0: $toggle"
//% subcategory="Logic"
//% toggle.shadow="toggleYesNo"
export function ConvertToNum(n: boolean, toggle: boolean) {
if (n) {
return CyberScripts.fib(toggle, 0, -1);
} else {
return 1;
}
}
//% block="if|$t then|$input1 else|$input2"
//% subcategory="Logic"
export function fib(t: boolean, input1: any, input2: any): any {
if (t) {
return input1;
} else {
return input2;
}
}
