Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inability to loop or repeat code #85

Open
pianokitkat opened this issue Feb 23, 2022 · 1 comment
Open

Inability to loop or repeat code #85

pianokitkat opened this issue Feb 23, 2022 · 1 comment

Comments

@pianokitkat
Copy link

Writing loops does not work. Additionally, repeating code by manually copying and pasting the same code multiple times still does not repeat the actions.

@mayacakmak
Copy link
Owner

Same response as Issue #86

The code written in the 'EMAR robot programming' tools is essentially Javascript and should allow everything you can do in Javascript, including loops, randomization, and defining/calling functions. Below is a simple example that I just tested and seems to work.

var greetings = ["hello", "hi", "greetings"];
var buttonName = null;
for (let i=0; i<greetings.length; i++) {
  let rand = getRandomInt(greetings.length);
  console.log(">>>>>>> " + i);
  console.log("rand " + rand);
  robot.setScreen(i);
  robot.speak(greetings[rand]);
  await robot.sleep(2000);
}

function getRandomInt(max) {
  return Math.floor(Math.random() * max);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants