-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReadVariable.java
54 lines (46 loc) · 1.35 KB
/
ReadVariable.java
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import processing.core.*;
import processing.data.*;
import java.util.ArrayList;
class ReadVariable extends LogicInputComponent {
public static final Identifier ID = new Identifier("ReadVariable");
int variableNumber=0;
ReadVariable(float x, float y, LogicBoard lb) {
super(x, y, "read var", lb);
button.setText("read var b"+variableNumber+" ");
}
ReadVariable(JSONObject data, LogicBoard lb) {
super(data.getFloat("x"), data.getFloat("y"), "read var", lb, data.getJSONArray("connections"));
variableNumber=data.getInt("variable number");
button.setText("read var b"+variableNumber+" ");
}
public ReadVariable(SerialIterator iterator){
super(iterator);
variableNumber = iterator.getInt();
}
void tick() {
outputTerminal=source.level.variables.get(variableNumber);
}
JSONObject save() {
JSONObject component=super.save();
component.setInt("variable number", variableNumber);
return component;
}
void setData(int data) {
variableNumber=data;
button.setText("read var b"+variableNumber+" ");
}
int getData() {
return variableNumber;
}
@Override
public SerializedData serialize() {
SerializedData data = new SerializedData(id());
serialize(data);
data.addInt(variableNumber);
return data;
}
@Override
public Identifier id() {
return ID;
}
}