-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmessenger.js
More file actions
38 lines (37 loc) · 967 Bytes
/
Copy pathmessenger.js
File metadata and controls
38 lines (37 loc) · 967 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
let message = ""
let alphabet = ""
let current = 0
radio.onDataPacketReceived( ({ receivedString }) => {
basic.showString(receivedString)
})
input.onButtonPressed(Button.A, () => {
current += -1
if (current < 0) {
current = alphabet.length - 1
}
basic.showString(alphabet.charAt(current))
})
input.onButtonPressed(Button.B, () => {
current += 1
if (current > alphabet.length) {
current = 0
}
basic.showString(alphabet.charAt(current))
})
input.onButtonPressed(Button.AB, () => {
if (alphabet.substr(current, 1).compare(">") == 0) {
basic.showString(message)
radio.sendString(message)
message = ""
basic.showString(alphabet.charAt(current))
} else {
message = "" + message + alphabet.substr(current, 1)
}
})
radio.setGroup(1)
alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ >"
current = 0
message = ""
basic.showString(alphabet.charAt(current))
basic.forever(() => {
})