rj8wjeiw

It's like the Scratch workaround challenge, but with a twist — Scratch blocks are workarounded in different programming languages

Ok so

<key [ v] pressed?>

In C++, Windows 2000 and up:

#import <stdint.h>
#import <windows.h>
bool key(uint8_t id){
return bool((uint16_t(GetAsyncKeyState(id)) >> 15);
}

where the IDs are documented at https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes .

Yyyyyy754

(()+())

In C++:

double add(double x, double y){
return double(double(x) + double(y));
}

Pretty sure, that should work for variables stored as doubles, but not for strings. So, it is a partial workaround.

clear

#import <stdint.h>
uint32_t pen[172800];
uint8_t clear(){
for (uint32_t i=0; i<172800; i++){
pen[i] &= 0x00FFFFFF;
}
}

badatprogrammingibe

(() + ())
In lisp:
+

Oh wait…

Yyyyyy754

<<> or <>>
In C++
bool or(bool a, bool b){
    return bool(bool(a)||bool(b));
}

ElsieBreeze

define add (a) (b)
set [return v] to ((a) + (b))

In OCaml
let add a b = a + b;;

Sheep_maker

((a) mod (b))
JavaScript:
function mod (a, b) {
  return (a % b + b) % b
}
 
mod(a, b)
Scheme:
(modulo a b)
((a) + (b))
JavaScript:
+a + +b
(join (a) (b))
JavaScript:
'' + a + b
// or
`${a}${b}`

Tdth

(letter (3) of [world])

In C++

"world"[3-1];

stop [this project v]
(Or stop all, etc. depending on Scratch version)

return 1/0; //chaotic operation, cannot be done on integers

NxNmultiply

(()mod())

The modulo operation does not exist on doubles, it is only a mathematical abstraction of Scratch (and Javascript). Therefore it must be implemented in software, therefore long double to handle intermediate precision.

In C++

double mod(double a, double b){
    long double c = (a/b);
    long double d = 0;
    long double e;
    while((c-d)<0){
        e = 1;
        do{
            e *= 2;
        }while(e<=(d-c));
        e /= 2;
        d -= e;
    }
    while((c-d)>=1){
        e = 1;
        do{
            e *= 2;
        }while(e<=(c-d));
        e /= 2;
        d += e;
    }
    return (a-(d*b));
}

Sheep_maker

NxNmultiply wrote:

(()mod())

The modulo operation does not exist on doubles, it is only a mathematical abstraction of Scratch (and Javascript). Therefore it must be implemented in software, therefore long double to handle intermediate precision.
Doesn't C++ have the % operator? It should be roughly identical to JavaScript's %, which is a remainder operator, so I think you could just translate Scratch's implementation of the mod block:
double mod(double n, double modulus) {
  double result = n % modulus;
  if (result / modulus < 0) result += modulus;
  return result;
}

A-E-

stop [all v]
In JS:
function stopAll(){
window.close()
setTimeout(()=>{
while(1){
alert("Close this page!")
}
},100)
}

R4356th

say []
in Python:
print ()

R4356th

say []
in C++:
printf ()

NxNmultiply

R4356th wrote:

say []
in C++:
printf ()
Uhh, this function appends text to console output, not changes the graphical speech visualization.

R4356th

NxNmultiply wrote:

R4356th wrote:

say []
in C++:
printf ()
Uhh, this function appends text to console output, not changes the graphical speech visualization.
What do you mean?

OurPrincess

say []
in HTML:
<p></p>

R4356th

OurPrincess wrote:

say []
in HTML:
<p></p>
Well, technically, that is not a workaround in HTML it just writes text in a webpage.

OurPrincess

R4356th wrote:

OurPrincess wrote:

say []
in HTML:
<p></p>
Well, technically, that is not a workaround in HTML it just writes text in a webpage.
I don't know, import an image or something?

R4356th

OurPrincess wrote:

I don't know, import an image or something?
Have you developed a website before? If you haven't then go to this link and see the demo:
https://www.w3schools.com/html/tryit.asp?filename=tryhtml_default

OurPrincess

R4356th wrote:

OurPrincess wrote:

I don't know, import an image or something?
Have you developed a website before? If you haven't then go to this link and see the demo:
https://www.w3schools.com/html/tryit.asp?filename=tryhtml_default
I've made many websites! Some with a website maker, others with HTML!

R4356th

OurPrincess wrote:

R4356th wrote:

OurPrincess wrote:

I don't know, import an image or something?
Have you developed a website before? If you haven't then go to this link and see the demo:
https://www.w3schools.com/html/tryit.asp?filename=tryhtml_default
I've made many websites! Some with a website maker, others with HTML!
But please look at that. That explains it.